Compare commits
13 Commits
v0.0.50-mu
...
v0.0.61-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73ce84ccf7 | ||
|
|
91bb0b1231 | ||
|
|
84156a9eba | ||
|
|
b13501b9fb | ||
|
|
3363e219a7 | ||
|
|
00ee23b0b6 | ||
|
|
1286b0f69e | ||
|
|
fe5bc5454e | ||
|
|
f4e94a9089 | ||
|
|
6a7da371e2 | ||
|
|
4cf5f7a118 | ||
|
|
35fd01f9ee | ||
|
|
04aad57789 |
15
.build.sh
Executable file
15
.build.sh
Executable 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
|
||||||
2
mud
2
mud
Submodule mud updated: 5c77233093...a22476f18a
3
src/ip.h
3
src/ip.h
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
struct ip_common {
|
struct ip_common {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
|
uint8_t tc;
|
||||||
uint8_t proto;
|
uint8_t proto;
|
||||||
uint8_t hdr_size;
|
uint8_t hdr_size;
|
||||||
uint16_t size;
|
uint16_t size;
|
||||||
@@ -24,11 +25,13 @@ static inline int ip_get_common (struct ip_common *ic, const uint8_t *data, size
|
|||||||
|
|
||||||
switch (ic->version) {
|
switch (ic->version) {
|
||||||
case 4:
|
case 4:
|
||||||
|
ic->tc = data[1];
|
||||||
ic->proto = data[9];
|
ic->proto = data[9];
|
||||||
ic->hdr_size = (data[0]&0xF)<<2;
|
ic->hdr_size = (data[0]&0xF)<<2;
|
||||||
ic->size = ((data[2]<<8)|data[3]);
|
ic->size = ((data[2]<<8)|data[3]);
|
||||||
return 0;
|
return 0;
|
||||||
case 6:
|
case 6:
|
||||||
|
ic->tc = ((data[0]&0xF)<<4)|(data[1]>>4);
|
||||||
ic->proto = data[6];
|
ic->proto = data[6];
|
||||||
ic->hdr_size = 40;
|
ic->hdr_size = 40;
|
||||||
ic->size = ((data[4]<<8)|data[5])+40;
|
ic->size = ((data[4]<<8)|data[5])+40;
|
||||||
|
|||||||
38
src/main.c
38
src/main.c
@@ -252,7 +252,11 @@ int main (int argc, char **argv)
|
|||||||
long time_tolerance = 0;
|
long time_tolerance = 0;
|
||||||
|
|
||||||
int v4 = 1;
|
int v4 = 1;
|
||||||
int v6 = 1;
|
int v6 = 0;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
v6 = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct option opts[] = {
|
struct option opts[] = {
|
||||||
{ "host", &host, option_str },
|
{ "host", &host, option_str },
|
||||||
@@ -268,6 +272,7 @@ int main (int argc, char **argv)
|
|||||||
{ "time-tolerance", &time_tolerance, option_long },
|
{ "time-tolerance", &time_tolerance, option_long },
|
||||||
{ "v4only", NULL, option_option },
|
{ "v4only", NULL, option_option },
|
||||||
{ "v6only", NULL, option_option },
|
{ "v6only", NULL, option_option },
|
||||||
|
{ "chacha20", NULL, option_option },
|
||||||
{ "version", NULL, option_option },
|
{ "version", NULL, option_option },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
@@ -280,13 +285,18 @@ int main (int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (option_is_set(opts, "v4only"))
|
if (option_is_set(opts, "v4only")) {
|
||||||
|
v4 = 1;
|
||||||
v6 = 0;
|
v6 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (option_is_set(opts, "v6only"))
|
if (option_is_set(opts, "v6only")) {
|
||||||
v4 = 0;
|
v4 = 0;
|
||||||
|
v6 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!v4 && !v6) {
|
if (option_is_set(opts, "v4only") &&
|
||||||
|
option_is_set(opts, "v6only")) {
|
||||||
gt_log("v4only and v6only are both set\n");
|
gt_log("v4only and v6only are both set\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -317,7 +327,9 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
fd_set_nonblock(tun_fd);
|
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) {
|
if (!mud) {
|
||||||
gt_log("couldn't create mud\n");
|
gt_log("couldn't create mud\n");
|
||||||
@@ -372,6 +384,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
size_t send_size = 0;
|
size_t send_size = 0;
|
||||||
size_t send_limit = 0;
|
size_t send_limit = 0;
|
||||||
|
int send_tc = 0;
|
||||||
|
int send_next_tc = 0;
|
||||||
|
|
||||||
while (!gt.quit) {
|
while (!gt.quit) {
|
||||||
FD_SET(tun_fd, &rfds);
|
FD_SET(tun_fd, &rfds);
|
||||||
@@ -426,16 +440,26 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
send_size += r;
|
send_size += r;
|
||||||
|
|
||||||
if (send_size<=mtu)
|
int update_tc = (ic.tc&0xFC)>(send_tc&0xFC);
|
||||||
|
|
||||||
|
if (send_size<=mtu) {
|
||||||
send_limit = send_size;
|
send_limit = send_size;
|
||||||
|
if ((ic.tc&0xFC)>(send_tc&0xFC))
|
||||||
|
send_tc = ic.tc;
|
||||||
|
} else {
|
||||||
|
if ((ic.tc&0xFC)>(send_next_tc&0xFC))
|
||||||
|
send_next_tc = ic.tc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_limit && mud_send(mud, send.buf, send_limit)==send_limit) {
|
if (send_limit && mud_send(mud, send.buf, send_limit, send_tc)==send_limit) {
|
||||||
if (send_size>send_limit)
|
if (send_size>send_limit)
|
||||||
memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit);
|
memmove(&send.buf[0], &send.buf[send_limit], send_size-send_limit);
|
||||||
send_size -= send_limit;
|
send_size -= send_limit;
|
||||||
send_limit = send_size;
|
send_limit = send_size;
|
||||||
|
send_tc = send_next_tc;
|
||||||
|
send_next_tc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mud_push(mud);
|
mud_push(mud);
|
||||||
|
|||||||
Reference in New Issue
Block a user