REST - Get the destination IP address only

I use Rest to get the IP Address of the Connected Devices. I got some situation that the IP address I got doesn’t route to the Device but point to a relay server. Is it possible to get only the IP-Addresses of the Devices?

No. If the device is connected via a relay Syncthing doesn’t know their IP.

Isn’t that the Job of a relay to get two PC together?

Yes, via the relay, as they can’t connect directly.

In my opinion these two statements dose not fit together.

and

As far I understood my Synthing-Client knows the IP-Address but could not set-up a direct connection.

It most likely does, and you can check that via rest api:

https://docs.syncthing.net/rest/system-discovery-get.html

But as it was said above, this will contain multiple different addresses that we try to connect to, some of which make no sense.

I don’t see the conflict between those statements.

How could A client don’t know the destination IP if It get the IP from the Relay to be able to try connecting them directly?

It doesn’t get the IP from the relay.

Syncthing performs discovery to find the addresses of other devices. Among other things it asks the discovery servers. Those may know the external IP of the other device, and you can see the results on the URL Audrius linked above.

If it can’t connect directly it will, after some time, try to connect via a relay. If the relay connection succeeds we, of course, know the IP adress of the relay. We don’t know the IP of the device on the other side of the relay. It could be one of the addresses returned by the discovery, but it also may not be.

Ok that seems a bit more logical. But I don’t get it why syncthing removes the Destination IP from it’s known list. Even a connection via Relay exist. shouldn’t Syncthing try to connect itself directly sometimes again? I don’t know why but my smart-phone and my PC at home are connected from the same Provider. I don’t get it why it sometimes not work to get the connection without a relay and sometimes it do.

The IP address of my PC also do not change for some weeks. Even the connection had worked directly one time and on an other time it don’t get the destination IP from discovery in my opinion it should also try the last known IP from time to time.

It tries the all the IPs advertised by the other side, based on priority/rank. If we are connected via relay it won’t try another relay, etc.

The other side advertises something every 30mins I think.

You can debug why it connects via relay by checking if the addresses other side advertised are actually accessible.

Could you briefly explain how relaying works . does it do something similar to port-forwarding ? I had set-up a discovery server behind a load balancer(which resolved the url to ip of discovery server). This setup isn’t allowed as load balancer becomes man in the middle. why isnt same happening when relay server is used ?

It’s documented in the docs site.

Syncthing has a trust relationship with the discovery server, certificates are checked in both directions. Syncthing has no trust requirements at all on the relay server - it’s completely untrusted. As long as it passes bytes from A to B and back it’s all good.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.