Update mud

This commit is contained in:
angt
2016-02-25 15:22:47 +00:00
parent 935111cfea
commit e750c46665
2 changed files with 10 additions and 21 deletions

2
mud

Submodule mud updated: 48419d0e5c...bfa92d373d

View File

@@ -336,29 +336,21 @@ int main (int argc, char **argv)
struct mud *mud = mud_create(ctx.skey, sizeof(ctx.skey)); struct mud *mud = mud_create(ctx.skey, sizeof(ctx.skey));
if (!mud) { if (!mud) {
gt_log("unable to crate the mud !!!\n"); gt_log("unable to create the mud !!!\n");
return 1; return 1;
} }
int fd1 = mud_bind(mud, host_bind, port); if (host_bind && mud_bind(mud, host_bind))
if (fd1==-1)
return 1; return 1;
int fdmax = fd1; if (host_bind2 && mud_bind(mud, host_bind2))
int fd2 = -1;
if (host_bind2) {
fd2 = mud_bind(mud, host_bind2, port);
fdmax = fd2;
if (fd2==-1)
return 1; return 1;
}
if (host_peer && mud_peer(mud, host_peer, port)) if (host_peer && mud_peer(mud, host_peer, port))
return 1; return 1;
int mud_fd = mud_get_fd(mud);
state("INITIALIZED", tun_name); state("INITIALIZED", tun_name);
struct packet *packet = NULL; struct packet *packet = NULL;
@@ -374,16 +366,13 @@ int main (int argc, char **argv)
while (!gt_close) { while (!gt_close) {
FD_SET(tun_fd, &rfds); FD_SET(tun_fd, &rfds);
FD_SET(fd1, &rfds); FD_SET(mud_fd, &rfds);
if (fd2!=-1)
FD_SET(fd2, &rfds);
struct timeval timeout = { struct timeval timeout = {
.tv_usec = 1000, .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) if (errno==EINTR)
continue; continue;
perror("select"); perror("select");
@@ -406,7 +395,7 @@ int main (int argc, char **argv)
mud_push(mud); mud_push(mud);
if (FD_ISSET(fd2, &rfds) || FD_ISSET(fd1, &rfds)) if (FD_ISSET(mud_fd, &rfds))
mud_pull(mud); mud_pull(mud);
while (1) { while (1) {