Selaa lähdekoodia

improve network address detection

Luke Pulverenti 8 vuotta sitten
vanhempi
sitoutus
6fe933fde4

+ 21 - 2
Emby.Common.Implementations/Networking/NetworkManager.cs

@@ -198,6 +198,12 @@ namespace Emby.Common.Implementations.Networking
             return Dns.GetHostAddressesAsync(hostName);
         }
 
+        private readonly List<NetworkInterfaceType> _validNetworkInterfaceTypes = new List<NetworkInterfaceType>
+        {
+            NetworkInterfaceType.Ethernet,
+            NetworkInterfaceType.Wireless80211
+        };
+
         private List<IPAddress> GetIPsDefault()
         {
             NetworkInterface[] interfaces;
@@ -223,9 +229,22 @@ namespace Emby.Common.Implementations.Networking
                 {
                     Logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus);
 
-                    var properties = network.GetIPProperties();
+                    var ipProperties = network.GetIPProperties();
+
+                    // Try to exclude virtual adapters
+                    // http://stackoverflow.com/questions/8089685/c-sharp-finding-my-machines-local-ip-address-and-not-the-vms
+                    var addr = ipProperties.GatewayAddresses.FirstOrDefault();
+                    if (addr == null|| string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase))
+                    {
+                        return new List<IPAddress>();
+                    }
+
+                    //if (!_validNetworkInterfaceTypes.Contains(network.NetworkInterfaceType))
+                    //{
+                    //    return new List<IPAddress>();
+                    //}
 
-                    return properties.UnicastAddresses
+                    return ipProperties.UnicastAddresses
                         .Where(i => i.IsDnsEligible)
                         .Select(i => i.Address)
                         .Where(i => i.AddressFamily == AddressFamily.InterNetwork)

+ 5 - 0
src/Emby.Server/Emby.Server.xproj

@@ -37,5 +37,10 @@
     <ProjectReference Include="..\..\ServiceStack\ServiceStack.csproj" />
     <ProjectReference Include="..\..\SocketHttpListener.Portable\SocketHttpListener.Portable.csproj" />
   </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\..\SharedVersion.cs">
+      <Link>Properties\SharedVersion.cs</Link>
+    </Compile>
+  </ItemGroup>
   <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
 </Project>

+ 21 - 3
src/Emby.Server/project.json

@@ -1,5 +1,5 @@
 {
-  "version": "1.0.0-*",
+  "version": "3.1.0-*",
   "buildOptions": {
     "emitEntryPoint": true
   },
@@ -33,8 +33,26 @@
     "win10-arm64": {},
     "osx.10.10-x64": {},
     "osx.10.11-x64": {},
-    "osx.10.12-x64": {},
-    "ubuntu.14.04-x64": {}
+    "osx.10.12-x64": ,
+    "rhel.7.0-x64": {},
+    "rhel.7.1-x64": {},
+    "rhel.7.2-x64": {},
+    "ubuntu.14.04-x64": {},
+    "ubuntu.14.10-x64": {},
+    "ubuntu.15.04-x64": {},
+    "ubuntu.15.10-x64": {},
+    "ubuntu.16.04-x64": {},
+    "ubuntu.16.10-x64": {},
+    "centos.7-x64": {},
+    "debian.8-x64": {},
+    "fedora.23-x64": {},
+    "fedora.24-x64": {},
+    "opensuse.13.2-x64": {},
+    "opensuse.42.1-x64": {},
+    "ol.7-x64": {},
+    "ol.7.0-x64": {},
+    "ol.7.1-x64": {},
+    "ol.7.2-x64": {}
   },
 
   "frameworks": {