Compare commits

...

17 Commits

Author SHA1 Message Date
Adrien Gallouët
fe5bc5454e Add chacha20 option and AES-NI negotiation 2016-07-12 17:01:41 +00:00
Adrien Gallouët
f4e94a9089 Remove -flto for now 2016-07-11 10:24:47 +00:00
Adrien Gallouët
6a7da371e2 Add .build.sh 2016-07-11 09:34:16 +00:00
Adrien Gallouët
4cf5f7a118 Update mud 2016-07-07 14:39:19 +00:00
Adrien Gallouët
35fd01f9ee Update mud 2016-07-06 13:42:30 +00:00
Adrien Gallouët
04aad57789 Update mud 2016-07-05 15:41:32 +00:00
Adrien Gallouët
7a277a8810 Update configure.ac 2016-06-30 09:52:34 +00:00
Adrien Gallouët
b232a101d2 Update mud 2016-06-30 09:41:32 +00:00
Adrien Gallouët
a01dc81500 Don't wait too long when we have data to send 2016-06-27 11:19:16 +00:00
Adrien Gallouët
1db628d84a Update mud 2016-06-24 13:21:02 +00:00
Adrien Gallouët
f11cd34dc4 Update mud 2016-06-22 17:55:18 +00:00
Adrien Gallouët
d0376e3aa5 Update mud 2016-06-22 09:18:34 +00:00
Adrien Gallouët
a7518c0e5a Update mud 2016-06-21 16:51:24 +00:00
Adrien Gallouët
378316bd68 Add mtu option 2016-06-13 15:43:45 +00:00
angt
286d6abf2d Update mud 2016-05-10 10:46:15 +00:00
angt
1f1464e90d Update mud 2016-05-09 14:23:17 +00:00
angt
55d9dd9277 Update mud 2016-05-02 09:18:44 +00:00
4 changed files with 85 additions and 27 deletions

15
.build.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
export CC="gcc -static"
git clone https://github.com/jedisct1/libsodium --depth=1 --branch stable
cd libsodium || exit 1
./autogen.sh && ./configure --enable-minimal --disable-shared --prefix=/usr && make install
cd ..
./autogen.sh && ./configure && make
[ -x glorytun ] || exit 1
mkdir -p deploy
strip -s glorytun
mv glorytun deploy/glorytun-$(cat VERSION)-$(uname -m).bin

View File

@@ -14,8 +14,9 @@ AM_SILENT_RULES([yes])
AM_PROG_CC_C_O
AC_PROG_CC_C99
AC_USE_SYSTEM_EXTENSIONS
AC_SEARCH_LIBS([getaddrinfo], [resolv nsl])
AC_SEARCH_LIBS([socket], [socket])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_FUNCS([clock_gettime])
PKG_CHECK_MODULES([libsodium], [libsodium >= 1.0.4])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

2
mud

Submodule mud updated: 7e5c487951...67f1f6abc2

View File

@@ -189,9 +189,12 @@ static int gt_setup_secretkey (struct mud *mud, char *keyfile)
if (str_empty(keyfile)) {
char buf[2*sizeof(key)+1];
size_t size = sizeof(key);
mud_get_key(mud, key, sizeof(key));
gt_tohex(buf, sizeof(buf), key, sizeof(key));
if (mud_get_key(mud, key, &size))
return -1;
gt_tohex(buf, sizeof(buf), key, size);
state_send(gt.state_fd, "SECRETKEY", buf);
return 0;
@@ -233,13 +236,17 @@ int main (int argc, char **argv)
gt_set_signal();
char *host = NULL;
char *port = "5000";
long port = 5000;
char *bind_list = NULL;
char *bind_port = "5000";
long bind_port = 5000;
char *dev = NULL;
char *keyfile = NULL;
char *statefile = NULL;
long mtu = 1450;
gt.timeout = 5000;
long time_tolerance = 0;
@@ -249,10 +256,11 @@ int main (int argc, char **argv)
struct option opts[] = {
{ "host", &host, option_str },
{ "port", &port, option_str },
{ "port", &port, option_long },
{ "bind", &bind_list, option_str },
{ "bind-port", &bind_port, option_str },
{ "bind-port", &bind_port, option_long },
{ "dev", &dev, option_str },
{ "mtu", &mtu, option_long },
{ "keyfile", &keyfile, option_str },
{ "multiqueue", NULL, option_option },
{ "statefile", &statefile, option_str },
@@ -260,6 +268,7 @@ int main (int argc, char **argv)
{ "time-tolerance", &time_tolerance, option_long },
{ "v4only", NULL, option_option },
{ "v6only", NULL, option_option },
{ "chacha20", NULL, option_option },
{ "version", NULL, option_option },
{ NULL },
};
@@ -309,7 +318,9 @@ int main (int argc, char **argv)
fd_set_nonblock(tun_fd);
struct mud *mud = mud_create(bind_port, v4, v6);
int chacha = option_is_set(opts, "chacha20");
struct mud *mud = mud_create(bind_port, v4, v6, !chacha);
if (!mud) {
gt_log("couldn't create mud\n");
@@ -324,7 +335,7 @@ int main (int argc, char **argv)
if (time_tolerance > 0)
mud_set_time_tolerance_sec(mud, time_tolerance);
if (bind_list) {
if (host && port && bind_list) {
char tmp[1024];
char *name = &tmp[0];
@@ -336,19 +347,16 @@ int main (int argc, char **argv)
tmp[i] = 0;
if (mud_bind(mud, name))
if (mud_peer(mud, name, host, port))
return 1;
name = &tmp[i+1];
}
if (name[0] && mud_bind(mud, name))
if (name[0] && mud_peer(mud, name, host, port))
return 1;
}
if (host && mud_peer(mud, host, port))
return 1;
int mud_fd = mud_get_fd(mud);
state_send(gt.state_fd, "INITIALIZED", tun_name);
@@ -357,7 +365,16 @@ int main (int argc, char **argv)
FD_ZERO(&rfds);
int started = 0;
unsigned char buf[2048];
struct {
unsigned char *buf;
} send, recv;
send.buf = malloc(2*mtu);
recv.buf = malloc(mtu);
size_t send_size = 0;
size_t send_limit = 0;
while (!gt.quit) {
FD_SET(tun_fd, &rfds);
@@ -372,7 +389,7 @@ int main (int argc, char **argv)
.tv_usec = 100000,
};
if (mud_can_push(mud))
if (mud_can_push(mud) || send_size)
timeout.tv_usec = 1000;
if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) {
@@ -395,8 +412,8 @@ int main (int argc, char **argv)
}
if (FD_ISSET(tun_fd, &rfds)) {
while (1) {
const ssize_t r = tun_read(tun_fd, buf, sizeof(buf));
while (send_size<mtu) {
const ssize_t r = tun_read(tun_fd, send.buf+send_size, mtu);
if (r<=0) {
gt.quit |= !r;
@@ -405,9 +422,23 @@ int main (int argc, char **argv)
struct ip_common ic;
if (!ip_get_common(&ic, buf, sizeof(buf)) && ic.size==r)
mud_send(mud, buf, r);
if (ip_get_common(&ic, send.buf+send_size, mtu) || ic.size!=r) {
gt_log("packet dropped: malformed\n");
continue;
}
send_size += r;
if (send_size<=mtu)
send_limit = send_size;
}
}
if (send_limit && mud_send(mud, send.buf, send_limit)==send_limit) {
if (send_size>send_limit)
memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit);
send_size -= send_limit;
send_limit = send_size;
}
mud_push(mud);
@@ -415,18 +446,29 @@ int main (int argc, char **argv)
if (FD_ISSET(mud_fd, &rfds))
mud_pull(mud);
while (1) {
const int size = mud_recv(mud, buf, sizeof(buf));
while (!gt.quit) {
const int size = mud_recv(mud, recv.buf, mtu);
if (size<=0)
break;
const ssize_t r = tun_write(tun_fd, buf, size);
int p = 0;
while (p<size) {
struct ip_common ic;
if (ip_get_common(&ic, recv.buf+p, size-p) || ic.size>size-p)
break;
const ssize_t r = tun_write(tun_fd, recv.buf+p, ic.size);
if (r<=0) {
gt.quit |= !r;
break;
}
p += ic.size;
}
}
}