stun

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

commit 8170f898519ea02c946d859157871be61c2a54a7
parent 4a6652547f545a50cac664a6149b30052af73d97
Author: sin <sin@2f30.org>
Date:   Wed, 30 Mar 2016 13:30:50 +0100

allow binding to given address

Diffstat:
Mstun.8 | 6+++++-
Mstun.c | 8++++++--
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/stun.8 b/stun.8 @@ -8,6 +8,7 @@ .Nm stun .Op Fl df .Fl s +.Op Fl b Ar address .Op Fl p Ar port .Op Fl t Ar type .Ar interface @@ -27,13 +28,16 @@ in advance. In client mode will automatically try to reconnect to the server every minute if the connection drops. .Sh OPTIONS -.Bl -tag -width "-p port" +.Bl -tag -width "-b address" .It Fl d Enable debug output. .It Fl f Run in foreground. .It Fl s Enable server mode. Default is off. +.It Fl b Ar address +Bind the server to the given +.Ar address . .It Fl p Ar port Listen on or connect to specified .Ar port . diff --git a/stun.c b/stun.c @@ -93,6 +93,7 @@ enum { EVP_CIPHER_CTX ectx, dctx; unsigned char aeskey[EVP_MAX_KEY_LENGTH]; char *argv0; +char *bindaddr; char *host; char *port = "12080"; int devtype = TUNDEV; @@ -633,7 +634,7 @@ serversetup(int devfd) hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; - ret = getaddrinfo(NULL, port, &hints, &ai); + ret = getaddrinfo(bindaddr, port, &hints, &ai); if (ret != 0) logerr("getaddrinfo: %s", gai_strerror(ret)); @@ -749,7 +750,7 @@ err: void usage(void) { - fprintf(stderr, "usage: stun [-df] -s [-p port] [-t type] interface\n"); + fprintf(stderr, "usage: stun [-df] -s [-b address] [-p port] [-t type] interface\n"); fprintf(stderr, " stun [-df] -h host [-p port] [-t type] interface\n"); exit(1); } @@ -770,6 +771,9 @@ main(int argc, char *argv[]) case 's': sflag = 1; break; + case 'b': + bindaddr = EARGF(usage()); + break; case 'h': host = EARGF(usage()); break;