X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=6c54eff90ac20fa7953ab9ae002e0910174a78b6;hb=9fdf4278f8c8c1563d45205c9e9f1bc351bd814f;hp=00757c47a57b96d7c3f258acd92652be66e9cac1;hpb=d8d1ab4ee1e92ec84fe9ea86eec2396275483a92;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 00757c47..6c54eff9 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -417,6 +417,7 @@ static bool ed25519_keygen(bool ask) { char *pubkey = ecdsa_get_base64_public_key(key); fprintf(f, "Ed25519PublicKey = %s\n", pubkey); + free(pubkey); fclose(f); ecdsa_free(key); @@ -1480,6 +1481,9 @@ const var_t variables[] = { {"UDPInfoInterval", VAR_SERVER}, {"UDPRcvBuf", VAR_SERVER}, {"UDPSndBuf", VAR_SERVER}, + {"UPnP", VAR_SERVER}, + {"UPnPDiscoverWait", VAR_SERVER}, + {"UPnPRefreshPeriod", VAR_SERVER}, {"VDEGroup", VAR_SERVER}, {"VDEPort", VAR_SERVER}, /* Host configuration */ @@ -1804,7 +1808,7 @@ static int cmd_config(int argc, char *argv[]) { } static bool try_bind(int port) { - struct addrinfo *ai = NULL; + struct addrinfo *ai = NULL, *aip; struct addrinfo hint = { .ai_flags = AI_PASSIVE, .ai_family = AF_UNSPEC, @@ -1812,24 +1816,30 @@ static bool try_bind(int port) { .ai_protocol = IPPROTO_TCP, }; + bool success = true; char portstr[16]; snprintf(portstr, sizeof portstr, "%d", port); if(getaddrinfo(NULL, portstr, &hint, &ai) || !ai) return false; - while(ai) { + for(aip = ai; aip; aip = aip->ai_next) { int fd = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP); - if(!fd) - return false; + if(!fd) { + success = false; + break; + } + int result = bind(fd, ai->ai_addr, ai->ai_addrlen); closesocket(fd); - if(result) - return false; - ai = ai->ai_next; + if(result) { + success = false; + break; + } } - return true; + freeaddrinfo(ai); + return success; } int check_port(char *name) {