Feature: Implement local-network priority for Jellyfin server connections#502
Open
eamondo2 wants to merge 1 commit intojellyfin:masterfrom
Open
Feature: Implement local-network priority for Jellyfin server connections#502eamondo2 wants to merge 1 commit intojellyfin:masterfrom
eamondo2 wants to merge 1 commit intojellyfin:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've got a mini-PC I bring with me when traveling, and I'd rather not have to switch the server configuration around between at-home or otherwise.
While the shim allows you to add multiple server connections, if you add the same Jellyfin server twice (from differing addresses, one local and one external) the behavior is a bit wonky currently.
The
_connect_all()function call inclients.pycurrently attempts to connect to all configured servers one after another, and while I assume that works fine if you have multiple different servers to connect to, it clobbers the connection if two entries are resolvable but point to the same server. This means that if the entry pointing at the external host for your server is last in thecred.jsonfile, it will connect after the local one has successfully connected, bouncing it and defaulting to that route. In my case this means it attempts to transcode, or at least marks the client as being outside of the local net for bandwidth limits etc.The implementation in the
clients.pymight be a touch hacky, but the gist is to sort the list of servers looped over for connection, prioritized by ones pointing at a subnet matching any local IP the host is on. Then we stash theIdof the Jellyfin server successfully connected to, and continue looping over the remainder.If an additional entry is hit with the same
Idas one we've connected to successfully, we skip connecting and finish iterating over the remainder.In theory this doesn't break the use-case where you have multiple, discrete Jellyfin servers you'd like your shim connected to, while allowing duplicate connections to the same servers via different endpoints to bail out once a valid connection has been made, and prefer a local direct IP connection if available.