X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_setup.c;h=f2621f3b92e6f87c0f2afcbcbf742b4ba22f7aa6;hb=a8c5d9fc9f1274608bf9b3a2430f3f72f00ecbcc;hp=a59632cfec3ff216124c229874c801fa5caf1a2b;hpb=b67296418c51784d39a24c3041e2cb199bee06f2;p=meshlink diff --git a/src/net_setup.c b/src/net_setup.c index a59632cf..f2621f3b 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -273,15 +273,13 @@ static bool add_listen_address(meshlink_handle_t *mesh, char *address, bool bind } } - struct addrinfo *ai, hint = {}; - - hint.ai_family = addressfamily; - - hint.ai_socktype = SOCK_STREAM; - - hint.ai_protocol = IPPROTO_TCP; - - hint.ai_flags = AI_PASSIVE; + struct addrinfo *ai; + struct addrinfo hint = { + .ai_family = addressfamily, + .ai_socktype = SOCK_STREAM, + .ai_protocol = IPPROTO_TCP, + .ai_flags = AI_PASSIVE, + }; int err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai); @@ -365,8 +363,10 @@ bool setup_myself(meshlink_handle_t *mesh) { read_host_config(mesh, mesh->config, name); if(!get_config_string(lookup_config(mesh->config, "Port"), &mesh->myport)) { - logger(mesh, MESHLINK_ERROR, "Port for MeshLink instance required!"); - return false; + int port = check_port(mesh); + if (port == 0) + return false; + xasprintf(&mesh->myport, "%d", port); } mesh->self->connection->options = 0;