diff --git a/iodine.c b/iodine.c index 5a54912..7bc7b40 100644 --- a/iodine.c +++ b/iodine.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -120,7 +121,7 @@ handshake(int dns_fd) timeout = 1; - for (i=0;i<5;i++) { + for (i=0; running && i<5 ;i++) { tv.tv_sec = timeout++; tv.tv_usec = 0; @@ -139,18 +140,17 @@ handshake(int dns_fd) continue; } - if (read == 0) - continue; + if (read > 0) { + p = strchr(in, '-'); + if (p) { + *p++ = '\0'; + mtu = atoi(p); - p = strchr(in, '-'); - if (p) { - *p++ = '\0'; - mtu = atoi(p); - - printf("%s %d\n", in, mtu); - - if (tun_setip(in) == 0 && tun_setmtu(atoi(p)) == 0) - return 0; + if (tun_setip(in) == 0 && tun_setmtu(atoi(p)) == 0) + return 0; + else + warn("Received handshake but b0rk"); + } } } diff --git a/iodined.c b/iodined.c index e49fcc3..439d1e2 100644 --- a/iodined.c +++ b/iodined.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/structs.h b/structs.h index 89762c7..2cec05c 100644 --- a/structs.h +++ b/structs.h @@ -28,7 +28,7 @@ struct query { char name[256]; short type; short id; - struct sockaddr_in from; + struct sockaddr from; int fromlen; };