From e750c4666597c46b4516dee238643a7b57aa15df Mon Sep 17 00:00:00 2001 From: angt Date: Thu, 25 Feb 2016 15:22:47 +0000 Subject: [PATCH] Update mud --- mud | 2 +- src/main.c | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/mud b/mud index 48419d0..bfa92d3 160000 --- a/mud +++ b/mud @@ -1 +1 @@ -Subproject commit 48419d0e5c004a05cf52ffe8d64d25f8d654b757 +Subproject commit bfa92d373d03626dbccfdabd5e016beebcadb163 diff --git a/src/main.c b/src/main.c index 827dc8d..dd5c44f 100644 --- a/src/main.c +++ b/src/main.c @@ -336,29 +336,21 @@ int main (int argc, char **argv) struct mud *mud = mud_create(ctx.skey, sizeof(ctx.skey)); if (!mud) { - gt_log("unable to crate the mud !!!\n"); + gt_log("unable to create the mud !!!\n"); return 1; } - int fd1 = mud_bind(mud, host_bind, port); - - if (fd1==-1) + if (host_bind && mud_bind(mud, host_bind)) return 1; - int fdmax = fd1; - - int fd2 = -1; - - if (host_bind2) { - fd2 = mud_bind(mud, host_bind2, port); - fdmax = fd2; - if (fd2==-1) - return 1; - } + if (host_bind2 && mud_bind(mud, host_bind2)) + return 1; if (host_peer && mud_peer(mud, host_peer, port)) return 1; + int mud_fd = mud_get_fd(mud); + state("INITIALIZED", tun_name); struct packet *packet = NULL; @@ -374,16 +366,13 @@ int main (int argc, char **argv) while (!gt_close) { FD_SET(tun_fd, &rfds); - FD_SET(fd1, &rfds); - - if (fd2!=-1) - FD_SET(fd2, &rfds); + FD_SET(mud_fd, &rfds); struct timeval timeout = { .tv_usec = 1000, }; - if _0_(select(fdmax+1, &rfds, NULL, NULL, &timeout)==-1) { + if _0_(select(mud_fd+1, &rfds, NULL, NULL, &timeout)==-1) { if (errno==EINTR) continue; perror("select"); @@ -406,7 +395,7 @@ int main (int argc, char **argv) mud_push(mud); - if (FD_ISSET(fd2, &rfds) || FD_ISSET(fd1, &rfds)) + if (FD_ISSET(mud_fd, &rfds)) mud_pull(mud); while (1) {