RFC 6335 says operating systems should use ports 49152-65535 for
ephemeral ports. However, Linux and several other operating systems use
32768-65535 by default. Make sure we don't bind in that range, as a
single outgoing TCP connection that uses the same port for the local end
as MeshLink wants to use for the listening port can cause problems.
int check_port(meshlink_handle_t *mesh) {
for(int i = 0; i < 1000; i++) {
- int port = 0x1000 + prng(mesh, 0x8000);
+ int port = 0x1000 + prng(mesh, 0x7000);
if(try_bind(mesh, port)) {
free(mesh->myport);