encrypt original path in download links and move apikey to parameters

This commit is contained in:
kaso17
2017-08-11 15:14:40 +02:00
parent 84a45737d3
commit 289c5cd24f
4 changed files with 21 additions and 11 deletions

View File

@@ -23,16 +23,18 @@ namespace Jackett.Controllers
private Logger logger;
private IIndexerManagerService indexerService;
IServerService serverService;
IProtectionService protectionService;
public BlackholeController(IIndexerManagerService i, Logger l, IServerService s)
public BlackholeController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps)
{
logger = l;
indexerService = i;
serverService = s;
protectionService = ps;
}
[HttpGet]
public async Task<IHttpActionResult> Blackhole(string indexerID, string path, string apikey, string file)
public async Task<IHttpActionResult> Blackhole(string indexerID, string path, string jackett_apikey, string file)
{
var jsonReply = new JObject();
@@ -45,10 +47,12 @@ namespace Jackett.Controllers
throw new Exception("This indexer is not configured.");
}
if (serverService.Config.APIKey != apikey)
if (serverService.Config.APIKey != jackett_apikey)
throw new Exception("Incorrect API key");
var remoteFile = new Uri(Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path)), UriKind.RelativeOrAbsolute);
path = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path));
path = protectionService.UnProtect(path);
var remoteFile = new Uri(path, UriKind.RelativeOrAbsolute);
var downloadBytes = await indexer.Download(remoteFile);
if (string.IsNullOrWhiteSpace(Engine.Server.Config.BlackholeDir))