[PR #3992] [CLOSED] WIP: Networking backend change. (Testing) #9809

Closed
opened 2026-02-07 06:08:54 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/3992
Author: @BaronGreenback
Created: 8/26/2020
Status: Closed

Base: masterHead: Networking2


📝 Commits (10+)

📊 Changes

135 files changed (+15582 additions, -1785 deletions)

View changed files

📝 Emby.Dlna/Configuration/DlnaOptions.cs (+36 -8)
📝 Emby.Dlna/ConnectionManager/ConnectionManagerService.cs (+1 -1)
📝 Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs (+79 -78)
📝 Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs (+5 -5)
📝 Emby.Dlna/ContentDirectory/ContentDirectoryService.cs (+2 -2)
📝 Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs (+114 -113)
📝 Emby.Dlna/ContentDirectory/ControlHandler.cs (+86 -86)
📝 Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs (+5 -5)
📝 Emby.Dlna/Didl/DidlBuilder.cs (+6 -6)
📝 Emby.Dlna/DlnaManager.cs (+3 -1)
📝 Emby.Dlna/Emby.Dlna.csproj (+3 -3)
📝 Emby.Dlna/Main/DlnaEntryPoint.cs (+349 -281)
📝 Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarService.cs (+1 -1)
📝 Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs (+53 -54)
📝 Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs (+5 -5)
Emby.Dlna/Net/EventArgs/RequestReceivedEventArgs.cs (+65 -0)
Emby.Dlna/Net/EventArgs/ResponseReceivedEventArgs.cs (+51 -0)
Emby.Dlna/Net/Parsers/HttpParserBase.cs (+249 -0)
Emby.Dlna/Net/Parsers/HttpRequestParser.cs (+84 -0)
Emby.Dlna/Net/Parsers/HttpResponseParser.cs (+73 -0)

...and 80 more files

📄 Description

Redesigned NetworkManager class.

  • Implemented the ability to exclude IP addresses by enclosing them in [ ]. These exclusions are built into all network options.

  • Can be used to exclude virtual interfaces. IP addresses can be FQDN. Interfaces can be specified by either using :- eth or the interface description("TP-LINK Wireless USB Adapter”)

  • Fully documented and Logger output.

  • Event driven, so lists auto update after network changes, or user intervention.

  • LAN addresses auto populated with private connected subnets if left blank.

  • New system parameter "TrustIP6Interfaces" determines if IP6 interface are treated as internal or external (see https://github.com/jellyfin/jellyfin/pull/3515.)

  • Caching implemented on network objects, and interfaces.

  • New classes (IPHost, IPNetAddress, and NetCollection) take care of anything IP based (Parsing, comparing, IP & Subnets, subnets comparisons, etc) and are fully LINQ compatible.

  • IPv6 compatible code providing IPv6 functionality.

  • Implements DNS lookup (auto-refreshed cache) meaning code can be simplified elsewhere.

  • Test unit provided.

  • Added a new configuration option EnableIPv6

    • Enables/disables IPv6 across the board SSDP/UDP/Web. (default is disabled).
  • Implemented and extended my previous change.

    • SSDP is only sent out and responded to on internal interfaces (and can be excluded).
    • IP addresses, FQDN, hostnames and interfaces can now be specified for inclusion/exclusion.
  • PublishedServerUrl implemented which overrides binding options for services.

  • Added a custom PublishedServerUrl per subnet, allowing users to specify what the response should be by source.

  • Adding interface binding options (with intelligent interface selection if nothing is specified) for services.

  • Add port range restriction capability for HDHomerun.

  • Improved socket handling when interface becomes unavailable. (SocketFactory)

    • In certain situations, if an interface went offline, the invalid socket was continued to be used causing errors. Now, if any sockets raise an exception, the code now checks to see if their IP address is still bound to an interface, and if not, they are disposed.
  • Improved network change handing (DlnaEntryPoint.cs).

    • If new interfaces came online after start-up – they were never used. Now linked into the network onchange event, which causes a re-initialisation similar to a configuration change event.
  • Removed unused async and task function definitions as advised by the compiler.

  • Traffic is no longer sent out of excluded interfaces (Platform dependant.)

  • Received traffic from excluded IP addresses/networks is ignored.

    • Errant devices (sky boxes etc) can be explicitly ignored, meaning no more spamming of the logs. This also stops untrusted interfaces/ networks from probing DLNA information.
  • Implemented IPv6 SSDP & UDP capability. (except Homerun as i thought this change was already too big)

  • New Mono.NAT uPNP implementation and gateway monitoring.

    • If the gateway goes down, the ports are automatically re-mapped when it comes back up.
    • Jellyfin now works side by side with Mono.NAT and implements shared SSDP processing when it's enabled.
    • uPnP no longer creats port forward rules on the router for the http port unless UPnPCreateHttpPortMap is set to true.
  • SSDP and Mono.NAT now co-exist peacefully and work with each other.

  • Added UDP port range capability for HRHomerun.

Config Settings:

(Value in brackets is the default setting.)

LocalNetworkSubnets (empty) : Defines local subnets, and is used by the DLNA subsystem.
If blank, all the subnets of any private interfaces will be assumed to be the LAN.
Interface names, descriptions and subnets can be specified, as well as exclusions (addresses enclosed with [], or beginning with !)
usage:
10.0.0.0/8,!192.168.1.1 means 10.0.0.0/8 is in the LAN, but ignore traffic to/from 192.168.1.1
!eth1 means every interface but exclude the interface eth1.

LocalNetworkAddresses (empty) : lists the interfaces that jellyfin binds to. Default is all interfaces.
Interface names, descriptions and subnets can be specified, as well as exclusions (addresses starting with !)
usage:
10.10.10.10 means listen only on 10.10.10.10
!eth1 means listen on every interface except eth1.

Advanced settings: (direct xml edit required)

HDHomerunPortRange (Random Port) : Specify a UDP port, or range of UDP ports that HDHomerun uses.

GatewayMonitorPeriod (60 seconds) : How often the gateway is pinged to ensure it's operational.

EnableIPV6 (False) : Disable/enable IPv6 usage. (Not implemented on HDHomerun)

TrustAllIP6Interfaces (false) ; All IPv6 interfaces are deemed to be local. (See conversation at #3515.)

EnableMultiSocketBinding (true) : System will use specific ip bound sockets. Autocalculated, but can be overridden.

PublishedServerUriBySubnet (empty) : list of [subnets|interfaces]/[serverUri|host|ip] [port] values that replicate the --published-server-url command line argument, but on a per subnet basis, enabling.
usage:

UPnPCreateHttpPortMap (false): Maps the HTTP port in addition to the HTTPS port on any network devices detected via uPNP (if active). Historically, uPnP has mapped both the HTTP and HTTP ports inbound. This is now no longer the case.

The following mimics the --published-server-url option but only for external requests.

<PublishedServerUriBySubnet>
<string>0.0.0.0=http://myjellyfin.org</string>
</PublishedServerUriBySubnet>

The following causes any requests from the subnet defined by eth1 to respond with a hostname jellyfin.com

<PublishedServerUriBySubnet>
<string>eth1=jellyfin.com </string>
</PublishedServerUriBySubnet>

The following causes any requests from the subnet defined by eth1 to respond with a hostname jellyfin.com, and everything else to return the address http://jellyexternal.com

<PublishedServerUriBySubnet>
<string>eth1=jellyfin.com</string>
<string>255.255.255.255=http://jellyexternal.com</string>
</PublishedServerUriBySubnet>

The following changes the url address dependant upon source request.

<PublishedServerUriBySubnet>
<string>192.168.1.0/24=net1access:1270</string>
<string>192.168.2.1/24=net2access</string>
<string>0.0.0.0=jellyfinoutside</string>
</PublishedServerUriBySubnet> 

Logging

To enable debug logging, edit logging.default.json, and add

    "Serilog": {
        "MinimumLevel": {
            "Override": {
	       "Emby.Server.Implementations.Networking" : "Debug",
               "Mono.Nat.Upnp.UpnpSearcher ": "Debug"

Retired settings

BlastAliveMessages - see comment below.

IgnoreVirtualInterfaces - no longer valid (pre 10.6). Exclude virtual interface by including them in LocalNetworkSubnets settings (and LocalNetworkAddresses if no interface defined ) enclosed in [ ]. eg. [eth1] will exclude interface 1, from being used.

SendOnlyMatchedHost (false)- No longer valid. It causes SSDP replies to be sent to all subnets, not just the local ones.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/3992 **Author:** [@BaronGreenback](https://github.com/BaronGreenback) **Created:** 8/26/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `Networking2` --- ### 📝 Commits (10+) - [`2b88729`](https://github.com/jellyfin/jellyfin/commit/2b887299aa88bac7d020f21c36c1bfba2fe87405) Merge pull request #52 from jellyfin/master - [`80a5c4d`](https://github.com/jellyfin/jellyfin/commit/80a5c4deb097975330c2694c2c342967dfd2ab0f) Make MediaBrowser.MediaEncoding warnings free - [`d5deb6d`](https://github.com/jellyfin/jellyfin/commit/d5deb6d11103470c2703291ea5eeacf1cd930685) Fix build - [`804fe98`](https://github.com/jellyfin/jellyfin/commit/804fe98ba126cae30ae728a66e185d0f7c46d6b3) Reduce warnings in Emby.Dlna - [`30e5d95`](https://github.com/jellyfin/jellyfin/commit/30e5d959ee87509a604c683be0ce17e4585a0b1a) Code review - [`4ca5121`](https://github.com/jellyfin/jellyfin/commit/4ca51216ef5a575b7efe20fea018ae214c8e1fd8) Fix all warnings in Emby.Dlna - [`8c68f40`](https://github.com/jellyfin/jellyfin/commit/8c68f4074e8b0cfd6c38f8672e22d5dbb7b3b408) Simplify FFmpeg detection code - [`4dbc283`](https://github.com/jellyfin/jellyfin/commit/4dbc28318b74089142202f3a5158214c7ed64cbd) Add unsupported ffmpeg version to tests - [`b240007`](https://github.com/jellyfin/jellyfin/commit/b240007c286a256a5dcd68b02859de357717b6d7) bump DotNet.Glob - [`66edca7`](https://github.com/jellyfin/jellyfin/commit/66edca76b60a6a35c61410ec4d6dd84435c05af6) Fix dlna play to ### 📊 Changes **135 files changed** (+15582 additions, -1785 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Dlna/Configuration/DlnaOptions.cs` (+36 -8) 📝 `Emby.Dlna/ConnectionManager/ConnectionManagerService.cs` (+1 -1) 📝 `Emby.Dlna/ConnectionManager/ConnectionManagerXmlBuilder.cs` (+79 -78) 📝 `Emby.Dlna/ConnectionManager/ServiceActionListBuilder.cs` (+5 -5) 📝 `Emby.Dlna/ContentDirectory/ContentDirectoryService.cs` (+2 -2) 📝 `Emby.Dlna/ContentDirectory/ContentDirectoryXmlBuilder.cs` (+114 -113) 📝 `Emby.Dlna/ContentDirectory/ControlHandler.cs` (+86 -86) 📝 `Emby.Dlna/ContentDirectory/ServiceActionListBuilder.cs` (+5 -5) 📝 `Emby.Dlna/Didl/DidlBuilder.cs` (+6 -6) 📝 `Emby.Dlna/DlnaManager.cs` (+3 -1) 📝 `Emby.Dlna/Emby.Dlna.csproj` (+3 -3) 📝 `Emby.Dlna/Main/DlnaEntryPoint.cs` (+349 -281) 📝 `Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarService.cs` (+1 -1) 📝 `Emby.Dlna/MediaReceiverRegistrar/MediaReceiverRegistrarXmlBuilder.cs` (+53 -54) 📝 `Emby.Dlna/MediaReceiverRegistrar/ServiceActionListBuilder.cs` (+5 -5) ➕ `Emby.Dlna/Net/EventArgs/RequestReceivedEventArgs.cs` (+65 -0) ➕ `Emby.Dlna/Net/EventArgs/ResponseReceivedEventArgs.cs` (+51 -0) ➕ `Emby.Dlna/Net/Parsers/HttpParserBase.cs` (+249 -0) ➕ `Emby.Dlna/Net/Parsers/HttpRequestParser.cs` (+84 -0) ➕ `Emby.Dlna/Net/Parsers/HttpResponseParser.cs` (+73 -0) _...and 80 more files_ </details> ### 📄 Description ### Redesigned NetworkManager class. - Implemented the ability to exclude IP addresses by enclosing them in [ ]. These exclusions are built into all network options. - Can be used to exclude virtual interfaces. IP addresses can be FQDN. Interfaces can be specified by either using :- eth<index> or the interface description("TP-LINK Wireless USB Adapter”) - Fully documented and Logger output. - Event driven, so lists auto update after network changes, or user intervention. - LAN addresses auto populated with private connected subnets if left blank. - New system parameter "TrustIP6Interfaces" determines if IP6 interface are treated as internal or external (see https://github.com/jellyfin/jellyfin/pull/3515.) - Caching implemented on network objects, and interfaces. - New classes (IPHost, IPNetAddress, and NetCollection) take care of anything IP based (Parsing, comparing, IP & Subnets, subnets comparisons, etc) and are fully LINQ compatible. - IPv6 compatible code providing IPv6 functionality. - Implements DNS lookup (auto-refreshed cache) meaning code can be simplified elsewhere. - Test unit provided. - Added a new configuration option EnableIPv6 - Enables/disables IPv6 across the board SSDP/UDP/Web. (default is disabled). - Implemented and extended my previous change. - SSDP is only sent out and responded to on internal interfaces (and can be excluded). - IP addresses, FQDN, hostnames and interfaces can now be specified for inclusion/exclusion. - PublishedServerUrl implemented which overrides binding options for services. - Added a custom PublishedServerUrl per subnet, allowing users to specify what the response should be by source. - Adding interface binding options (with intelligent interface selection if nothing is specified) for services. - Add port range restriction capability for HDHomerun. - Improved socket handling when interface becomes unavailable. (SocketFactory) - In certain situations, if an interface went offline, the invalid socket was continued to be used causing errors. Now, if any sockets raise an exception, the code now checks to see if their IP address is still bound to an interface, and if not, they are disposed. - Improved network change handing (DlnaEntryPoint.cs). - If new interfaces came online after start-up – they were never used. Now linked into the network onchange event, which causes a re-initialisation similar to a configuration change event. - Removed unused async and task function definitions as advised by the compiler. - Traffic is no longer sent out of excluded interfaces (Platform dependant.) - Received traffic from excluded IP addresses/networks is ignored. - Errant devices (sky boxes etc) can be explicitly ignored, meaning no more spamming of the logs. This also stops untrusted interfaces/ networks from probing DLNA information. - Implemented IPv6 SSDP & UDP capability. (except Homerun as i thought this change was already too big) - New Mono.NAT uPNP implementation and gateway monitoring. - If the gateway goes down, the ports are automatically re-mapped when it comes back up. - Jellyfin now works side by side with Mono.NAT and implements shared SSDP processing when it's enabled. - uPnP no longer creats port forward rules on the router for the http port unless UPnPCreateHttpPortMap is set to true. - SSDP and Mono.NAT now co-exist peacefully and work with each other. - Added UDP port range capability for HRHomerun. Config Settings: ===== (Value in brackets is the default setting.) **LocalNetworkSubnets** (empty) : Defines local subnets, and is used by the DLNA subsystem. If blank, all the subnets of any private interfaces will be assumed to be the LAN. Interface names, descriptions and subnets can be specified, as well as exclusions (addresses enclosed with [], or beginning with !) usage: 10.0.0.0/8,!192.168.1.1 means 10.0.0.0/8 is in the LAN, but ignore traffic to/from 192.168.1.1 !eth1 means every interface but exclude the interface eth1. **LocalNetworkAddresses** (empty) : lists the interfaces that jellyfin binds to. Default is all interfaces. Interface names, descriptions and subnets can be specified, as well as exclusions (addresses starting with !) usage: 10.10.10.10 means listen only on 10.10.10.10 !eth1 means listen on every interface except eth1. Advanced settings: (direct xml edit required) ==== **HDHomerunPortRange** (Random Port) : Specify a UDP port, or range of UDP ports that HDHomerun uses. **GatewayMonitorPeriod** (60 seconds) : How often the gateway is pinged to ensure it's operational. **EnableIPV6** (False) : Disable/enable IPv6 usage. (Not implemented on HDHomerun) **TrustAllIP6Interfaces** (false) ; All IPv6 interfaces are deemed to be local. (See conversation at #3515.) **EnableMultiSocketBinding** (true) : System will use specific ip bound sockets. Autocalculated, but can be overridden. **PublishedServerUriBySubnet** (empty) : list of [subnets|interfaces]/[serverUri|host|ip] [port] values that replicate the --published-server-url command line argument, but on a per subnet basis, enabling. usage: **UPnPCreateHttpPortMap** (false): Maps the HTTP port in addition to the HTTPS port on any network devices detected via uPNP (if active). Historically, uPnP has mapped both the HTTP and HTTP ports inbound. This is now no longer the case. The following mimics the --published-server-url option but only for external requests. ``` <PublishedServerUriBySubnet> <string>0.0.0.0=http://myjellyfin.org</string> </PublishedServerUriBySubnet> ``` The following causes any requests from the subnet defined by eth1 to respond with a hostname jellyfin.com ``` <PublishedServerUriBySubnet> <string>eth1=jellyfin.com </string> </PublishedServerUriBySubnet> ``` The following causes any requests from the subnet defined by eth1 to respond with a hostname jellyfin.com, and everything else to return the address http://jellyexternal.com ``` <PublishedServerUriBySubnet> <string>eth1=jellyfin.com</string> <string>255.255.255.255=http://jellyexternal.com</string> </PublishedServerUriBySubnet> ``` The following changes the url address dependant upon source request. ``` <PublishedServerUriBySubnet> <string>192.168.1.0/24=net1access:1270</string> <string>192.168.2.1/24=net2access</string> <string>0.0.0.0=jellyfinoutside</string> </PublishedServerUriBySubnet> ``` Logging ==== To enable debug logging, edit logging.default.json, and add ``` "Serilog": { "MinimumLevel": { "Override": { "Emby.Server.Implementations.Networking" : "Debug", "Mono.Nat.Upnp.UpnpSearcher ": "Debug" ``` Retired settings ===== **BlastAliveMessages** - see comment below. **IgnoreVirtualInterfaces** - no longer valid (pre 10.6). Exclude virtual interface by including them in LocalNetworkSubnets settings (and LocalNetworkAddresses if no interface defined ) enclosed in [ ]. eg. [eth1] will exclude interface 1, from being used. **SendOnlyMatchedHost** (false)- No longer valid. It causes SSDP replies to be sent to all subnets, not just the local ones. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:08:54 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#9809