mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-30 19:55:08 -04:00
add fixes for .net core
This commit is contained in:
parent
a57c887f7f
commit
a7dcf7191a
@ -13,15 +13,12 @@ namespace Emby.Server.Implementations.AppBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected BaseApplicationPaths(string programDataPath, string appFolderPath, Action<string> createDirectoryFn)
|
protected BaseApplicationPaths(string programDataPath, string appFolderPath)
|
||||||
{
|
{
|
||||||
ProgramDataPath = programDataPath;
|
ProgramDataPath = programDataPath;
|
||||||
ProgramSystemPath = appFolderPath;
|
ProgramSystemPath = appFolderPath;
|
||||||
CreateDirectoryFn = createDirectoryFn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Action<string> CreateDirectoryFn;
|
|
||||||
|
|
||||||
public string ProgramDataPath { get; private set; }
|
public string ProgramDataPath { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -45,7 +42,7 @@ namespace Emby.Server.Implementations.AppBase
|
|||||||
{
|
{
|
||||||
_dataDirectory = Path.Combine(ProgramDataPath, "data");
|
_dataDirectory = Path.Combine(ProgramDataPath, "data");
|
||||||
|
|
||||||
CreateDirectoryFn(_dataDirectory);
|
Directory.CreateDirectory(_dataDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _dataDirectory;
|
return _dataDirectory;
|
||||||
@ -152,7 +149,7 @@ namespace Emby.Server.Implementations.AppBase
|
|||||||
{
|
{
|
||||||
_cachePath = Path.Combine(ProgramDataPath, "cache");
|
_cachePath = Path.Combine(ProgramDataPath, "cache");
|
||||||
|
|
||||||
CreateDirectoryFn(_cachePath);
|
Directory.CreateDirectory(_cachePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _cachePath;
|
return _cachePath;
|
||||||
|
@ -111,6 +111,7 @@ using System.Security.Cryptography.X509Certificates;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Emby.Server.Core.Cryptography;
|
||||||
using Emby.Server.Implementations.Archiving;
|
using Emby.Server.Implementations.Archiving;
|
||||||
using Emby.Server.Implementations.Cryptography;
|
using Emby.Server.Implementations.Cryptography;
|
||||||
using Emby.Server.Implementations.Diagnostics;
|
using Emby.Server.Implementations.Diagnostics;
|
||||||
@ -368,8 +369,6 @@ namespace Emby.Server.Implementations
|
|||||||
internal IPowerManagement PowerManagement { get; private set; }
|
internal IPowerManagement PowerManagement { get; private set; }
|
||||||
internal IImageEncoder ImageEncoder { get; private set; }
|
internal IImageEncoder ImageEncoder { get; private set; }
|
||||||
|
|
||||||
private readonly Action<string, string, string> _certificateGenerator;
|
|
||||||
private readonly Func<string> _defaultUserNameFactory;
|
|
||||||
protected IProcessFactory ProcessFactory { get; private set; }
|
protected IProcessFactory ProcessFactory { get; private set; }
|
||||||
protected ITimerFactory TimerFactory { get; private set; }
|
protected ITimerFactory TimerFactory { get; private set; }
|
||||||
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
|
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
|
||||||
@ -394,10 +393,7 @@ namespace Emby.Server.Implementations
|
|||||||
IEnvironmentInfo environmentInfo,
|
IEnvironmentInfo environmentInfo,
|
||||||
IImageEncoder imageEncoder,
|
IImageEncoder imageEncoder,
|
||||||
ISystemEvents systemEvents,
|
ISystemEvents systemEvents,
|
||||||
IMemoryStreamFactory memoryStreamFactory,
|
INetworkManager networkManager)
|
||||||
INetworkManager networkManager,
|
|
||||||
Action<string, string, string> certificateGenerator,
|
|
||||||
Func<string> defaultUsernameFactory)
|
|
||||||
{
|
{
|
||||||
// hack alert, until common can target .net core
|
// hack alert, until common can target .net core
|
||||||
BaseExtensions.CryptographyProvider = CryptographyProvider;
|
BaseExtensions.CryptographyProvider = CryptographyProvider;
|
||||||
@ -407,7 +403,7 @@ namespace Emby.Server.Implementations
|
|||||||
NetworkManager = networkManager;
|
NetworkManager = networkManager;
|
||||||
EnvironmentInfo = environmentInfo;
|
EnvironmentInfo = environmentInfo;
|
||||||
SystemEvents = systemEvents;
|
SystemEvents = systemEvents;
|
||||||
MemoryStreamFactory = memoryStreamFactory;
|
MemoryStreamFactory = new MemoryStreamProvider();
|
||||||
|
|
||||||
FailedAssemblies = new List<string>();
|
FailedAssemblies = new List<string>();
|
||||||
|
|
||||||
@ -421,9 +417,7 @@ namespace Emby.Server.Implementations
|
|||||||
Logger = LogManager.GetLogger("App");
|
Logger = LogManager.GetLogger("App");
|
||||||
|
|
||||||
StartupOptions = options;
|
StartupOptions = options;
|
||||||
_certificateGenerator = certificateGenerator;
|
|
||||||
_releaseAssetFilename = releaseAssetFilename;
|
_releaseAssetFilename = releaseAssetFilename;
|
||||||
_defaultUserNameFactory = defaultUsernameFactory;
|
|
||||||
PowerManagement = powerManagement;
|
PowerManagement = powerManagement;
|
||||||
|
|
||||||
ImageEncoder = imageEncoder;
|
ImageEncoder = imageEncoder;
|
||||||
@ -917,7 +911,7 @@ namespace Emby.Server.Implementations
|
|||||||
AuthenticationRepository = GetAuthenticationRepository();
|
AuthenticationRepository = GetAuthenticationRepository();
|
||||||
RegisterSingleInstance(AuthenticationRepository);
|
RegisterSingleInstance(AuthenticationRepository);
|
||||||
|
|
||||||
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, _defaultUserNameFactory());
|
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider);
|
||||||
RegisterSingleInstance(UserManager);
|
RegisterSingleInstance(UserManager);
|
||||||
|
|
||||||
LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
|
LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
|
||||||
@ -1652,7 +1646,7 @@ namespace Emby.Server.Implementations
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_certificateGenerator(certPath, certHost, password);
|
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -2314,13 +2308,19 @@ namespace Emby.Server.Implementations
|
|||||||
NotifyPendingRestart();
|
NotifyPendingRestart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _disposed;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
_disposed = true;
|
||||||
|
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace Emby.Server.Core.Cryptography
|
namespace Emby.Server.Core.Cryptography
|
||||||
{
|
{
|
||||||
@ -27,7 +28,11 @@ namespace Emby.Server.Core.Cryptography
|
|||||||
DateTime notAfter = DateTime.Now.AddYears(10);
|
DateTime notAfter = DateTime.Now.AddYears(10);
|
||||||
|
|
||||||
RSA issuerKey = RSA.Create();
|
RSA issuerKey = RSA.Create();
|
||||||
|
#if NET46
|
||||||
issuerKey.FromXmlString(MonoTestRootAgency);
|
issuerKey.FromXmlString(MonoTestRootAgency);
|
||||||
|
#else
|
||||||
|
RSACryptoServiceProviderExtensions.FromXmlString(issuerKey, MonoTestRootAgency);
|
||||||
|
#endif
|
||||||
RSA subjectKey = RSA.Create();
|
RSA subjectKey = RSA.Create();
|
||||||
|
|
||||||
// serial number MUST be positive
|
// serial number MUST be positive
|
||||||
@ -66,4 +71,39 @@ namespace Emby.Server.Core.Cryptography
|
|||||||
p12.SaveToFile(fileName);
|
p12.SaveToFile(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class RSACryptoServiceProviderExtensions
|
||||||
|
{
|
||||||
|
public static void FromXmlString(RSA rsa, string xmlString)
|
||||||
|
{
|
||||||
|
RSAParameters parameters = new RSAParameters();
|
||||||
|
|
||||||
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
xmlDoc.LoadXml(xmlString);
|
||||||
|
|
||||||
|
if (xmlDoc.DocumentElement.Name.Equals("RSAKeyValue"))
|
||||||
|
{
|
||||||
|
foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
|
||||||
|
{
|
||||||
|
switch (node.Name)
|
||||||
|
{
|
||||||
|
case "Modulus": parameters.Modulus = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "Exponent": parameters.Exponent = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "P": parameters.P = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "Q": parameters.Q = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "DP": parameters.DP = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "DQ": parameters.DQ = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "InverseQ": parameters.InverseQ = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
case "D": parameters.D = Convert.FromBase64String(node.InnerText); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid XML RSA key.");
|
||||||
|
}
|
||||||
|
|
||||||
|
rsa.ImportParameters(parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,16 @@ namespace Emby.Server.Implementations.EnvironmentInfo
|
|||||||
{
|
{
|
||||||
public class EnvironmentInfo : IEnvironmentInfo
|
public class EnvironmentInfo : IEnvironmentInfo
|
||||||
{
|
{
|
||||||
public Architecture? CustomArchitecture { get; set; }
|
private Architecture? _customArchitecture;
|
||||||
public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; }
|
private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem;
|
||||||
|
|
||||||
public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
|
public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (CustomOperatingSystem.HasValue)
|
if (_customOperatingSystem.HasValue)
|
||||||
{
|
{
|
||||||
return CustomOperatingSystem.Value;
|
return _customOperatingSystem.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Environment.OSVersion.Platform)
|
switch (Environment.OSVersion.Platform)
|
||||||
@ -30,6 +30,10 @@ namespace Emby.Server.Implementations.EnvironmentInfo
|
|||||||
|
|
||||||
return MediaBrowser.Model.System.OperatingSystem.Windows;
|
return MediaBrowser.Model.System.OperatingSystem.Windows;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_customOperatingSystem = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OperatingSystemName
|
public string OperatingSystemName
|
||||||
@ -60,13 +64,17 @@ namespace Emby.Server.Implementations.EnvironmentInfo
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (CustomArchitecture.HasValue)
|
if (_customArchitecture.HasValue)
|
||||||
{
|
{
|
||||||
return CustomArchitecture.Value;
|
return _customArchitecture.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
|
return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_customArchitecture = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetEnvironmentVariable(string name)
|
public string GetEnvironmentVariable(string name)
|
||||||
|
@ -66,8 +66,10 @@ namespace Emby.Server.Implementations.HttpClientManager
|
|||||||
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
||||||
ServicePointManager.Expect100Continue = false;
|
ServicePointManager.Expect100Continue = false;
|
||||||
|
|
||||||
|
#if NET46
|
||||||
// Trakt requests sometimes fail without this
|
// Trakt requests sometimes fail without this
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -71,9 +71,8 @@ namespace Emby.Server.Implementations.Library
|
|||||||
private readonly IServerApplicationHost _appHost;
|
private readonly IServerApplicationHost _appHost;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly ICryptoProvider _cryptographyProvider;
|
private readonly ICryptoProvider _cryptographyProvider;
|
||||||
private readonly string _defaultUserName;
|
|
||||||
|
|
||||||
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string defaultUserName)
|
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptoProvider cryptographyProvider)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
UserRepository = userRepository;
|
UserRepository = userRepository;
|
||||||
@ -86,7 +85,6 @@ namespace Emby.Server.Implementations.Library
|
|||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_cryptographyProvider = cryptographyProvider;
|
_cryptographyProvider = cryptographyProvider;
|
||||||
_defaultUserName = defaultUserName;
|
|
||||||
ConfigurationManager = configurationManager;
|
ConfigurationManager = configurationManager;
|
||||||
Users = new List<User>();
|
Users = new List<User>();
|
||||||
|
|
||||||
@ -381,7 +379,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
// There always has to be at least one user.
|
// There always has to be at least one user.
|
||||||
if (users.Count == 0)
|
if (users.Count == 0)
|
||||||
{
|
{
|
||||||
var name = MakeValidUsername(_defaultUserName);
|
var name = MakeValidUsername(Environment.UserName);
|
||||||
|
|
||||||
var user = InstantiateNewUser(name);
|
var user = InstantiateNewUser(name);
|
||||||
|
|
||||||
|
@ -138,10 +138,10 @@ namespace Emby.Server.Implementations.Logging
|
|||||||
|
|
||||||
foreach (var message in _queue.GetConsumingEnumerable())
|
foreach (var message in _queue.GetConsumingEnumerable())
|
||||||
{
|
{
|
||||||
any = true;
|
|
||||||
|
|
||||||
var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine);
|
var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine);
|
||||||
_fileStream.Write(bytes, 0, bytes.Length);
|
_fileStream.Write(bytes, 0, bytes.Length);
|
||||||
|
|
||||||
|
any = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any)
|
if (any)
|
||||||
|
@ -186,7 +186,16 @@ namespace Emby.Server.Implementations.Net
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// not supported on all platforms. throws on ubuntu with .net core 2.0
|
||||||
retVal.ExclusiveAddressUse = false;
|
retVal.ExclusiveAddressUse = false;
|
||||||
|
}
|
||||||
|
catch (SocketException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
//retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
//retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
||||||
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||||
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
|
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
|
||||||
|
@ -13,8 +13,8 @@ namespace Emby.Server.Implementations
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
|
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, Action<string> createDirectoryFn)
|
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath)
|
||||||
: base(programDataPath, appFolderPath, createDirectoryFn)
|
: base(programDataPath, appFolderPath)
|
||||||
{
|
{
|
||||||
ApplicationResourcesPath = applicationResourcesPath;
|
ApplicationResourcesPath = applicationResourcesPath;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace MediaBrowser.Model.Session
|
|||||||
/// <value>The position ticks.</value>
|
/// <value>The position ticks.</value>
|
||||||
public long? PositionTicks { get; set; }
|
public long? PositionTicks { get; set; }
|
||||||
|
|
||||||
public long? playbackStartTimeTicks { get; set; }
|
public long? PlaybackStartTimeTicks { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the volume level.
|
/// Gets or sets the volume level.
|
||||||
|
@ -19,7 +19,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
{
|
{
|
||||||
public class MonoAppHost : ApplicationHost
|
public class MonoAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ using Emby.Server.Implementations.Networking;
|
|||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.System;
|
using MediaBrowser.Model.System;
|
||||||
using Mono.Unix.Native;
|
using Mono.Unix.Native;
|
||||||
using NLog;
|
|
||||||
using ILogger = MediaBrowser.Model.Logging.ILogger;
|
using ILogger = MediaBrowser.Model.Logging.ILogger;
|
||||||
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
|
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);
|
var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);
|
||||||
|
|
||||||
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
|
var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server");
|
||||||
logManager.ReloadLogger(LogSeverity.Info);
|
logManager.ReloadLogger(LogSeverity.Info);
|
||||||
logManager.AddConsoleOutput();
|
logManager.AddConsoleOutput();
|
||||||
|
|
||||||
@ -84,9 +83,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
var appFolderPath = Path.GetDirectoryName(applicationPath);
|
var appFolderPath = Path.GetDirectoryName(applicationPath);
|
||||||
|
|
||||||
Action<string> createDirectoryFn = s => Directory.CreateDirectory(s);
|
return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath));
|
||||||
|
|
||||||
return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath), createDirectoryFn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
|
private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>();
|
||||||
@ -113,10 +110,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
environmentInfo,
|
environmentInfo,
|
||||||
imageEncoder,
|
imageEncoder,
|
||||||
new SystemEvents(logManager.GetLogger("SystemEvents")),
|
new SystemEvents(logManager.GetLogger("SystemEvents")),
|
||||||
new MemoryStreamProvider(),
|
new NetworkManager(logManager.GetLogger("NetworkManager")));
|
||||||
new NetworkManager(logManager.GetLogger("NetworkManager")),
|
|
||||||
GenerateCertificate,
|
|
||||||
() => Environment.UserName);
|
|
||||||
|
|
||||||
if (options.ContainsOption("-v"))
|
if (options.ContainsOption("-v"))
|
||||||
{
|
{
|
||||||
@ -141,11 +135,6 @@ namespace MediaBrowser.Server.Mono
|
|||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateCertificate(string certPath, string certHost, string certPassword)
|
|
||||||
{
|
|
||||||
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MonoEnvironmentInfo GetEnvironmentInfo()
|
private static MonoEnvironmentInfo GetEnvironmentInfo()
|
||||||
{
|
{
|
||||||
var info = new MonoEnvironmentInfo();
|
var info = new MonoEnvironmentInfo();
|
||||||
@ -156,39 +145,38 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
//info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
|
info.OperatingSystem = Model.System.OperatingSystem.OSX;
|
||||||
}
|
}
|
||||||
else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
//info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
|
info.OperatingSystem = Model.System.OperatingSystem.Linux;
|
||||||
}
|
}
|
||||||
else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
//info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
|
info.OperatingSystem = Model.System.OperatingSystem.BSD;
|
||||||
info.IsBsd = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var archX86 = new Regex("(i|I)[3-6]86");
|
var archX86 = new Regex("(i|I)[3-6]86");
|
||||||
|
|
||||||
if (archX86.IsMatch(uname.machine))
|
if (archX86.IsMatch(uname.machine))
|
||||||
{
|
{
|
||||||
info.CustomArchitecture = Architecture.X86;
|
info.SystemArchitecture = Architecture.X86;
|
||||||
}
|
}
|
||||||
else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
info.CustomArchitecture = Architecture.X64;
|
info.SystemArchitecture = Architecture.X64;
|
||||||
}
|
}
|
||||||
else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
|
else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
info.CustomArchitecture = Architecture.Arm;
|
info.SystemArchitecture = Architecture.Arm;
|
||||||
}
|
}
|
||||||
else if (System.Environment.Is64BitOperatingSystem)
|
else if (System.Environment.Is64BitOperatingSystem)
|
||||||
{
|
{
|
||||||
info.CustomArchitecture = Architecture.X64;
|
info.SystemArchitecture = Architecture.X64;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.CustomArchitecture = Architecture.X86;
|
info.SystemArchitecture = Architecture.X86;
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
@ -308,24 +296,9 @@ namespace MediaBrowser.Server.Mono
|
|||||||
|
|
||||||
public class MonoEnvironmentInfo : EnvironmentInfo
|
public class MonoEnvironmentInfo : EnvironmentInfo
|
||||||
{
|
{
|
||||||
public bool IsBsd { get; set; }
|
|
||||||
|
|
||||||
public override string GetUserId()
|
public override string GetUserId()
|
||||||
{
|
{
|
||||||
return Syscall.getuid().ToString(CultureInfo.InvariantCulture);
|
return Syscall.getuid().ToString(CultureInfo.InvariantCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Model.System.OperatingSystem OperatingSystem
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (IsBsd)
|
|
||||||
{
|
|
||||||
return Model.System.OperatingSystem.BSD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OperatingSystem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using Emby.Drawing;
|
using Emby.Drawing;
|
||||||
using Emby.Drawing.ImageMagick;
|
|
||||||
using Emby.Drawing.Skia;
|
using Emby.Drawing.Skia;
|
||||||
using Emby.Server.Core;
|
using Emby.Server.Core;
|
||||||
using Emby.Server.Implementations;
|
using Emby.Server.Implementations;
|
||||||
|
@ -236,18 +236,16 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
var resourcesPath = Path.GetDirectoryName(applicationPath);
|
var resourcesPath = Path.GetDirectoryName(applicationPath);
|
||||||
|
|
||||||
Action<string> createDirectoryFn = s => Directory.CreateDirectory(s);
|
|
||||||
|
|
||||||
if (runAsService)
|
if (runAsService)
|
||||||
{
|
{
|
||||||
var systemPath = Path.GetDirectoryName(applicationPath);
|
var systemPath = Path.GetDirectoryName(applicationPath);
|
||||||
|
|
||||||
var programDataPath = Path.GetDirectoryName(systemPath);
|
var programDataPath = Path.GetDirectoryName(systemPath);
|
||||||
|
|
||||||
return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath, createDirectoryFn);
|
return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath, createDirectoryFn);
|
return new ServerApplicationPaths(ApplicationPathHelper.GetProgramDataPath(applicationPath), appFolderPath, resourcesPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -316,10 +314,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
environmentInfo,
|
environmentInfo,
|
||||||
new NullImageEncoder(),
|
new NullImageEncoder(),
|
||||||
new SystemEvents(logManager.GetLogger("SystemEvents")),
|
new SystemEvents(logManager.GetLogger("SystemEvents")),
|
||||||
new MemoryStreamProvider(),
|
new Networking.NetworkManager(logManager.GetLogger("NetworkManager")));
|
||||||
new Networking.NetworkManager(logManager.GetLogger("NetworkManager")),
|
|
||||||
GenerateCertificate,
|
|
||||||
() => Environment.UserDomainName);
|
|
||||||
|
|
||||||
var initProgress = new Progress<double>();
|
var initProgress = new Progress<double>();
|
||||||
|
|
||||||
@ -366,11 +361,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateCertificate(string certPath, string certHost, string certPassword)
|
|
||||||
{
|
|
||||||
CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ServerNotifyIcon _serverNotifyIcon;
|
private static ServerNotifyIcon _serverNotifyIcon;
|
||||||
private static TaskScheduler _mainTaskScheduler;
|
private static TaskScheduler _mainTaskScheduler;
|
||||||
private static void ShowTrayIcon()
|
private static void ShowTrayIcon()
|
||||||
|
@ -201,10 +201,6 @@
|
|||||||
<Project>{805844ab-e92f-45e6-9d99-4f6d48d129a5}</Project>
|
<Project>{805844ab-e92f-45e6-9d99-4f6d48d129a5}</Project>
|
||||||
<Name>Emby.Dlna</Name>
|
<Name>Emby.Dlna</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Emby.Drawing.ImageMagick\Emby.Drawing.ImageMagick.csproj">
|
|
||||||
<Project>{6cfee013-6e7c-432b-ac37-cabf0880c69a}</Project>
|
|
||||||
<Name>Emby.Drawing.ImageMagick</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\Emby.Drawing.Skia\Emby.Drawing.Skia.csproj">
|
<ProjectReference Include="..\Emby.Drawing.Skia\Emby.Drawing.Skia.csproj">
|
||||||
<Project>{2312da6d-ff86-4597-9777-bceec32d96dd}</Project>
|
<Project>{2312da6d-ff86-4597-9777-bceec32d96dd}</Project>
|
||||||
<Name>Emby.Drawing.Skia</Name>
|
<Name>Emby.Drawing.Skia</Name>
|
||||||
|
@ -25,8 +25,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
public class WindowsAppHost : ApplicationHost
|
public class WindowsAppHost : ApplicationHost
|
||||||
{
|
{
|
||||||
public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string, string> certificateGenerator, Func<string> defaultUsernameFactory)
|
public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager)
|
||||||
: base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
: base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user