mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-10-31 10:37:22 -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> | ||||
|         /// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class. | ||||
|         /// </summary> | ||||
|         protected BaseApplicationPaths(string programDataPath, string appFolderPath, Action<string> createDirectoryFn) | ||||
|         protected BaseApplicationPaths(string programDataPath, string appFolderPath) | ||||
|         { | ||||
|             ProgramDataPath = programDataPath; | ||||
|             ProgramSystemPath = appFolderPath; | ||||
|             CreateDirectoryFn = createDirectoryFn; | ||||
|         } | ||||
| 
 | ||||
|         protected Action<string> CreateDirectoryFn; | ||||
| 
 | ||||
|         public string ProgramDataPath { get; private set; } | ||||
| 
 | ||||
|         /// <summary> | ||||
| @ -45,7 +42,7 @@ namespace Emby.Server.Implementations.AppBase | ||||
|                 { | ||||
|                     _dataDirectory = Path.Combine(ProgramDataPath, "data"); | ||||
| 
 | ||||
|                     CreateDirectoryFn(_dataDirectory); | ||||
|                     Directory.CreateDirectory(_dataDirectory); | ||||
|                 } | ||||
| 
 | ||||
|                 return _dataDirectory; | ||||
| @ -152,7 +149,7 @@ namespace Emby.Server.Implementations.AppBase | ||||
|                 { | ||||
|                     _cachePath = Path.Combine(ProgramDataPath, "cache"); | ||||
| 
 | ||||
|                     CreateDirectoryFn(_cachePath); | ||||
|                     Directory.CreateDirectory(_cachePath); | ||||
|                 } | ||||
| 
 | ||||
|                 return _cachePath; | ||||
|  | ||||
| @ -111,6 +111,7 @@ using System.Security.Cryptography.X509Certificates; | ||||
| using System.Text; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Emby.Server.Core.Cryptography; | ||||
| using Emby.Server.Implementations.Archiving; | ||||
| using Emby.Server.Implementations.Cryptography; | ||||
| using Emby.Server.Implementations.Diagnostics; | ||||
| @ -368,8 +369,6 @@ namespace Emby.Server.Implementations | ||||
|         internal IPowerManagement PowerManagement { 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 ITimerFactory TimerFactory { get; private set; } | ||||
|         protected ICryptoProvider CryptographyProvider = new CryptographyProvider(); | ||||
| @ -394,10 +393,7 @@ namespace Emby.Server.Implementations | ||||
|             IEnvironmentInfo environmentInfo, | ||||
|             IImageEncoder imageEncoder, | ||||
|             ISystemEvents systemEvents, | ||||
|             IMemoryStreamFactory memoryStreamFactory, | ||||
|             INetworkManager networkManager, | ||||
|             Action<string, string, string> certificateGenerator, | ||||
|             Func<string> defaultUsernameFactory) | ||||
|             INetworkManager networkManager) | ||||
|         { | ||||
|             // hack alert, until common can target .net core | ||||
|             BaseExtensions.CryptographyProvider = CryptographyProvider; | ||||
| @ -407,7 +403,7 @@ namespace Emby.Server.Implementations | ||||
|             NetworkManager = networkManager; | ||||
|             EnvironmentInfo = environmentInfo; | ||||
|             SystemEvents = systemEvents; | ||||
|             MemoryStreamFactory = memoryStreamFactory; | ||||
|             MemoryStreamFactory = new MemoryStreamProvider(); | ||||
| 
 | ||||
|             FailedAssemblies = new List<string>(); | ||||
| 
 | ||||
| @ -421,9 +417,7 @@ namespace Emby.Server.Implementations | ||||
|             Logger = LogManager.GetLogger("App"); | ||||
| 
 | ||||
|             StartupOptions = options; | ||||
|             _certificateGenerator = certificateGenerator; | ||||
|             _releaseAssetFilename = releaseAssetFilename; | ||||
|             _defaultUserNameFactory = defaultUsernameFactory; | ||||
|             PowerManagement = powerManagement; | ||||
| 
 | ||||
|             ImageEncoder = imageEncoder; | ||||
| @ -917,7 +911,7 @@ namespace Emby.Server.Implementations | ||||
|             AuthenticationRepository = GetAuthenticationRepository(); | ||||
|             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); | ||||
| 
 | ||||
|             LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager); | ||||
| @ -1257,7 +1251,7 @@ namespace Emby.Server.Implementations | ||||
|                 case MediaBrowser.Model.System.Architecture.X64: | ||||
|                     return new[] | ||||
|                     { | ||||
|                                 "https://embydata.com/downloads/ffmpeg/osx/ffmpeg-x64-20170308.7z" | ||||
|                         "https://embydata.com/downloads/ffmpeg/osx/ffmpeg-x64-20170308.7z" | ||||
|                     }; | ||||
|             } | ||||
| 
 | ||||
| @ -1271,12 +1265,12 @@ namespace Emby.Server.Implementations | ||||
|                 case MediaBrowser.Model.System.Architecture.X64: | ||||
|                     return new[] | ||||
|                     { | ||||
|                                 "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win64.7z" | ||||
|                         "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win64.7z" | ||||
|                     }; | ||||
|                 case MediaBrowser.Model.System.Architecture.X86: | ||||
|                     return new[] | ||||
|                     { | ||||
|                                 "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win32.7z" | ||||
|                         "https://embydata.com/downloads/ffmpeg/windows/ffmpeg-20170308-win32.7z" | ||||
|                     }; | ||||
|             } | ||||
| 
 | ||||
| @ -1290,12 +1284,12 @@ namespace Emby.Server.Implementations | ||||
|                 case MediaBrowser.Model.System.Architecture.X64: | ||||
|                     return new[] | ||||
|                     { | ||||
|                                 "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-64bit-static.7z" | ||||
|                         "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-64bit-static.7z" | ||||
|                     }; | ||||
|                 case MediaBrowser.Model.System.Architecture.X86: | ||||
|                     return new[] | ||||
|                     { | ||||
|                                 "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-32bit-static.7z" | ||||
|                         "https://embydata.com/downloads/ffmpeg/linux/ffmpeg-git-20170301-32bit-static.7z" | ||||
|                     }; | ||||
|             } | ||||
| 
 | ||||
| @ -1442,17 +1436,17 @@ namespace Emby.Server.Implementations | ||||
|             StartServer(); | ||||
| 
 | ||||
|             LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), | ||||
|                                     GetExports<IVirtualFolderCreator>(), | ||||
|                                     GetExports<IItemResolver>(), | ||||
|                                     GetExports<IIntroProvider>(), | ||||
|                                     GetExports<IBaseItemComparer>(), | ||||
|                                     GetExports<ILibraryPostScanTask>()); | ||||
|                 GetExports<IVirtualFolderCreator>(), | ||||
|                 GetExports<IItemResolver>(), | ||||
|                 GetExports<IIntroProvider>(), | ||||
|                 GetExports<IBaseItemComparer>(), | ||||
|                 GetExports<ILibraryPostScanTask>()); | ||||
| 
 | ||||
|             ProviderManager.AddParts(GetExports<IImageProvider>(), | ||||
|                                      GetExports<IMetadataService>(), | ||||
|                                      GetExports<IMetadataProvider>(), | ||||
|                                      GetExports<IMetadataSaver>(), | ||||
|                                      GetExports<IExternalId>()); | ||||
|                 GetExports<IMetadataService>(), | ||||
|                 GetExports<IMetadataProvider>(), | ||||
|                 GetExports<IMetadataSaver>(), | ||||
|                 GetExports<IExternalId>()); | ||||
| 
 | ||||
|             ImageProcessor.AddParts(GetExports<IImageEnhancer>()); | ||||
| 
 | ||||
| @ -1652,7 +1646,7 @@ namespace Emby.Server.Implementations | ||||
| 
 | ||||
|                     try | ||||
|                     { | ||||
|                         _certificateGenerator(certPath, certHost, password); | ||||
|                         CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger); | ||||
|                     } | ||||
|                     catch (Exception ex) | ||||
|                     { | ||||
| @ -2158,7 +2152,7 @@ namespace Emby.Server.Implementations | ||||
|             list.Remove(plugin); | ||||
|             Plugins = list.ToArray(); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Checks for update. | ||||
|         /// </summary> | ||||
| @ -2176,7 +2170,7 @@ namespace Emby.Server.Implementations | ||||
|             } | ||||
| 
 | ||||
|             var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, updateLevel, _releaseAssetFilename, | ||||
|                     "MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false); | ||||
|                 "MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false); | ||||
| 
 | ||||
|             HasUpdateAvailable = result.IsUpdateAvailable; | ||||
| 
 | ||||
| @ -2314,12 +2308,18 @@ namespace Emby.Server.Implementations | ||||
|             NotifyPendingRestart(); | ||||
|         } | ||||
| 
 | ||||
|         private bool _disposed; | ||||
|         /// <summary> | ||||
|         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | ||||
|         /// </summary> | ||||
|         public void Dispose() | ||||
|         { | ||||
|             Dispose(true); | ||||
|             if (!_disposed) | ||||
|             { | ||||
|                 _disposed = true; | ||||
| 
 | ||||
|                 Dispose(true); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| using System; | ||||
| using System.Collections; | ||||
| using System.Security.Cryptography; | ||||
| using System.Xml; | ||||
| 
 | ||||
| namespace Emby.Server.Core.Cryptography | ||||
| { | ||||
| @ -27,7 +28,11 @@ namespace Emby.Server.Core.Cryptography | ||||
|             DateTime notAfter = DateTime.Now.AddYears(10); | ||||
| 
 | ||||
|             RSA issuerKey = RSA.Create(); | ||||
| #if NET46 | ||||
|             issuerKey.FromXmlString(MonoTestRootAgency); | ||||
| #else | ||||
|             RSACryptoServiceProviderExtensions.FromXmlString(issuerKey, MonoTestRootAgency); | ||||
| #endif | ||||
|             RSA subjectKey = RSA.Create(); | ||||
| 
 | ||||
|             // serial number MUST be positive | ||||
| @ -44,7 +49,7 @@ namespace Emby.Server.Core.Cryptography | ||||
|             cb.NotAfter = notAfter; | ||||
|             cb.SubjectName = subject; | ||||
|             cb.SubjectPublicKey = subjectKey; | ||||
|              | ||||
| 
 | ||||
|             // signature | ||||
|             cb.Hash = "SHA256"; | ||||
|             byte[] rawcert = cb.Sign(issuerKey); | ||||
| @ -66,4 +71,39 @@ namespace Emby.Server.Core.Cryptography | ||||
|             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 Architecture? CustomArchitecture { get; set; } | ||||
|         public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; } | ||||
|         private Architecture? _customArchitecture; | ||||
|         private MediaBrowser.Model.System.OperatingSystem? _customOperatingSystem; | ||||
| 
 | ||||
|         public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (CustomOperatingSystem.HasValue) | ||||
|                 if (_customOperatingSystem.HasValue) | ||||
|                 { | ||||
|                     return CustomOperatingSystem.Value; | ||||
|                     return _customOperatingSystem.Value; | ||||
|                 } | ||||
| 
 | ||||
|                 switch (Environment.OSVersion.Platform) | ||||
| @ -30,6 +30,10 @@ namespace Emby.Server.Implementations.EnvironmentInfo | ||||
| 
 | ||||
|                 return MediaBrowser.Model.System.OperatingSystem.Windows; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 _customOperatingSystem = value; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public string OperatingSystemName | ||||
| @ -60,13 +64,17 @@ namespace Emby.Server.Implementations.EnvironmentInfo | ||||
|         { | ||||
|             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; | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 _customArchitecture = value; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         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 | ||||
|             ServicePointManager.Expect100Continue = false; | ||||
| 
 | ||||
|             // Trakt requests sometimes fail without this | ||||
| #if NET46 | ||||
| // Trakt requests sometimes fail without this | ||||
|             ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; | ||||
| #endif | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
| @ -428,7 +430,7 @@ namespace Emby.Server.Implementations.HttpClientManager | ||||
|                 try | ||||
|                 { | ||||
|                     var bytes = options.RequestContentBytes ?? | ||||
|                         Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); | ||||
|                                 Encoding.UTF8.GetBytes(options.RequestContent ?? string.Empty); | ||||
| 
 | ||||
|                     httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded"; | ||||
| 
 | ||||
| @ -727,7 +729,7 @@ namespace Emby.Server.Implementations.HttpClientManager | ||||
|             } | ||||
| 
 | ||||
|             var webException = ex as WebException | ||||
|                 ?? ex.InnerException as WebException; | ||||
|                                ?? ex.InnerException as WebException; | ||||
| 
 | ||||
|             if (webException != null) | ||||
|             { | ||||
| @ -762,7 +764,7 @@ namespace Emby.Server.Implementations.HttpClientManager | ||||
|             } | ||||
| 
 | ||||
|             var operationCanceledException = ex as OperationCanceledException | ||||
|                 ?? ex.InnerException as OperationCanceledException; | ||||
|                                              ?? ex.InnerException as OperationCanceledException; | ||||
| 
 | ||||
|             if (operationCanceledException != null) | ||||
|             { | ||||
|  | ||||
| @ -71,9 +71,8 @@ namespace Emby.Server.Implementations.Library | ||||
|         private readonly IServerApplicationHost _appHost; | ||||
|         private readonly IFileSystem _fileSystem; | ||||
|         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; | ||||
|             UserRepository = userRepository; | ||||
| @ -86,7 +85,6 @@ namespace Emby.Server.Implementations.Library | ||||
|             _jsonSerializer = jsonSerializer; | ||||
|             _fileSystem = fileSystem; | ||||
|             _cryptographyProvider = cryptographyProvider; | ||||
|             _defaultUserName = defaultUserName; | ||||
|             ConfigurationManager = configurationManager; | ||||
|             Users = new List<User>(); | ||||
| 
 | ||||
| @ -381,7 +379,7 @@ namespace Emby.Server.Implementations.Library | ||||
|             // There always has to be at least one user. | ||||
|             if (users.Count == 0) | ||||
|             { | ||||
|                 var name = MakeValidUsername(_defaultUserName); | ||||
|                 var name = MakeValidUsername(Environment.UserName); | ||||
| 
 | ||||
|                 var user = InstantiateNewUser(name); | ||||
| 
 | ||||
|  | ||||
| @ -138,10 +138,10 @@ namespace Emby.Server.Implementations.Logging | ||||
| 
 | ||||
|                     foreach (var message in _queue.GetConsumingEnumerable()) | ||||
|                     { | ||||
|                         any = true; | ||||
| 
 | ||||
|                         var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine); | ||||
|                         _fileStream.Write(bytes, 0, bytes.Length); | ||||
| 
 | ||||
|                         any = true; | ||||
|                     } | ||||
| 
 | ||||
|                     if (any) | ||||
|  | ||||
| @ -69,8 +69,8 @@ namespace Emby.Server.Implementations.Net | ||||
|             if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort"); | ||||
| 
 | ||||
|             var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork | ||||
|                ? AddressFamily.InterNetwork | ||||
|                : AddressFamily.InterNetworkV6; | ||||
|                 ? AddressFamily.InterNetwork | ||||
|                 : AddressFamily.InterNetworkV6; | ||||
| 
 | ||||
|             var retVal = new Socket(addressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); | ||||
| 
 | ||||
| @ -82,7 +82,7 @@ namespace Emby.Server.Implementations.Net | ||||
|             { | ||||
|                 // This is not supported on all operating systems (qnap) | ||||
|             } | ||||
|              | ||||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 return new UdpSocket(retVal, new IpEndPointInfo(remoteAddress, remotePort)); | ||||
| @ -139,11 +139,11 @@ namespace Emby.Server.Implementations.Net | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         /// <summary> | ||||
|               /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. | ||||
|               /// </summary> | ||||
|               /// <returns>An implementation of the <see cref="ISocket"/> interface used by RSSDP components to perform acceptSocket operations.</returns> | ||||
|         /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. | ||||
|         /// </summary> | ||||
|         /// <returns>An implementation of the <see cref="ISocket"/> interface used by RSSDP components to perform acceptSocket operations.</returns> | ||||
|         public ISocket CreateSsdpUdpSocket(IpAddressInfo localIpAddress, int localPort) | ||||
|         { | ||||
|             if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); | ||||
| @ -186,7 +186,16 @@ namespace Emby.Server.Implementations.Net | ||||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 // not supported on all platforms. throws on ubuntu with .net core 2.0 | ||||
|                 retVal.ExclusiveAddressUse = false; | ||||
|             } | ||||
|             catch (SocketException) | ||||
|             { | ||||
| 
 | ||||
|             } | ||||
| 
 | ||||
|             try | ||||
|             { | ||||
|                 //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); | ||||
|                 retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); | ||||
|                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); | ||||
|  | ||||
| @ -13,8 +13,8 @@ namespace Emby.Server.Implementations | ||||
|         /// <summary> | ||||
|         /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class. | ||||
|         /// </summary> | ||||
|         public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, Action<string> createDirectoryFn) | ||||
|             : base(programDataPath, appFolderPath, createDirectoryFn) | ||||
|         public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath) | ||||
|             : base(programDataPath, appFolderPath) | ||||
|         { | ||||
|             ApplicationResourcesPath = applicationResourcesPath; | ||||
|         } | ||||
|  | ||||
| @ -67,7 +67,7 @@ namespace MediaBrowser.Model.Session | ||||
|         /// <value>The position ticks.</value> | ||||
|         public long? PositionTicks { get; set; } | ||||
| 
 | ||||
|         public long? playbackStartTimeTicks { get; set; } | ||||
|         public long? PlaybackStartTimeTicks { get; set; } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Gets or sets the volume level. | ||||
|  | ||||
| @ -19,7 +19,7 @@ namespace MediaBrowser.Server.Mono | ||||
| { | ||||
|     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.System; | ||||
| using Mono.Unix.Native; | ||||
| using NLog; | ||||
| using ILogger = MediaBrowser.Model.Logging.ILogger; | ||||
| using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate; | ||||
| 
 | ||||
| @ -48,7 +47,7 @@ namespace MediaBrowser.Server.Mono | ||||
| 
 | ||||
|             var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath); | ||||
| 
 | ||||
|             var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); | ||||
|             var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"); | ||||
|             logManager.ReloadLogger(LogSeverity.Info); | ||||
|             logManager.AddConsoleOutput(); | ||||
| 
 | ||||
| @ -84,9 +83,7 @@ namespace MediaBrowser.Server.Mono | ||||
| 
 | ||||
|             var appFolderPath = Path.GetDirectoryName(applicationPath); | ||||
| 
 | ||||
|             Action<string> createDirectoryFn = s => Directory.CreateDirectory(s); | ||||
| 
 | ||||
|             return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath), createDirectoryFn); | ||||
|             return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath)); | ||||
|         } | ||||
| 
 | ||||
|         private static readonly TaskCompletionSource<bool> ApplicationTaskCompletionSource = new TaskCompletionSource<bool>(); | ||||
| @ -113,10 +110,7 @@ namespace MediaBrowser.Server.Mono | ||||
|                 environmentInfo, | ||||
|                 imageEncoder, | ||||
|                 new SystemEvents(logManager.GetLogger("SystemEvents")), | ||||
|                 new MemoryStreamProvider(), | ||||
|                 new NetworkManager(logManager.GetLogger("NetworkManager")), | ||||
|                 GenerateCertificate, | ||||
|                 () => Environment.UserName); | ||||
|                 new NetworkManager(logManager.GetLogger("NetworkManager"))); | ||||
| 
 | ||||
|             if (options.ContainsOption("-v")) | ||||
|             { | ||||
| @ -141,11 +135,6 @@ namespace MediaBrowser.Server.Mono | ||||
|             Task.WaitAll(task); | ||||
|         } | ||||
| 
 | ||||
|         private static void GenerateCertificate(string certPath, string certHost, string certPassword) | ||||
|         { | ||||
|             CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger); | ||||
|         } | ||||
| 
 | ||||
|         private static MonoEnvironmentInfo GetEnvironmentInfo() | ||||
|         { | ||||
|             var info = new MonoEnvironmentInfo(); | ||||
| @ -156,39 +145,38 @@ namespace MediaBrowser.Server.Mono | ||||
| 
 | ||||
|             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)) | ||||
|             { | ||||
|                 //info.OperatingSystem = Startup.Common.OperatingSystem.Linux; | ||||
|                 info.OperatingSystem = Model.System.OperatingSystem.Linux; | ||||
|             } | ||||
|             else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase)) | ||||
|             { | ||||
|                 //info.OperatingSystem = Startup.Common.OperatingSystem.Bsd; | ||||
|                 info.IsBsd = true; | ||||
|                 info.OperatingSystem = Model.System.OperatingSystem.BSD; | ||||
|             } | ||||
| 
 | ||||
|             var archX86 = new Regex("(i|I)[3-6]86"); | ||||
| 
 | ||||
|             if (archX86.IsMatch(uname.machine)) | ||||
|             { | ||||
|                 info.CustomArchitecture = Architecture.X86; | ||||
|                 info.SystemArchitecture = Architecture.X86; | ||||
|             } | ||||
|             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)) | ||||
|             { | ||||
|                 info.CustomArchitecture = Architecture.Arm; | ||||
|                 info.SystemArchitecture = Architecture.Arm; | ||||
|             } | ||||
|             else if (System.Environment.Is64BitOperatingSystem) | ||||
|             { | ||||
|                 info.CustomArchitecture = Architecture.X64; | ||||
|                 info.SystemArchitecture = Architecture.X64; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 info.CustomArchitecture = Architecture.X86; | ||||
|                 info.SystemArchitecture = Architecture.X86; | ||||
|             } | ||||
| 
 | ||||
|             return info; | ||||
| @ -308,24 +296,9 @@ namespace MediaBrowser.Server.Mono | ||||
| 
 | ||||
|     public class MonoEnvironmentInfo : EnvironmentInfo | ||||
|     { | ||||
|         public bool IsBsd { get; set; } | ||||
| 
 | ||||
|         public override string GetUserId() | ||||
|         { | ||||
|             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 Emby.Drawing; | ||||
| using Emby.Drawing.ImageMagick; | ||||
| using Emby.Drawing.Skia; | ||||
| using Emby.Server.Core; | ||||
| using Emby.Server.Implementations; | ||||
|  | ||||
| @ -236,18 +236,16 @@ namespace MediaBrowser.ServerApplication | ||||
| 
 | ||||
|             var resourcesPath = Path.GetDirectoryName(applicationPath); | ||||
| 
 | ||||
|             Action<string> createDirectoryFn = s => Directory.CreateDirectory(s); | ||||
| 
 | ||||
|             if (runAsService) | ||||
|             { | ||||
|                 var systemPath = Path.GetDirectoryName(applicationPath); | ||||
| 
 | ||||
|                 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> | ||||
| @ -316,10 +314,7 @@ namespace MediaBrowser.ServerApplication | ||||
|                 environmentInfo, | ||||
|                 new NullImageEncoder(), | ||||
|                 new SystemEvents(logManager.GetLogger("SystemEvents")), | ||||
|                 new MemoryStreamProvider(), | ||||
|                 new Networking.NetworkManager(logManager.GetLogger("NetworkManager")), | ||||
|                 GenerateCertificate, | ||||
|                 () => Environment.UserDomainName); | ||||
|                 new Networking.NetworkManager(logManager.GetLogger("NetworkManager"))); | ||||
| 
 | ||||
|             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 TaskScheduler _mainTaskScheduler; | ||||
|         private static void ShowTrayIcon() | ||||
|  | ||||
| @ -201,10 +201,6 @@ | ||||
|       <Project>{805844ab-e92f-45e6-9d99-4f6d48d129a5}</Project> | ||||
|       <Name>Emby.Dlna</Name> | ||||
|     </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"> | ||||
|       <Project>{2312da6d-ff86-4597-9777-bceec32d96dd}</Project> | ||||
|       <Name>Emby.Drawing.Skia</Name> | ||||
|  | ||||
| @ -25,8 +25,8 @@ namespace MediaBrowser.ServerApplication | ||||
| { | ||||
|     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) | ||||
|             : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, 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, networkManager) | ||||
|         { | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user