MitchellMarinoDev / carrier-pigeon

A rusty networking library for games.
Other
13 stars 2 forks source link

UDP through NAT is not supported #5

Open elsid opened 2 years ago

elsid commented 2 years ago

When a UDP packet is received, the server tries to lookup a peer that was added earlier. The problem is it was added for TCP connection but when the UDP packet goes through NAT the source port can change to any value. This happens because network routers handle TCP and UDP traffic independently. As a result, the carrier-pigeon server can't find the UDP peer in the Server::addr_cid and the traffic is rejected. Usually the problem appears when IPv4 is used and client and server are located in different networks.

MitchellMarinoDev commented 1 year ago

I see. I had not done extensive testing though a NAT, mostly all local network stuff. I am in the midst of a rework gutting tcp and implementing a reliable layer on top of udp. Since connection will then happen over udp, I will be using the udp source address which should be correct.