Add certificate to https and minor cleanup
This commit is contained in:
parent
6bdb5debd2
commit
e823c11b46
|
@ -626,9 +626,12 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
options.Listen(IPAddress.Any, HttpPort);
|
options.Listen(IPAddress.Any, HttpPort);
|
||||||
options.Listen(IPAddress.Loopback, HttpPort);
|
options.Listen(IPAddress.Loopback, HttpPort);
|
||||||
// TODO certs
|
|
||||||
options.Listen(IPAddress.Any, HttpsPort, listenOptions => { listenOptions.UseHttps(); });
|
if (CertificateInfo != null)
|
||||||
options.Listen(IPAddress.Loopback, HttpsPort, listenOptions => { listenOptions.UseHttps(); });
|
{
|
||||||
|
options.Listen(IPAddress.Any, HttpsPort, listenOptions => { listenOptions.UseHttps(Certificate); });
|
||||||
|
options.Listen(IPAddress.Loopback, HttpsPort, listenOptions => { listenOptions.UseHttps(Certificate); });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.UseContentRoot(Path.Combine(Directory.GetCurrentDirectory(), "jellyfin-web", "src"))
|
.UseContentRoot(Path.Combine(Directory.GetCurrentDirectory(), "jellyfin-web", "src"))
|
||||||
.ConfigureServices(services =>
|
.ConfigureServices(services =>
|
||||||
|
@ -927,11 +930,9 @@ namespace Emby.Server.Implementations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool SupportsDualModeSockets => true;
|
private X509Certificate2 GetCertificate(CertificateInfo info)
|
||||||
|
|
||||||
private X509Certificate GetCertificate(CertificateInfo info)
|
|
||||||
{
|
{
|
||||||
var certificateLocation = info == null ? null : info.Path;
|
var certificateLocation = info?.Path;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(certificateLocation))
|
if (string.IsNullOrWhiteSpace(certificateLocation))
|
||||||
{
|
{
|
||||||
|
@ -1004,7 +1005,7 @@ namespace Emby.Server.Implementations
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual FFMpegInfo GetFFMpegInfo()
|
protected FFMpegInfo GetFFMpegInfo()
|
||||||
{
|
{
|
||||||
return new FFMpegLoader(ApplicationPaths, FileSystemManager, GetFfmpegInstallInfo())
|
return new FFMpegLoader(ApplicationPaths, FileSystemManager, GetFfmpegInstallInfo())
|
||||||
.GetFFMpegInfo(StartupOptions);
|
.GetFFMpegInfo(StartupOptions);
|
||||||
|
@ -1085,7 +1086,7 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void SetStaticProperties()
|
private void SetStaticProperties()
|
||||||
{
|
{
|
||||||
((SqliteItemRepository)ItemRepository).ImageProcessor = ImageProcessor;
|
ItemRepository.ImageProcessor = ImageProcessor;
|
||||||
|
|
||||||
// For now there's no real way to inject these properly
|
// For now there's no real way to inject these properly
|
||||||
BaseItem.Logger = LoggerFactory.CreateLogger("BaseItem");
|
BaseItem.Logger = LoggerFactory.CreateLogger("BaseItem");
|
||||||
|
@ -1211,15 +1212,12 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
AllConcreteTypes = GetComposablePartAssemblies()
|
AllConcreteTypes = GetComposablePartAssemblies()
|
||||||
.SelectMany(x => x.ExportedTypes)
|
.SelectMany(x => x.ExportedTypes)
|
||||||
.Where(type =>
|
.Where(type => type.IsClass && !type.IsAbstract && !type.IsInterface && !type.IsGenericType)
|
||||||
{
|
|
||||||
return type.IsClass && !type.IsAbstract && !type.IsInterface && !type.IsGenericType;
|
|
||||||
})
|
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CertificateInfo CertificateInfo { get; set; }
|
private CertificateInfo CertificateInfo { get; set; }
|
||||||
protected X509Certificate Certificate { get; private set; }
|
protected X509Certificate2 Certificate { get; private set; }
|
||||||
|
|
||||||
private IEnumerable<string> GetUrlPrefixes()
|
private IEnumerable<string> GetUrlPrefixes()
|
||||||
{
|
{
|
||||||
|
|
|
@ -855,16 +855,5 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartServer(string[] urlPrefixes, IHttpListener httpListener)
|
|
||||||
{
|
|
||||||
UrlPrefixes = urlPrefixes;
|
|
||||||
|
|
||||||
_listener = httpListener;
|
|
||||||
|
|
||||||
_listener.WebSocketConnected = OnWebSocketConnected;
|
|
||||||
_listener.ErrorHandler = ErrorHandler;
|
|
||||||
_listener.RequestHandler = RequestHandler;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace Emby.Server.Implementations.WebSockets
|
||||||
{
|
{
|
||||||
public interface IWebSocketHandler
|
public interface IWebSocketHandler
|
||||||
{
|
{
|
||||||
Task ProcessMessage(WebSocketMessage<object> message);
|
Task ProcessMessage(WebSocketMessage<object> message, TaskCompletionSource<bool> taskCompletionSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace Emby.Server.Implementations.WebSockets
|
||||||
WebSocketReceiveResult result;
|
WebSocketReceiveResult result;
|
||||||
var message = new List<byte>();
|
var message = new List<byte>();
|
||||||
|
|
||||||
|
// Keep listening for incoming messages, otherwise the socket closes automatically
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
var buffer = WebSocket.CreateServerBuffer(BufferSize);
|
var buffer = WebSocket.CreateServerBuffer(BufferSize);
|
||||||
|
@ -57,7 +58,7 @@ namespace Emby.Server.Implementations.WebSockets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ProcessMessage(byte[] messageBytes, TaskCompletionSource<bool> taskCompletionSource)
|
private async Task ProcessMessage(byte[] messageBytes, TaskCompletionSource<bool> taskCompletionSource)
|
||||||
{
|
{
|
||||||
var charset = CharsetDetector.DetectFromBytes(messageBytes).Detected?.EncodingName;
|
var charset = CharsetDetector.DetectFromBytes(messageBytes).Detected?.EncodingName;
|
||||||
var message = string.Equals(charset, "utf-8", StringComparison.OrdinalIgnoreCase)
|
var message = string.Equals(charset, "utf-8", StringComparison.OrdinalIgnoreCase)
|
||||||
|
@ -81,11 +82,12 @@ namespace Emby.Server.Implementations.WebSockets
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
handler.ProcessMessage(info).ConfigureAwait(false);
|
handler.ProcessMessage(info, taskCompletionSource).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "{0} failed processing WebSocket message {1}", handler.GetType().Name, info.MessageType ?? string.Empty);
|
_logger.LogError(ex, "{HandlerType} failed processing WebSocket message {MessageType}",
|
||||||
|
handler.GetType().Name, info.MessageType ?? string.Empty);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ namespace Jellyfin.Server
|
||||||
|
|
||||||
public override bool CanSelfRestart => StartupOptions.RestartPath != null;
|
public override bool CanSelfRestart => StartupOptions.RestartPath != null;
|
||||||
|
|
||||||
protected override bool SupportsDualModeSockets => true;
|
|
||||||
|
|
||||||
protected override void RestartInternal() => Program.Restart();
|
protected override void RestartInternal() => Program.Restart();
|
||||||
|
|
||||||
protected override IEnumerable<Assembly> GetAssembliesWithPartsInternal()
|
protected override IEnumerable<Assembly> GetAssembliesWithPartsInternal()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user