From b6fdf354441ec55e345e323195cbc923b657e094 Mon Sep 17 00:00:00 2001 From: Julian Kranz Date: Fri, 27 Jan 2012 14:19:00 +0100 Subject: [PATCH] Iodine: IPv6 --- src/client.c | 8 +++++++- src/client.h | 1 + src/iodine.c | 23 ++++++++++++++++------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/client.c b/src/client.c index fcf458d..a43b0bb 100644 --- a/src/client.c +++ b/src/client.c @@ -73,7 +73,7 @@ static uint16_t rand_seed; #ifdef LINUX static char _v6; -static char _v6_connect = 1; +static char _v6_connect; #endif /* Current up/downstream IP packet */ @@ -318,6 +318,12 @@ client_set_v6(char v6) { _v6 = v6; } + +void +client_set_v6_connect(char v6_connect) +{ + _v6_connect = v6_connect; +} #endif const char * diff --git a/src/client.h b/src/client.h index 8f3c272..249efab 100644 --- a/src/client.h +++ b/src/client.h @@ -35,6 +35,7 @@ void client_set_lazymode(int lazy_mode); void client_set_hostname_maxlen(int i); #ifdef LINUX void client_set_v6(char v6); +void client_set_v6_connect(char v6); #endif int client_handshake(int dns_fd, int raw_mode, int autodetect_frag_size, int fragsize); diff --git a/src/iodine.c b/src/iodine.c index f3cbc3c..e0e34ce 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -63,7 +63,7 @@ usage() { #ifdef LINUX fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] " - "[-P password] [-6] [-m maxfragsize] [-M maxlen] [-T type] [-O enc] [-L 0|1] [-I sec] " + "[-P password] [-6] [-7] [-m maxfragsize] [-M maxlen] [-T type] [-O enc] [-L 0|1] [-I sec] " "[-z context] [-F pidfile] [nameserver] topdomain\n", __progname); #else fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] " @@ -80,7 +80,7 @@ help() { fprintf(stderr, "iodine IP over DNS tunneling client\n"); #ifdef LINUX fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] " - "[-P password] [-6] [-m maxfragsize] [-M maxlen] [-T type] [-O enc] [-L 0|1] [-I sec] " + "[-P password] [-6] [-7] [-m maxfragsize] [-M maxlen] [-T type] [-O enc] [-L 0|1] [-I sec] " "[-z context] [-F pidfile] [nameserver] topdomain\n", __progname); #else fprintf(stderr, "Usage: %s [-v] [-h] [-f] [-r] [-u user] [-t chrootdir] [-d device] " @@ -99,6 +99,7 @@ help() { fprintf(stderr, " -P password used for authentication (max 32 chars will be used)\n"); #ifdef LINUX fprintf(stderr, " -6 use IPv6 (make sure to use this option consistently on client and server)\n"); + fprintf(stderr, " -7 enable IPv6 outside the tunnel\n"); #endif fprintf(stderr, "Other options:\n"); fprintf(stderr, " -v to print version info and exit\n"); @@ -154,6 +155,7 @@ main(int argc, char **argv) int hostname_maxlen; #ifdef LINUX char v6; + char v6_connect; #endif int rtable = 0; @@ -181,6 +183,7 @@ main(int argc, char **argv) #ifdef LINUX v6 = 0; + v6_connect = 0; #endif #ifdef WINDOWS32 @@ -199,7 +202,7 @@ main(int argc, char **argv) #endif #ifdef LINUX - while ((choice = getopt(argc, argv, "6vfhru:t:d:R:P:m:M:F:T:O:L:I:")) != -1) { + while ((choice = getopt(argc, argv, "67vfhru:t:d:R:P:m:M:F:T:O:L:I:")) != -1) { #else while ((choice = getopt(argc, argv, "vfhru:t:d:R:P:m:M:F:T:O:L:I:")) != -1) { #endif @@ -277,6 +280,9 @@ main(int argc, char **argv) case '6': v6 = 1; break; + case '7': + v6_connect = 1; + break; #endif default: usage(); @@ -335,6 +341,7 @@ main(int argc, char **argv) client_set_hostname_maxlen(hostname_maxlen); #ifdef LINUX client_set_v6(v6); + client_set_v6_connect(v6_connect); #endif if (username != NULL) { @@ -361,14 +368,16 @@ main(int argc, char **argv) goto cleanup1; } - /** - * Todo: Fix - */ + // if ((dns_fd = open_dns(0, INADDR_ANY)) == -1) { // retval = 1; // goto cleanup2; // } - if ((dns_fd = open_dns_ipv6(0, in6addr_any)) == -1) { +#ifdef LINUX + if ((dns_fd = v6_connect ? open_dns_ipv6(0, in6addr_any) : open_dns(0, INADDR_ANY)) == -1) { +#else + if ((dns_fd = open_dns(0, INADDR_ANY)) == -1) { +#endif retval = 1; goto cleanup2; }