Skip to content

New gateway handshake

Luke Champine requested to merge gateway-handshake into gateway-proto

This is a pretty messy refactoring. It would be nice if we could split the compat code into a separate file or something. Even then, peers.go is too long for my liking.

One uncertainty I had was around hostname validation. In the new handshake, the gateways exchange their full NetAddresses. They will then check that the "claimed" NetAddress hostname matches the hostname of conn.RemoteAddr. (The rationale for this is to prevent a gateway from tricking you into DDoSing an IP other than their own.) However, while running the antfarm, connections would fail because the connecting gateway thinks its NetAddress is its external IP, but the accepting gateway sees conn.RemoteAddr == 127.0.0.1. I rectified this by having the gateway send conn.LocalAddr instead of its external NetAddress, but I'm not sure if that solution will work for all network architectures. There may be a valid instance where the "true" hostname doesn't match the hostname returned by conn.RemoteAddr. For now, I'm erring on the side of preventing DDoS.

Merge request reports