commit
f1322555d5
|
@ -184,6 +184,9 @@ namespace Exceptron.Client
|
||||||
{
|
{
|
||||||
report.cul = Thread.CurrentThread.CurrentCulture.Name;
|
report.cul = Thread.CurrentThread.CurrentCulture.Name;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(report.cul))
|
||||||
|
report.cul = "en";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
report.os = Environment.OSVersion.VersionString;
|
report.os = Environment.OSVersion.VersionString;
|
||||||
|
|
|
@ -12,12 +12,10 @@ namespace NzbDrone.Api.Authentication
|
||||||
{
|
{
|
||||||
public class EnableStatelessAuthInNancy : IRegisterNancyPipeline
|
public class EnableStatelessAuthInNancy : IRegisterNancyPipeline
|
||||||
{
|
{
|
||||||
private readonly IAuthenticationService _authenticationService;
|
|
||||||
private static String API_KEY;
|
private static String API_KEY;
|
||||||
|
|
||||||
public EnableStatelessAuthInNancy(IAuthenticationService authenticationService, IConfigFileProvider configFileProvider)
|
public EnableStatelessAuthInNancy(IConfigFileProvider configFileProvider)
|
||||||
{
|
{
|
||||||
_authenticationService = authenticationService;
|
|
||||||
API_KEY = configFileProvider.ApiKey;
|
API_KEY = configFileProvider.ApiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,17 +27,12 @@ namespace NzbDrone.Api.Authentication
|
||||||
public Response ValidateApiKey(NancyContext context)
|
public Response ValidateApiKey(NancyContext context)
|
||||||
{
|
{
|
||||||
Response response = null;
|
Response response = null;
|
||||||
|
|
||||||
if (!RuntimeInfo.IsProduction && context.Request.IsLocalRequest())
|
|
||||||
{
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
var authorizationHeader = context.Request.Headers.Authorization;
|
var authorizationHeader = context.Request.Headers.Authorization;
|
||||||
var apiKeyHeader = context.Request.Headers["X-Api-Key"].FirstOrDefault();
|
var apiKeyHeader = context.Request.Headers["X-Api-Key"].FirstOrDefault();
|
||||||
var apiKey = apiKeyHeader.IsNullOrWhiteSpace() ? authorizationHeader : apiKeyHeader;
|
var apiKey = apiKeyHeader.IsNullOrWhiteSpace() ? authorizationHeader : apiKeyHeader;
|
||||||
|
|
||||||
if (context.Request.IsApiRequest() && !ValidApiKey(apiKey) && !IsAuthenticated(context))
|
if (context.Request.IsApiRequest() && !ValidApiKey(apiKey))
|
||||||
{
|
{
|
||||||
response = new Response { StatusCode = HttpStatusCode.Unauthorized };
|
response = new Response { StatusCode = HttpStatusCode.Unauthorized };
|
||||||
}
|
}
|
||||||
|
@ -49,15 +42,9 @@ namespace NzbDrone.Api.Authentication
|
||||||
|
|
||||||
private bool ValidApiKey(string apiKey)
|
private bool ValidApiKey(string apiKey)
|
||||||
{
|
{
|
||||||
if (apiKey.IsNullOrWhiteSpace()) return false;
|
if (!API_KEY.Equals(apiKey)) return false;
|
||||||
if (!apiKey.Equals(API_KEY)) return false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAuthenticated(NancyContext context)
|
|
||||||
{
|
|
||||||
return _authenticationService.Enabled && _authenticationService.IsAuthenticated(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,8 +40,8 @@ namespace NzbDrone.Api.Calendar
|
||||||
var occurrence = icalCalendar.Create<Event>();
|
var occurrence = icalCalendar.Create<Event>();
|
||||||
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();
|
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();
|
||||||
occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
||||||
occurrence.Start = new iCalDateTime(episode.AirDateUtc.Value);
|
occurrence.Start = new iCalDateTime(episode.AirDateUtc.Value) { HasTime = true };
|
||||||
occurrence.End = new iCalDateTime(episode.AirDateUtc.Value.AddMinutes(episode.Series.Runtime));
|
occurrence.End = new iCalDateTime(episode.AirDateUtc.Value.AddMinutes(episode.Series.Runtime)) { HasTime = true };
|
||||||
occurrence.Description = episode.Overview;
|
occurrence.Description = episode.Overview;
|
||||||
occurrence.Categories = new List<string>() { episode.Series.Network };
|
occurrence.Categories = new List<string>() { episode.Series.Network };
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace NzbDrone.Api.Extensions
|
||||||
{
|
{
|
||||||
public static bool IsApiRequest(this Request request)
|
public static bool IsApiRequest(this Request request)
|
||||||
{
|
{
|
||||||
return request.Path.StartsWith("/api/", StringComparison.InvariantCultureIgnoreCase) || request.IsLogFileRequest();
|
return request.Path.StartsWith("/api/", StringComparison.InvariantCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsSignalRRequest(this Request request)
|
public static bool IsSignalRRequest(this Request request)
|
||||||
|
@ -21,11 +21,5 @@ namespace NzbDrone.Api.Extensions
|
||||||
request.UserHostAddress.Equals("127.0.0.1") ||
|
request.UserHostAddress.Equals("127.0.0.1") ||
|
||||||
request.UserHostAddress.Equals("::1"));
|
request.UserHostAddress.Equals("::1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsLogFileRequest(this Request request)
|
|
||||||
{
|
|
||||||
return request.Path.StartsWith("/log/", StringComparison.InvariantCultureIgnoreCase) &&
|
|
||||||
request.Path.EndsWith(".txt", StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,15 @@ using System.Linq;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using Nancy;
|
||||||
|
using Nancy.Responses;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Logs
|
namespace NzbDrone.Api.Logs
|
||||||
{
|
{
|
||||||
public class LogFileModule : NzbDroneRestModule<LogFileResource>
|
public class LogFileModule : NzbDroneRestModule<LogFileResource>
|
||||||
{
|
{
|
||||||
|
private const string LOGFILE_ROUTE = @"/(?<filename>nzbdrone(?:\.\d+)?\.txt)";
|
||||||
|
|
||||||
private readonly IAppFolderInfo _appFolderInfo;
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
|
||||||
|
@ -19,6 +23,8 @@ namespace NzbDrone.Api.Logs
|
||||||
_appFolderInfo = appFolderInfo;
|
_appFolderInfo = appFolderInfo;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
GetResourceAll = GetLogFiles;
|
GetResourceAll = GetLogFiles;
|
||||||
|
|
||||||
|
Get[LOGFILE_ROUTE] = options => GetLogFile(options.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LogFileResource> GetLogFiles()
|
private List<LogFileResource> GetLogFiles()
|
||||||
|
@ -41,5 +47,17 @@ namespace NzbDrone.Api.Logs
|
||||||
|
|
||||||
return result.OrderByDescending(l => l.LastWriteTime).ToList();
|
return result.OrderByDescending(l => l.LastWriteTime).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response GetLogFile(string filename)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(_appFolderInfo.GetLogFolder(), filename);
|
||||||
|
|
||||||
|
if (!_diskProvider.FileExists(filePath))
|
||||||
|
return new NotFoundResponse();
|
||||||
|
|
||||||
|
var data = _diskProvider.ReadAllText(filePath);
|
||||||
|
|
||||||
|
return new TextResponse(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -116,7 +116,7 @@ namespace NzbDrone.Common.Processes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
logger.Info("Starting {0} {1}", path, args);
|
logger.Debug("Starting {0} {1}", path, args);
|
||||||
|
|
||||||
var process = new Process
|
var process = new Process
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ namespace NzbDrone.Common.Processes
|
||||||
path = "mono";
|
path = "mono";
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info("Starting {0} {1}", path, args);
|
Logger.Debug("Starting {0} {1}", path, args);
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo(path, args);
|
var startInfo = new ProcessStartInfo(path, args);
|
||||||
var process = new Process
|
var process = new Process
|
||||||
|
|
|
@ -22,7 +22,7 @@ define(
|
||||||
_onClick: function () {
|
_onClick: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (window.confirm('Are you sure you want to delete \'{0}\' form disk?'.format(this.model.get('path')))) {
|
if (window.confirm('Are you sure you want to delete \'{0}\' from disk?'.format(this.model.get('path')))) {
|
||||||
this.model.destroy()
|
this.model.destroy()
|
||||||
.done(function () {
|
.done(function () {
|
||||||
vent.trigger(vent.Events.EpisodeFileDeleted, { episodeFile: self.model });
|
vent.trigger(vent.Events.EpisodeFileDeleted, { episodeFile: self.model });
|
||||||
|
|
|
@ -13,22 +13,22 @@
|
||||||
{{#if_eq eventType compare="grabbed"}}
|
{{#if_eq eventType compare="grabbed"}}
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
|
||||||
<dt>Name</dt>
|
<dt>Name:</dt>
|
||||||
<dd>{{sourceTitle}}</dd>
|
<dd>{{sourceTitle}}</dd>
|
||||||
|
|
||||||
{{#with data}}
|
{{#with data}}
|
||||||
{{#if indexer}}
|
{{#if indexer}}
|
||||||
<dt>Indexer</dt>
|
<dt>Indexer:</dt>
|
||||||
<dd>{{indexer}}</dd>
|
<dd>{{indexer}}</dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if releaseGroup}}
|
{{#if releaseGroup}}
|
||||||
<dt>Release Group</dt>
|
<dt>Release Group:</dt>
|
||||||
<dd>{{releaseGroup}}</dd>
|
<dd>{{releaseGroup}}</dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if nzbInfoUrl}}
|
{{#if nzbInfoUrl}}
|
||||||
<dt>Info</dt>
|
<dt>Info:</dt>
|
||||||
<dd><a href="{{nzbInfoUrl}}">{{nzbInfoUrl}}</a></dd>
|
<dd><a href="{{nzbInfoUrl}}">{{nzbInfoUrl}}</a></dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
@ -36,19 +36,25 @@
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{#if_eq eventType compare="downloadFailed"}}
|
{{#if_eq eventType compare="downloadFailed"}}
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
<dt>Source Title</dt>
|
|
||||||
|
<dt>Name:</dt>
|
||||||
<dd>{{sourceTitle}}</dd>
|
<dd>{{sourceTitle}}</dd>
|
||||||
|
|
||||||
{{#with data}}
|
{{#with data}}
|
||||||
<dt>Message</dt>
|
<dt>Message:</dt>
|
||||||
<dd>{{message}}</dd>
|
<dd>{{message}}</dd>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
</dl>
|
</dl>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{#if_eq eventType compare="downloadFolderImported"}}
|
{{#if_eq eventType compare="downloadFolderImported"}}
|
||||||
{{#if data}}
|
<dl class="dl-horizontal">
|
||||||
|
|
||||||
|
{{#if sourceTitle}}
|
||||||
|
<dt>Name:</dt>
|
||||||
|
<dd>{{sourceTitle}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#with data}}
|
{{#with data}}
|
||||||
<dl class="dl-horizontal">
|
|
||||||
{{#if droppedPath}}
|
{{#if droppedPath}}
|
||||||
<dt>Source:</dt>
|
<dt>Source:</dt>
|
||||||
<dd>{{droppedPath}}</dd>
|
<dd>{{droppedPath}}</dd>
|
||||||
|
@ -58,11 +64,8 @@
|
||||||
<dt>Imported To:</dt>
|
<dt>Imported To:</dt>
|
||||||
<dd>{{importedPath}}</dd>
|
<dd>{{importedPath}}</dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</dl>
|
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{else}}
|
</dl>
|
||||||
No details available
|
|
||||||
{{/if}}
|
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -6,7 +6,7 @@ define(
|
||||||
], function (Backbone, StatusModel) {
|
], function (Backbone, StatusModel) {
|
||||||
return Backbone.Model.extend({
|
return Backbone.Model.extend({
|
||||||
url: function () {
|
url: function () {
|
||||||
return StatusModel.get('urlBase') + '/logfile/' + this.get('filename');
|
return StatusModel.get('urlBase') + '/api/log/file/' + this.get('filename');
|
||||||
},
|
},
|
||||||
|
|
||||||
parse: function (contents) {
|
parse: function (contents) {
|
||||||
|
|
Loading…
Reference in New Issue