matchbox icon indicating copy to clipboard operation
matchbox copied to clipboard

Add handshake logic for negotiating closest network IP to peer

Open ConnorBP opened this issue 1 year ago • 1 comments

Currently matchbox always connects peers via public IP Address. I propose an extra step is added to the handshake process to detect peers located on the same LAN or WAN networks, perhaps via MAC address of the router / modem, then the process can proceed to connect the peers via the local address with a fallback to the external on fail.

Reasons:

  1. Some college campuses and business networks block incoming connections on their firewalls, thereby breaking peer to peer connections over external IP's
  2. When two people play on the same network, connecting over the internet may add unnecessary latency and points of failure.
  3. I'm sure there are other reasons I am forgetting at the moment

Other potential solutions to number 1 would involve using a relay server of some kind. This kind of defeats the purpose of peer to peer, but could be a good fallback option. In general more fallback options is good to have.

Side note: when the peers are set together and the traffic between them never starts, matchbox never fails (or perhaps fails silently). Some kind of error handling or timeout on new peer connection would also be a welcome addition to this handshaking process.

ConnorBP avatar Sep 06 '24 14:09 ConnorBP

I don't think this is something that can be fixed with this library. ICE trickling and gathering is handled by the webrtc.rs library, which is simply* a port of the native JS WebRTC library. You don't choose what IP you connect to, WebRTC will connect to the first available successful connection iirc.

  • I say simply, but it's not at all a simple library LOL

dbidwell94 avatar Feb 01 '25 09:02 dbidwell94