Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.1k stars 214 forks source link

Syncplay Server should tell the IP and port of the machine its running on. #80

Closed abhay-raizada closed 8 years ago

abhay-raizada commented 8 years ago

right now after starting the server, the user has to search their own ip and port, to give to the clients, it should be the responsibility of the syncplay server to tell the user their ip and port.

Uriziel commented 8 years ago

Not really possible, I guess? Server does not necessarily knows its IP, nor it's bound to any particular interface so it's accessible from multiple ips (like localhost)

abhay-raizada commented 8 years ago

the server could provide a list of all ip's its listening on? i mean if there are many interfaces it could provide the ip's of all of them?

Uriziel commented 8 years ago

Still there's no easy way to tell (platform dependent too, I guess?). Also its ip might be hidden by NAT or something similar

Et0h commented 8 years ago

Port is easy. We could add an option to connect to syncplay.pl to get Internet-facing IP and host a special script, but people could just do wget -O - -q http://whatismyip.org/ or whatever to get their IP.

abhay-raizada commented 8 years ago

People Can find their own IP's, but shouldn't syncplay do it for them? not everybody is a power user? , why not have syncplay return the output from wget -O - -q http://whatismyip.org/ ?

Et0h commented 8 years ago

We wouldn't want to use any old random service as at any point they could go down or change their response. So if we did it we'd need to host our own script on our own server so we could be sure it'd work (so long as our server is up). Furthermore, it might not be a good idea to connect to an external IP without user's consent for privacy reasons. If someone is happy to connect to Syncplay server, we could also check to ensure server is running latest stable version of Syncplay (or newer). I don't see it as a top priority, though, as non-power-users can simply use the public Syncplay servers. However, thanks for the suggestion.

abhay-raizada commented 8 years ago

we could send have a socket connect connect to http://syncplay.pl ,use the getsockname function to know which address the connection was established with . For example:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("syncplay.pl",80))
print(s.getsockname()[0])
s.close()
Et0h commented 8 years ago

Does getsockname work properly across all platforms (operating systems) and circumstances (network configurations)? Does it have any advantages over connecting to a custom PHP script via urllib which also checks for updates?

abhay-raizada commented 8 years ago

I don't know about cross-platforming yet, I'll update when I have checked, it does work on Linux, the obvious advantage over connecting via urllib is that as of now, we don't have to make any changes, server side, as per network configurations it will give the ip of the entire network if you're on an NAT, for a local ip we could use ifconfig and check the output, and specify both the addresses

Uriziel commented 8 years ago

It is cross-platform. Every TCP connection internally uses sockets. There's probably also twisted way of finding address of your connection too - except it still relies on connecting to external service and is literally the same as querying "what's my ip".

abhay-raizada commented 8 years ago

what seems to be the only way. to do this is to query the internet(In cas we're on a network with a single ip), using twisted. then go through all the interfaces, and check the IP's and display them all as "local adresses" . I can write this entire thing, but I am worried I may break the conventions followed by the software.

Et0h commented 8 years ago

This seems more hassle than it is worth, and anyone who wants to get their IP can do so without Syncplay having a dedicated feature for it.