stun

simple point to point tunnel
git clone git://git.2f30.org/stun
Log | Files | Refs | README

commit 4c9ea459209408dce9a491304cf0e866882ee5b7
parent 5a0cc172c12ebc490bcc40268c681f1feda3490f
Author: sin <sin@2f30.org>
Date:   Fri,  8 Apr 2016 15:07:34 +0100

cleanup

Diffstat:
Mstun.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/stun.c b/stun.c @@ -536,7 +536,7 @@ serversetup(int devfd) hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; - if ((ret = getaddrinfo(bindaddr, port, &hints, &ai)) != 0) + if ((ret = getaddrinfo(bindaddr, port, &hints, &ai))) logerr("getaddrinfo: %s", gai_strerror(ret)); for (p = ai; p; p = p->ai_next) { @@ -548,15 +548,16 @@ serversetup(int devfd) close(listenfd); continue; } + if (listen(listenfd, 5) < 0) { + close(listenfd); + continue; + } break; } if (!p) logerr("failed to bind socket"); freeaddrinfo(ai); - if (listen(listenfd, 5) < 0) - logerr("listen failed"); - revokeprivs(); for (;;) { netfd = accept(listenfd, (struct sockaddr *)&remote, @@ -598,7 +599,7 @@ clientsetup(int devfd) memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; - if ((ret = getaddrinfo(host, port, &hints, &ai)) != 0) + if ((ret = getaddrinfo(host, port, &hints, &ai))) logerr("getaddrinfo: %s", gai_strerror(ret)); for (p = ai; p; p = p->ai_next) {