diff options
| author | Claus Vium <clausvium@gmail.com> | 2019-03-07 20:16:51 +0100 |
|---|---|---|
| committer | Claus Vium <clausvium@gmail.com> | 2019-03-07 20:16:51 +0100 |
| commit | 0abe57e930e44eab9566991f33b089d1e61cfb83 (patch) | |
| tree | 602be322daedca127ba66de07837ac8e792730a7 /MediaBrowser.Model | |
| parent | dfff68b2f4ca8d3da59508eb4cbe2e751ed76f49 (diff) | |
| parent | ae0ecc1b10982d9240ecdcc82cb7299fc708aafb (diff) | |
Merge remote-tracking branch 'remotes/upstream/master' into kestrel_poc
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Configuration/EncodingOptions.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/Configuration/ServerConfiguration.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Cryptography/ICryptoProvider.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.Model/Cryptography/PasswordHash.cs | 153 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/IpAddressInfo.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Model/System/SystemInfo.cs | 17 | ||||
| -rw-r--r-- | MediaBrowser.Model/Users/UserPolicy.cs | 2 |
7 files changed, 189 insertions, 2 deletions
diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs index 8584bd3dd..285ff4ba5 100644 --- a/MediaBrowser.Model/Configuration/EncodingOptions.cs +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -8,7 +8,14 @@ namespace MediaBrowser.Model.Configuration public bool EnableThrottling { get; set; } public int ThrottleDelaySeconds { get; set; } public string HardwareAccelerationType { get; set; } + /// <summary> + /// FFmpeg path as set by the user via the UI + /// </summary> public string EncoderAppPath { get; set; } + /// <summary> + /// The current FFmpeg path being used by the system and displayed on the transcode page + /// </summary> + public string EncoderAppPathDisplay { get; set; } public string VaapiDevice { get; set; } public int H264Crf { get; set; } public string H264Preset { get; set; } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index ed5800329..0ba36b4b9 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -178,6 +178,7 @@ namespace MediaBrowser.Model.Configuration public string[] LocalNetworkSubnets { get; set; } public string[] LocalNetworkAddresses { get; set; } public string[] CodecsUsed { get; set; } + public bool IgnoreVirtualInterfaces { get; set; } public bool EnableExternalContentInSuggestions { get; set; } public bool RequireHttps { get; set; } public bool IsBehindProxy { get; set; } @@ -205,6 +206,7 @@ namespace MediaBrowser.Model.Configuration CodecsUsed = Array.Empty<string>(); ImageExtractionTimeoutMs = 0; PathSubstitutions = Array.Empty<PathSubstitution>(); + IgnoreVirtualInterfaces = false; EnableSimpleArtistDetection = true; DisplaySpecialsWithinSeasons = true; diff --git a/MediaBrowser.Model/Cryptography/ICryptoProvider.cs b/MediaBrowser.Model/Cryptography/ICryptoProvider.cs index b027d2ad0..5988112c2 100644 --- a/MediaBrowser.Model/Cryptography/ICryptoProvider.cs +++ b/MediaBrowser.Model/Cryptography/ICryptoProvider.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Collections.Generic; namespace MediaBrowser.Model.Cryptography { @@ -9,5 +10,13 @@ namespace MediaBrowser.Model.Cryptography byte[] ComputeMD5(Stream str); byte[] ComputeMD5(byte[] bytes); byte[] ComputeSHA1(byte[] bytes); + IEnumerable<string> GetSupportedHashMethods(); + byte[] ComputeHash(string HashMethod, byte[] bytes); + byte[] ComputeHashWithDefaultMethod(byte[] bytes); + byte[] ComputeHash(string HashMethod, byte[] bytes, byte[] salt); + byte[] ComputeHashWithDefaultMethod(byte[] bytes, byte[] salt); + byte[] ComputeHash(PasswordHash hash); + byte[] GenerateSalt(); + string DefaultHashMethod { get; } } } diff --git a/MediaBrowser.Model/Cryptography/PasswordHash.cs b/MediaBrowser.Model/Cryptography/PasswordHash.cs new file mode 100644 index 000000000..a9d0f6744 --- /dev/null +++ b/MediaBrowser.Model/Cryptography/PasswordHash.cs @@ -0,0 +1,153 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MediaBrowser.Model.Cryptography
+{
+ public class PasswordHash
+ {
+ // Defined from this hash storage spec
+ // https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md
+ // $<id>[$<param>=<value>(,<param>=<value>)*][$<salt>[$<hash>]]
+ // with one slight amendment to ease the transition, we're writing out the bytes in hex
+ // rather than making them a BASE64 string with stripped padding
+
+ private string _id;
+
+ private Dictionary<string, string> _parameters = new Dictionary<string, string>();
+
+ private string _salt;
+
+ private byte[] _saltBytes;
+
+ private string _hash;
+
+ private byte[] _hashBytes;
+
+ public string Id { get => _id; set => _id = value; }
+
+ public Dictionary<string, string> Parameters { get => _parameters; set => _parameters = value; }
+
+ public string Salt { get => _salt; set => _salt = value; }
+
+ public byte[] SaltBytes { get => _saltBytes; set => _saltBytes = value; }
+
+ public string Hash { get => _hash; set => _hash = value; }
+
+ public byte[] HashBytes { get => _hashBytes; set => _hashBytes = value; }
+
+ public PasswordHash(string storageString)
+ {
+ string[] splitted = storageString.Split('$');
+ _id = splitted[1];
+ if (splitted[2].Contains("="))
+ {
+ foreach (string paramset in (splitted[2].Split(',')))
+ {
+ if (!string.IsNullOrEmpty(paramset))
+ {
+ string[] fields = paramset.Split('=');
+ if (fields.Length == 2)
+ {
+ _parameters.Add(fields[0], fields[1]);
+ }
+ else
+ {
+ throw new Exception($"Malformed parameter in password hash string {paramset}");
+ }
+ }
+ }
+ if (splitted.Length == 5)
+ {
+ _salt = splitted[3];
+ _saltBytes = ConvertFromByteString(_salt);
+ _hash = splitted[4];
+ _hashBytes = ConvertFromByteString(_hash);
+ }
+ else
+ {
+ _salt = string.Empty;
+ _hash = splitted[3];
+ _hashBytes = ConvertFromByteString(_hash);
+ }
+ }
+ else
+ {
+ if (splitted.Length == 4)
+ {
+ _salt = splitted[2];
+ _saltBytes = ConvertFromByteString(_salt);
+ _hash = splitted[3];
+ _hashBytes = ConvertFromByteString(_hash);
+ }
+ else
+ {
+ _salt = string.Empty;
+ _hash = splitted[2];
+ _hashBytes = ConvertFromByteString(_hash);
+ }
+
+ }
+
+ }
+
+ public PasswordHash(ICryptoProvider cryptoProvider)
+ {
+ _id = cryptoProvider.DefaultHashMethod;
+ _saltBytes = cryptoProvider.GenerateSalt();
+ _salt = ConvertToByteString(SaltBytes);
+ }
+
+ public static byte[] ConvertFromByteString(string byteString)
+ {
+ byte[] bytes = new byte[byteString.Length / 2];
+ for (int i = 0; i < byteString.Length; i += 2)
+ {
+ // TODO: NetStandard2.1 switch this to use a span instead of a substring.
+ bytes[i / 2] = Convert.ToByte(byteString.Substring(i, 2), 16);
+ }
+
+ return bytes;
+ }
+
+ public static string ConvertToByteString(byte[] bytes)
+ {
+ return BitConverter.ToString(bytes).Replace("-", "");
+ }
+
+ private string SerializeParameters()
+ {
+ string returnString = string.Empty;
+ foreach (var KVP in _parameters)
+ {
+ returnString += $",{KVP.Key}={KVP.Value}";
+ }
+
+ if ((!string.IsNullOrEmpty(returnString)) && returnString[0] == ',')
+ {
+ returnString = returnString.Remove(0, 1);
+ }
+
+ return returnString;
+ }
+
+ public override string ToString()
+ {
+ string outString = "$" + _id;
+ string paramstring = SerializeParameters();
+ if (!string.IsNullOrEmpty(paramstring))
+ {
+ outString += $"${paramstring}";
+ }
+
+ if (!string.IsNullOrEmpty(_salt))
+ {
+ outString += $"${_salt}";
+ }
+
+ outString += $"${_hash}";
+ return outString;
+ }
+ }
+
+}
diff --git a/MediaBrowser.Model/Net/IpAddressInfo.cs b/MediaBrowser.Model/Net/IpAddressInfo.cs index 7a278d4d4..87fa55bca 100644 --- a/MediaBrowser.Model/Net/IpAddressInfo.cs +++ b/MediaBrowser.Model/Net/IpAddressInfo.cs @@ -10,6 +10,7 @@ namespace MediaBrowser.Model.Net public static IpAddressInfo IPv6Loopback = new IpAddressInfo("::1", IpAddressFamily.InterNetworkV6); public string Address { get; set; } + public IpAddressInfo SubnetMask { get; set; } public IpAddressFamily AddressFamily { get; set; } public IpAddressInfo(string address, IpAddressFamily addressFamily) diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 581a1069c..6482f2c84 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -5,6 +5,21 @@ using MediaBrowser.Model.Updates; namespace MediaBrowser.Model.System { /// <summary> + /// Enum describing the location of the FFmpeg tool. + /// </summary> + public enum FFmpegLocation + { + /// <summary>No path to FFmpeg found.</summary> + NotFound, + /// <summary>Path supplied via command line using switch --ffmpeg.</summary> + SetByArgument, + /// <summary>User has supplied path via Transcoding UI page.</summary> + Custom, + /// <summary>FFmpeg tool found on system $PATH.</summary> + System + }; + + /// <summary> /// Class SystemInfo /// </summary> public class SystemInfo : PublicSystemInfo @@ -122,7 +137,7 @@ namespace MediaBrowser.Model.System /// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value> public bool HasUpdateAvailable { get; set; } - public string EncoderLocationType { get; set; } + public FFmpegLocation EncoderLocation { get; set; } public Architecture SystemArchitecture { get; set; } diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index 23805b79f..27ce23778 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -77,7 +77,7 @@ namespace MediaBrowser.Model.Users public UserPolicy() { - EnableContentDeletion = true; + EnableContentDeletion = false; EnableContentDeletionFromFolders = Array.Empty<string>(); EnableSyncTranscoding = true; |
