diff options
| author | dkanada <dkanada@users.noreply.github.com> | 2021-03-04 17:03:53 +0900 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2021-03-06 14:26:41 -0500 |
| commit | 7545b1286b0c8db1d19cd6a9a191eb7223ee4dba (patch) | |
| tree | 90bcd1024d84d3597a20f773883d8edea59a03e0 | |
| parent | b99db64f8fb517d19d2249eb8ccb62589518a934 (diff) | |
Merge pull request #5345 from BaronGreenback/IP6Fix
Dual IP4 / IP6 server fails on non-windows platforms
(cherry picked from commit 8615847a8aba1f504b184e79907e6885215ffdaa)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
| -rw-r--r-- | Jellyfin.Networking/Manager/NetworkManager.cs | 21 | ||||
| -rw-r--r-- | Jellyfin.Server/Program.cs | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.cs index 51fcb6d9a..d2e9dcf9e 100644 --- a/Jellyfin.Networking/Manager/NetworkManager.cs +++ b/Jellyfin.Networking/Manager/NetworkManager.cs @@ -285,14 +285,25 @@ namespace Jellyfin.Networking.Manager // No bind address and no exclusions, so listen on all interfaces. Collection<IPObject> result = new Collection<IPObject>(); - if (IsIP4Enabled) + if (IsIP6Enabled && IsIP4Enabled) + { + // Kestrel source code shows it uses Sockets.DualMode - so this also covers IPAddress.Any + result.AddItem(IPAddress.IPv6Any); + } + else if (IsIP4Enabled) { result.AddItem(IPAddress.Any); } - - if (IsIP6Enabled) + else if (IsIP6Enabled) { - result.AddItem(IPAddress.IPv6Any); + // Cannot use IPv6Any as Kestrel will bind to IPv4 addresses. + foreach (var iface in _interfaceAddresses) + { + if (iface.AddressFamily == AddressFamily.InterNetworkV6) + { + result.AddItem(iface.Address); + } + } } return result; @@ -414,7 +425,7 @@ namespace Jellyfin.Networking.Manager } // There isn't any others, so we'll use the loopback. - result = IsIP6Enabled ? "::" : "127.0.0.1"; + result = IsIP6Enabled ? "::1" : "127.0.0.1"; _logger.LogWarning("{Source}: GetBindInterface: Loopback {Result} returned.", source, result); return result; } diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e19028f9f..6823a4301 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -280,7 +280,7 @@ namespace Jellyfin.Server bool flagged = false; foreach (IPObject netAdd in addresses) { - _logger.LogInformation("Kestrel listening on {0}", netAdd); + _logger.LogInformation("Kestrel listening on {Address}", netAdd.Address == IPAddress.IPv6Any ? "All Addresses" : netAdd); options.Listen(netAdd.Address, appHost.HttpPort); if (appHost.ListenWithHttps) { |
