X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_setup.c;h=ceaeb0c5b1fb9f0502c65e34d23931e44f0221c4;hb=64db0bb3f32236b55746bf62002faca08a54e364;hp=d0e450039913c995298f304f3b4003730ad606f8;hpb=097f88088e00923b74bc4c38e67feceb162ba4ef;p=meshlink diff --git a/src/net_setup.c b/src/net_setup.c index d0e45003..ceaeb0c5 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -301,7 +301,7 @@ static bool load_node(meshlink_handle_t *mesh, const char *name, void *priv) { return true; } -static int setup_tcp_listen_socket(meshlink_handle_t *mesh, const struct addrinfo *aip) { +int setup_tcp_listen_socket(meshlink_handle_t *mesh, const struct addrinfo *aip) { int nfd = socket(aip->ai_family, SOCK_STREAM, IPPROTO_TCP); if(nfd == -1) { @@ -339,7 +339,7 @@ static int setup_tcp_listen_socket(meshlink_handle_t *mesh, const struct addrinf return nfd; } -static int setup_udp_socket(meshlink_handle_t *mesh, const struct addrinfo *aip) { +int setup_udp_listen_socket(meshlink_handle_t *mesh, const struct addrinfo *aip) { int nfd = socket(aip->ai_family, SOCK_DGRAM, IPPROTO_UDP); if(nfd == -1) { @@ -422,7 +422,7 @@ static bool add_listen_sockets(meshlink_handle_t *mesh) { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, .ai_protocol = IPPROTO_TCP, - .ai_flags = AI_PASSIVE, + .ai_flags = AI_PASSIVE | AI_NUMERICSERV, }; int err = getaddrinfo(NULL, mesh->myport, &hint, &ai); @@ -470,7 +470,7 @@ static bool add_listen_sockets(meshlink_handle_t *mesh) { /* If TCP worked, then we require that UDP works as well. */ - int udp_fd = setup_udp_socket(mesh, aip); + int udp_fd = setup_udp_listen_socket(mesh, aip); if(udp_fd == -1) { closesocket(tcp_fd); @@ -565,7 +565,6 @@ bool setup_myself(meshlink_handle_t *mesh) { /* Done. */ - mesh->last_config_check = mesh->loop.now.tv_sec; mesh->last_unreachable = mesh->loop.now.tv_sec; return true;