Compare commits
2 Commits
v0.0.38-mu
...
v0.0.40-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39e3f53139 | ||
|
|
babe14d544 |
2
mud
2
mud
Submodule mud updated: 04c8495fe6...f0ad4bbdd3
33
src/main.c
33
src/main.c
@@ -244,6 +244,9 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
long time_tolerance = 0;
|
long time_tolerance = 0;
|
||||||
|
|
||||||
|
int v4 = 1;
|
||||||
|
int v6 = 1;
|
||||||
|
|
||||||
struct option opts[] = {
|
struct option opts[] = {
|
||||||
{ "host", &host, option_str },
|
{ "host", &host, option_str },
|
||||||
{ "port", &port, option_str },
|
{ "port", &port, option_str },
|
||||||
@@ -255,6 +258,8 @@ int main (int argc, char **argv)
|
|||||||
{ "statefile", &statefile, option_str },
|
{ "statefile", &statefile, option_str },
|
||||||
{ "timeout", >.timeout, option_long },
|
{ "timeout", >.timeout, option_long },
|
||||||
{ "time-tolerance", &time_tolerance, option_long },
|
{ "time-tolerance", &time_tolerance, option_long },
|
||||||
|
{ "v4only", NULL, option_option },
|
||||||
|
{ "v6only", NULL, option_option },
|
||||||
{ "version", NULL, option_option },
|
{ "version", NULL, option_option },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
@@ -267,6 +272,17 @@ int main (int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (option_is_set(opts, "v4only"))
|
||||||
|
v6 = 0;
|
||||||
|
|
||||||
|
if (option_is_set(opts, "v6only"))
|
||||||
|
v4 = 0;
|
||||||
|
|
||||||
|
if (!v4 && !v6) {
|
||||||
|
gt_log("v4only and v6only are both set\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!option_is_set(opts, "keyfile")) {
|
if (!option_is_set(opts, "keyfile")) {
|
||||||
gt_log("keyfile option must be set\n");
|
gt_log("keyfile option must be set\n");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -299,7 +315,7 @@ int main (int argc, char **argv)
|
|||||||
if (gt_setup_secretkey(keyfile))
|
if (gt_setup_secretkey(keyfile))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
struct mud *mud = mud_create(bind_port);
|
struct mud *mud = mud_create(bind_port, v4, v6);
|
||||||
|
|
||||||
if (!mud) {
|
if (!mud) {
|
||||||
gt_log("couldn't create mud\n");
|
gt_log("couldn't create mud\n");
|
||||||
@@ -387,8 +403,10 @@ int main (int argc, char **argv)
|
|||||||
while (1) {
|
while (1) {
|
||||||
const ssize_t r = tun_read(tun_fd, buf, sizeof(buf));
|
const ssize_t r = tun_read(tun_fd, buf, sizeof(buf));
|
||||||
|
|
||||||
if (r<=0)
|
if (r<=0) {
|
||||||
|
gt.quit |= !r;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
struct ip_common ic;
|
struct ip_common ic;
|
||||||
|
|
||||||
@@ -403,12 +421,17 @@ int main (int argc, char **argv)
|
|||||||
mud_pull(mud);
|
mud_pull(mud);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
const int r = mud_recv(mud, buf, sizeof(buf));
|
const int size = mud_recv(mud, buf, sizeof(buf));
|
||||||
|
|
||||||
if (r<=0)
|
if (size<=0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tun_write(tun_fd, buf, r);
|
const ssize_t r = tun_write(tun_fd, buf, size);
|
||||||
|
|
||||||
|
if (r<=0) {
|
||||||
|
gt.quit |= !r;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user