Compare commits
1 Commits
v0.0.39-mu
...
v0.0.29-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3b78a3868 |
2
mud
2
mud
Submodule mud updated: 04c8495fe6...6b3001e6d8
63
src/main.c
63
src/main.c
@@ -242,20 +242,17 @@ int main (int argc, char **argv)
|
||||
|
||||
gt.timeout = 5000;
|
||||
|
||||
long time_tolerance = 0;
|
||||
|
||||
struct option opts[] = {
|
||||
{ "host", &host, option_str },
|
||||
{ "port", &port, option_str },
|
||||
{ "bind", &bind_list, option_str },
|
||||
{ "bind-port", &bind_port, option_str },
|
||||
{ "dev", &dev, option_str },
|
||||
{ "keyfile", &keyfile, option_str },
|
||||
{ "multiqueue", NULL, option_option },
|
||||
{ "statefile", &statefile, option_str },
|
||||
{ "timeout", >.timeout, option_long },
|
||||
{ "time-tolerance", &time_tolerance, option_long },
|
||||
{ "version", NULL, option_option },
|
||||
{ "host", &host, option_str },
|
||||
{ "port", &port, option_str },
|
||||
{ "bind", &bind_list, option_str },
|
||||
{ "bind-port", &bind_port, option_str },
|
||||
{ "dev", &dev, option_str },
|
||||
{ "keyfile", &keyfile, option_str },
|
||||
{ "multiqueue", NULL, option_option },
|
||||
{ "statefile", &statefile, option_str },
|
||||
{ "timeout", >.timeout, option_long },
|
||||
{ "version", NULL, option_option },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
@@ -282,6 +279,11 @@ int main (int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!crypto_aead_aes256gcm_is_available()) {
|
||||
gt_na("AES-256-GCM");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (state_init(statefile))
|
||||
return 1;
|
||||
|
||||
@@ -308,11 +310,6 @@ int main (int argc, char **argv)
|
||||
|
||||
mud_set_key(mud, gt.key, sizeof(gt.key));
|
||||
|
||||
mud_set_send_timeout_msec(mud, gt.timeout);
|
||||
|
||||
if (time_tolerance > 0)
|
||||
mud_set_time_tolerance_sec(mud, time_tolerance);
|
||||
|
||||
if (bind_list) {
|
||||
char tmp[1024];
|
||||
char *name = &tmp[0];
|
||||
@@ -358,12 +355,9 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
struct timeval timeout = {
|
||||
.tv_usec = 100000,
|
||||
.tv_usec = 1000,
|
||||
};
|
||||
|
||||
if (mud_can_push(mud))
|
||||
timeout.tv_usec = 1000;
|
||||
|
||||
if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) {
|
||||
if (errno==EINTR)
|
||||
continue;
|
||||
@@ -373,24 +367,20 @@ int main (int argc, char **argv)
|
||||
|
||||
if (mud_is_up(mud)) {
|
||||
if (!started) {
|
||||
state("STARTED", tun_name);
|
||||
state("STARTED", NULL);
|
||||
started = 1;
|
||||
}
|
||||
} else {
|
||||
if (started) {
|
||||
state("STOPPED", tun_name);
|
||||
started = 0;
|
||||
}
|
||||
} else if (started) {
|
||||
state("STOPPED", NULL);
|
||||
started = 0;
|
||||
}
|
||||
|
||||
if (FD_ISSET(tun_fd, &rfds)) {
|
||||
while (1) {
|
||||
const ssize_t r = tun_read(tun_fd, buf, sizeof(buf));
|
||||
|
||||
if (r<=0) {
|
||||
gt.quit |= !r;
|
||||
if (r<=0)
|
||||
break;
|
||||
}
|
||||
|
||||
struct ip_common ic;
|
||||
|
||||
@@ -405,17 +395,12 @@ int main (int argc, char **argv)
|
||||
mud_pull(mud);
|
||||
|
||||
while (1) {
|
||||
const int size = mud_recv(mud, buf, sizeof(buf));
|
||||
const int r = mud_recv(mud, buf, sizeof(buf));
|
||||
|
||||
if (size<=0)
|
||||
if (r<=0)
|
||||
break;
|
||||
|
||||
const ssize_t r = tun_write(tun_fd, buf, size);
|
||||
|
||||
if (r<=0) {
|
||||
gt.quit |= !r;
|
||||
break;
|
||||
}
|
||||
tun_write(tun_fd, buf, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user