warp-vpn

point to point VPN implementation
git clone git://git.2f30.org/warp-vpn
Log | Files | Refs | README

commit 25ab42f0d2836737bbb3890e6dc9e5ba8b86b704
parent f05be7cab79ef6d8852f900826347bf34030ba22
Author: sin <sin@2f30.org>
Date:   Mon, 21 Mar 2016 11:25:15 +0000

some newlines

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

diff --git a/stun.c b/stun.c @@ -350,14 +350,15 @@ serversetup(int tunfd) (socklen_t []){sizeof(remote)}); if (netfd < 0) err(1, "accept"); + setsockopt(netfd, IPPROTO_TCP, TCP_NODELAY, (int []){1}, sizeof(int)); - if (debug) - printf("client connected\n"); + ret = challenge(netfd); if (ret < 0) { close(netfd); continue; } + loop(netfd, tunfd); close(netfd); } @@ -379,10 +380,13 @@ clientsetup(int tunfd) ret = connect(netfd, (struct sockaddr *)&remote, sizeof(remote)); if (ret < 0) err(1, "connect"); + setsockopt(netfd, IPPROTO_TCP, TCP_NODELAY, (int []){1}, sizeof(int)); + ret = response(netfd); if (ret < 0) errx(1, "failed to respond to challenge"); + return loop(netfd, tunfd); } @@ -421,13 +425,16 @@ main(int argc, char *argv[]) if (argc != 1 || (!sflag && !host)) usage(); + tunfd = opentun(argv[0]); + pw = getenv("STUNPW"); if (!pw) errx(1, "STUNPW is not set"); if (aesinit((unsigned char *)pw, strlen(pw), &enc, &dec) < 0) errx(1, "couldn't initialize AES cipher"); explicit_bzero(pw, strlen(pw)); + if (sflag) return serversetup(tunfd); ret = clientsetup(tunfd);