Compare commits
9 Commits
v0.0.30-mu
...
v0.0.37-mu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99262777fc | ||
|
|
b0f60caab2 | ||
|
|
efd5e0bb36 | ||
|
|
ade4617d53 | ||
|
|
64a5fd8227 | ||
|
|
eba968797c | ||
|
|
d60f28a7fe | ||
|
|
32069eb104 | ||
|
|
a6adcefc25 |
2
mud
2
mud
Submodule mud updated: a1ba274fbf...3b86683636
43
src/main.c
43
src/main.c
@@ -242,17 +242,20 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
gt.timeout = 5000;
|
gt.timeout = 5000;
|
||||||
|
|
||||||
|
long time_tolerance = 0;
|
||||||
|
|
||||||
struct option opts[] = {
|
struct option opts[] = {
|
||||||
{ "host", &host, option_str },
|
{ "host", &host, option_str },
|
||||||
{ "port", &port, option_str },
|
{ "port", &port, option_str },
|
||||||
{ "bind", &bind_list, option_str },
|
{ "bind", &bind_list, option_str },
|
||||||
{ "bind-port", &bind_port, option_str },
|
{ "bind-port", &bind_port, option_str },
|
||||||
{ "dev", &dev, option_str },
|
{ "dev", &dev, option_str },
|
||||||
{ "keyfile", &keyfile, option_str },
|
{ "keyfile", &keyfile, option_str },
|
||||||
{ "multiqueue", NULL, option_option },
|
{ "multiqueue", NULL, option_option },
|
||||||
{ "statefile", &statefile, option_str },
|
{ "statefile", &statefile, option_str },
|
||||||
{ "timeout", >.timeout, option_long },
|
{ "timeout", >.timeout, option_long },
|
||||||
{ "version", NULL, option_option },
|
{ "time-tolerance", &time_tolerance, option_long },
|
||||||
|
{ "version", NULL, option_option },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -305,6 +308,11 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
mud_set_key(mud, gt.key, sizeof(gt.key));
|
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) {
|
if (bind_list) {
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
char *name = &tmp[0];
|
char *name = &tmp[0];
|
||||||
@@ -350,9 +358,12 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct timeval timeout = {
|
struct timeval timeout = {
|
||||||
.tv_usec = 1000,
|
.tv_usec = 100000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (mud_can_push(mud))
|
||||||
|
timeout.tv_usec = 1000;
|
||||||
|
|
||||||
if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) {
|
if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) {
|
||||||
if (errno==EINTR)
|
if (errno==EINTR)
|
||||||
continue;
|
continue;
|
||||||
@@ -362,12 +373,14 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (mud_is_up(mud)) {
|
if (mud_is_up(mud)) {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
state("STARTED", NULL);
|
state("STARTED", tun_name);
|
||||||
started = 1;
|
started = 1;
|
||||||
}
|
}
|
||||||
} else if (started) {
|
} else {
|
||||||
state("STOPPED", NULL);
|
if (started) {
|
||||||
started = 0;
|
state("STOPPED", tun_name);
|
||||||
|
started = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(tun_fd, &rfds)) {
|
if (FD_ISSET(tun_fd, &rfds)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user