From 1feacfada324334ae536cd0b26d5c1b609c9c487 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Tue, 11 Jul 2006 08:54:05 +0000 Subject: [PATCH] Release 0.3.1 --- CHANGELOG | 18 ++++++++++++++++++ README | 7 ++++--- dns.c | 25 +++++++++++++------------ iodine.c | 2 +- iodined.c | 2 +- tun.c | 40 +++++++++++++++++++++++----------------- 6 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 CHANGELOG diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..5fae2b5 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,18 @@ + +iodine - IP over DNS is now easy + + http://code.kryo.se/iodine + +******************************** + +CHANGES: + +2006-07-11: 0.3.1 + - Add Mac OSX support + - Add setting device name + - Use compression of domain name in reply (should allow setting MTU + approx 200 bytes higher) + +2006-06-24: 0.3.0 + - First public release + - Support for Linux, FreeBSD, OpenBSD diff --git a/README b/README index 485086e..077c511 100644 --- a/README +++ b/README @@ -61,9 +61,10 @@ possible to allow maximum throughput. PORTABILITY: -iodine has been tested on Linux (x86 and SPARC64), FreeBSD (x86) and -OpenBSD (x86). It should work on other unix-like systems as well that has -TUN/TAP tunneling support. Let us know if you get it to run on other platforms. +iodine has been tested on Linux (x86 and SPARC64), FreeBSD (x86), OpenBSD (x86) +and MacOS X (10.3, ppc, with http://www-user.rhrk.uni-kl.de/~nissler/tuntap/). +It should work on other unix-like systems as well that has TUN/TAP tunneling +support. Let us know if you get it to run on other platforms. THE NAME: diff --git a/dns.c b/dns.c index 0d7d1f3..2cf04ab 100644 --- a/dns.c +++ b/dns.c @@ -19,11 +19,15 @@ #include #include #include +#ifdef DARWIN +#include +#endif #include #include #include #include #include +#include #include #include #include @@ -352,7 +356,6 @@ dns_read(int fd, char *buf, int buflen) return 0; } - static int host2dns(const char *host, char *buffer, int size) { @@ -386,6 +389,7 @@ dnsd_send(int fd, struct query *q, char *data, int datalen) int len; char *p; char buf[64*1024]; + short name; HEADER *header; memset(buf, 0, sizeof(buf)); @@ -406,24 +410,21 @@ dnsd_send(int fd, struct query *q, char *data, int datalen) p = buf + sizeof(HEADER); + name = 0xc000 | ((p - buf) & 0x3fff); p += host2dns(q->name, p, strlen(q->name)); PUTSHORT(q->type, p); PUTSHORT(C_IN, p); - p += host2dns(q->name, p, strlen(q->name)); + PUTSHORT(name, p); PUTSHORT(q->type, p); PUTSHORT(C_IN, p); PUTLONG(0, p); q->id = 0; - if(datalen > 0) { - PUTSHORT(datalen, p); - memcpy(p, data, datalen); - p += datalen; - } else { - PUTSHORT(0, p); - } + PUTSHORT(datalen, p); + memcpy(p, data, datalen); + p += datalen; len = p - buf; sendto(fd, buf, len, 0, (struct sockaddr*)&q->from, q->fromlen); @@ -481,9 +482,7 @@ dnsd_read(int fd, struct query *q, char *buf, int buflen) addrlen = sizeof(struct sockaddr); r = recvfrom(fd, packet, sizeof(packet), 0, (struct sockaddr*)&from, &addrlen); - if(r == -1) { - perror("recvfrom"); - } else { + if (r >= sizeof(HEADER)) { header = (HEADER*)packet; id = ntohs(header->id); @@ -508,6 +507,8 @@ dnsd_read(int fd, struct query *q, char *buf, int buflen) return decodepacket(name, buf, buflen); } } + } else { + perror("recvfrom"); } return 0; diff --git a/iodine.c b/iodine.c index 8ea5c19..a8241c3 100644 --- a/iodine.c +++ b/iodine.c @@ -188,7 +188,7 @@ help() { static void version() { printf("iodine IP over DNS tunneling client\n"); - printf("version: 0.3\n"); + printf("version: 0.3.1 from 2006-07-11\n"); exit(0); } diff --git a/iodined.c b/iodined.c index 7a7b231..a4b0d41 100644 --- a/iodined.c +++ b/iodined.c @@ -188,7 +188,7 @@ help() { static void version() { printf("iodine IP over DNS tunneling server\n"); - printf("version: 0.3\n"); + printf("version: 0.3.1 from 2006-07-11\n"); exit(0); } diff --git a/tun.c b/tun.c index c97aee3..d22f950 100644 --- a/tun.c +++ b/tun.c @@ -57,18 +57,18 @@ open_tun(const char *tun_device) ifreq.ifr_flags = IFF_TUN; if (tun_device != NULL) { - strncpy(ifreq.ifr_name, tun_device, IFNAMSIZ); - strncpy(if_name, tun_device, sizeof(if_name)); + strncpy(ifreq.ifr_name, tun_device, IFNAMSIZ); + strncpy(if_name, tun_device, sizeof(if_name)); - if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) { - printf("Opened %s\n", ifreq.ifr_name); - return tun_fd; - } + if (ioctl(tun_fd, TUNSETIFF, (void *) &ifreq) != -1) { + printf("Opened %s\n", ifreq.ifr_name); + return tun_fd; + } - if (errno != EBUSY) { - warn("open_tun: ioctl[TUNSETIFF]: %s", strerror(errno)); - return -1; - } + if (errno != EBUSY) { + warn("open_tun: ioctl[TUNSETIFF]: %s", strerror(errno)); + return -1; + } } else { for (i = 0; i < TUN_MAX_TRY; i++) { snprintf(ifreq.ifr_name, IFNAMSIZ, "dns%d", i); @@ -85,7 +85,7 @@ open_tun(const char *tun_device) } } - warn("open_tun: Couldn't set interface name.\n"); + warn("open_tun: Couldn't set interface name"); } return -1; } @@ -100,10 +100,16 @@ open_tun(const char *tun_device) char tun_name[50]; if (tun_device != NULL) { - if ((tun_fd = open(tun_device, O_RDWR)) < 0) { - warn("open_tun: %s: %s", tun_device, strerror(errno)); + snprintf(tun_name, sizeof(tun_name), "/dev/%s", tun_device); + strncpy(if_name, tun_device, sizeof(if_name)); + + if ((tun_fd = open(tun_name, O_RDWR)) < 0) { + warn("open_tun: %s: %s", tun_name, strerror(errno)); return -1; } + + printf("Opened %s\n", tun_name); + return tun_fd; } else { for (i = 0; i < TUN_MAX_TRY; i++) { snprintf(tun_name, sizeof(tun_name), "/dev/tun%d", i); @@ -118,7 +124,7 @@ open_tun(const char *tun_device) break; } - warn("open_tun: Failed to open tunneling device."); + warn("open_tun: Failed to open tunneling device"); } return -1; @@ -136,10 +142,10 @@ close_tun(int tun_fd) int write_tun(int tun_fd, char *data, int len) { -#ifdef FREEBSD +#if defined (FREEBSD) || defined (DARWIN) data += 4; len -= 4; -#else /* !FREEBSD */ +#else /* !FREEBSD/DARWIN */ #ifdef LINUX data[0] = 0x00; data[1] = 0x00; @@ -163,7 +169,7 @@ write_tun(int tun_fd, char *data, int len) int read_tun(int tun_fd, char *buf, int len) { -#ifdef FREEBSD +#if defined (FREEBSD) || defined (DARWIN) // FreeBSD has no header return read(tun_fd, buf + 4, len - 4) + 4; #else /* !FREEBSD */