Fix blackhole downloads #135

This commit is contained in:
Azerelat 2015-12-27 21:25:54 +00:00
parent aadf25e3b6
commit d598017a03
1 changed files with 143 additions and 143 deletions

View File

@ -1,143 +1,143 @@
using Owin; using Owin;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Http; using System.Web.Http;
using Autofac.Integration.WebApi; using Autofac.Integration.WebApi;
using Microsoft.Owin; using Microsoft.Owin;
using Jackett; using Jackett;
using Microsoft.Owin.StaticFiles; using Microsoft.Owin.StaticFiles;
using Microsoft.Owin.FileSystems; using Microsoft.Owin.FileSystems;
using Autofac; using Autofac;
using Jackett.Services; using Jackett.Services;
using System.Web.Http.Tracing; using System.Web.Http.Tracing;
using Jackett.Utils; using Jackett.Utils;
using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity;
[assembly: OwinStartup(typeof(Startup))] [assembly: OwinStartup(typeof(Startup))]
namespace Jackett namespace Jackett
{ {
public class Startup public class Startup
{ {
public static bool TracingEnabled public static bool TracingEnabled
{ {
get; get;
set; set;
} }
public static bool LogRequests public static bool LogRequests
{ {
get; get;
set; set;
} }
public static string ClientOverride public static string ClientOverride
{ {
get; get;
set; set;
} }
public static bool? DoSSLFix public static bool? DoSSLFix
{ {
get; get;
set; set;
} }
public static bool? IgnoreSslErrors public static bool? IgnoreSslErrors
{ {
get; get;
set; set;
} }
public void Configuration(IAppBuilder appBuilder) public void Configuration(IAppBuilder appBuilder)
{ {
// Configure Web API for self-host. // Configure Web API for self-host.
var config = new HttpConfiguration(); var config = new HttpConfiguration();
appBuilder.Use<WebApiRootRedirectMiddleware>(); appBuilder.Use<WebApiRootRedirectMiddleware>();
// Setup tracing if enabled // Setup tracing if enabled
if (TracingEnabled) if (TracingEnabled)
{ {
config.EnableSystemDiagnosticsTracing(); config.EnableSystemDiagnosticsTracing();
config.Services.Replace(typeof(ITraceWriter), new WebAPIToNLogTracer()); config.Services.Replace(typeof(ITraceWriter), new WebAPIToNLogTracer());
} }
// Add request logging if enabled // Add request logging if enabled
if (LogRequests) if (LogRequests)
{ {
config.MessageHandlers.Add(new WebAPIRequestLogger()); config.MessageHandlers.Add(new WebAPIRequestLogger());
} }
config.DependencyResolver = new AutofacWebApiDependencyResolver(Engine.GetContainer()); config.DependencyResolver = new AutofacWebApiDependencyResolver(Engine.GetContainer());
config.MapHttpAttributeRoutes(); config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "Admin", name: "Admin",
routeTemplate: "admin/{action}", routeTemplate: "admin/{action}",
defaults: new { controller = "Admin" } defaults: new { controller = "Admin" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "apiDefault", name: "apiDefault",
routeTemplate: "api/{indexerID}", routeTemplate: "api/{indexerID}",
defaults: new { controller = "Torznab", action = "Call" } defaults: new { controller = "Torznab", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "api", name: "api",
routeTemplate: "api/{indexerID}/api", routeTemplate: "api/{indexerID}/api",
defaults: new { controller = "Torznab", action = "Call" } defaults: new { controller = "Torznab", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "torznabDefault", name: "torznabDefault",
routeTemplate: "torznab/{indexerID}", routeTemplate: "torznab/{indexerID}",
defaults: new { controller = "Torznab", action = "Call" } defaults: new { controller = "Torznab", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "torznab", name: "torznab",
routeTemplate: "torznab/{indexerID}/api", routeTemplate: "torznab/{indexerID}/api",
defaults: new { controller = "Torznab", action = "Call" } defaults: new { controller = "Torznab", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "potatoDefault", name: "potatoDefault",
routeTemplate: "potato/{indexerID}", routeTemplate: "potato/{indexerID}",
defaults: new { controller = "Potato", action = "Call" } defaults: new { controller = "Potato", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "potato", name: "potato",
routeTemplate: "potato/{indexerID}/api", routeTemplate: "potato/{indexerID}/api",
defaults: new { controller = "Potato", action = "Call" } defaults: new { controller = "Potato", action = "Call" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "download", name: "download",
routeTemplate: "dl/{indexerID}/{apiKey}", routeTemplate: "dl/{indexerID}/{apiKey}",
defaults: new { controller = "Download", action = "Download" } defaults: new { controller = "Download", action = "Download" }
); );
config.Routes.MapHttpRoute( config.Routes.MapHttpRoute(
name: "blackhole", name: "blackhole",
routeTemplate: "bh/{indexerID}/{apikey}/{path}", routeTemplate: "bh/{indexerID}/{apikey}",
defaults: new { controller = "Blackhole", action = "Blackhole" } defaults: new { controller = "Blackhole", action = "Blackhole" }
); );
appBuilder.UseWebApi(config); appBuilder.UseWebApi(config);
appBuilder.UseFileServer(new FileServerOptions appBuilder.UseFileServer(new FileServerOptions
{ {
RequestPath = new PathString(string.Empty), RequestPath = new PathString(string.Empty),
FileSystem = new PhysicalFileSystem(Engine.ConfigService.GetContentFolder()), FileSystem = new PhysicalFileSystem(Engine.ConfigService.GetContentFolder()),
EnableDirectoryBrowsing = false, EnableDirectoryBrowsing = false,
}); });
} }
} }
} }