holepunchto / hyperdht

The DHT powering Hyperswarm
https://docs.holepunch.to
MIT License
323 stars 46 forks source link

Ensure relay-connections-through-node test actually relays #159

Closed HDegroote closed 9 months ago

HDegroote commented 9 months ago

The relay tests weren't really testing anything related to the relays, as the connection stack could connect over the local network, and the relay logic never triggered.

This PR modifies the test where both client and server follow a normal flow, ensuring they cannot connect over LAN or holepunch, also adding explicit checks to ensure this.

Note: I had to add a new, hidden _noHolepunching option to the DHT server, because whenever the holepunch code at the end of the _addHandshake function executed, server and client connected directly anyway (https://github.com/holepunchto/hyperdht/blob/66341e7f028189d1418c1ec49635b14d208a26f1/lib/server.js#L402-L407)

This also means that I don't know how to fix the relay tests where the holepunching is cancelled at one side, as those too get saved by that code and currently make no use at all of the relay