jellyfin / jellyfin-kodi

Jellyfin Plugin for Kodi
https://jellyfin.org
GNU General Public License v3.0
841 stars 113 forks source link

Add dynamic server address change based on network SSID #304

Open LeVraiRoiDHyrule opened 4 years ago

LeVraiRoiDHyrule commented 4 years ago

Hi, I would suggest an enhancement to the addon.

My Jellyfin server runs on a Rpi4. When connecting locally, server address is 192.168.1.XX:8096. When connecting remotely, the address is [mydyndns]:8096. I'm tired of having to manually delete and re-add the server with the correct address in the addon settings everytime I am out of home or when I come back.

Could it be possible to add a feature that allows to add a secondary address that will be used for a specific network SSID ?

The Android Kodi remote Yatse have a similar feature for connecting to Kodi, that's so useful. Could you consider adding that to Jellyfin addon too ? Thanks and have a good day.

mcarlton00 commented 4 years ago

I'm not sure we have access to the network settings to determine server based on SSID. It may be possible to add a toggle, but I'm not sure what that would look like yet.

A simpler (certainly faster) solution may be to set up a DNS override in your local DNS server/router so that your dyndns name points to the local IP. So when you're on your lan you could go to [mydyndns]:8096 instead of the IP address

LeVraiRoiDHyrule commented 4 years ago

I need my dyndns to point to my global IP and not a single local IP on my network, because I also use it to access other devices on my network with other services (Xbox One streaming for example).

Plus my router can't do DNS override. It can only send its global IP to the dyndns service when it changes.

But could you look into adding a feature to change the address easily from within the addon ? A simple toggle button could do the job is Kodi can't detect SSID.

Artiume commented 4 years ago

Do you have this issue with other clients? It could be hairpinning

LeVraiRoiDHyrule commented 4 years ago

It's not an issue, it's just an improvement i'm suggesting. This happens in all apps that communicate to a server, I always have to switch the address from my local IP when inside the network and the dynamic dns when outside. For most apps it's fast to do. But in Jellyfin for Kodi addon, it's much more a struggle to do. I think it would be easy to automatise this and make the addon automatically choose the right address depending on the SSID (or maybe just trying one then the other if it can't connect, if SSID detection is not possible)

oddstr13 commented 4 years ago

What @mcarlton00 is suggesting is called Split-horizon DNS, and is what I personally use for this at the moment. When a computer on LAN asks the router what the IP of the server is, it responds with the local IP, but when a computer outside the LAN asks about the same domain name, their DNS server will respond with the public IP (as provided by dyndns). This feature may or may not be available in your router, but in the OpenWRT firmware it's located under Network -> Hostnames

@Artiume is talking about NAT Reflection, which I've had mixed success with. Either it should just work, or your router probably doesn't support it. I've seen both in the router setups I've had throughout the years.

If we want to implement something like this in the addon directly, I believe the easiest way would be to have a list of addresses, and attempt pinging the LAN IP first, and see if that is reachable, or if not, continue with the next one in the list. I think there may have sort of been a feature like this earlier, but that we pulled it out as part of cleanup work.

Artiume commented 4 years ago

I've had success with using an alternative DNS for my router, like pihole, but yeah, mixed success lol

mobamoba commented 4 years ago

A total kludge for this issue - which I have as well as I have a device I sometimes use at home and sometimes travel with and have a router without NAT Loopback unfortunately - is to modify the Jellyfin settings.xml and change the server address there simply because it's significantly faster to type using your keyboard rather than your remote. A second kludge is to create a second Kodi profile with your main profile having Jellyfin using your LAN IP and your second profile setup with Jellyfin using your hostname.

Hopefully there will be a way to add both a LAN address with a remote as fallback if LAN ping fails at some point in the future but until then the above are my workarounds and I thought I'd share.

LeVraiRoiDHyrule commented 4 years ago

A total kludge for this issue - which I have as well as I have a device I sometimes use at home and sometimes travel with and have a router without NAT Loopback unfortunately - is to modify the Jellyfin settings.xml and change the server address there simply because it's significantly faster to type using your keyboard rather than your remote. A second kludge is to create a second Kodi profile with your main profile having Jellyfin using your LAN IP and your second profile setup with Jellyfin using your hostname.

Hopefully there will be a way to add both a LAN address with a remote as fallback if LAN ping fails at some point in the future but until then the above are my workarounds and I thought I'd share.

I'm happy to know that I'm not the only one having a router that doesn't support loopback. So yeah this is a big issue, I hope we will have a workaround in the future.