From 30fe7dbc06c87fd11cc30ff6e4c4179b20070b98 Mon Sep 17 00:00:00 2001 From: Julian Kranz Date: Sat, 7 Jan 2012 02:38:47 +0100 Subject: [PATCH] Iodine: Fixed network protocol version --- src/client.c | 17 +++++++++++++++-- src/iodined.c | 11 ++++++++++- src/version.h | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index 86e1e3b..6632cfa 100644 --- a/src/client.c +++ b/src/client.c @@ -1473,7 +1473,12 @@ handshake_version(int dns_fd, int *seed) for (i = 0; running && i < 5; i++) { - send_version(dns_fd, VERSION); +#ifdef LINUX + if(_v6) + send_version(dns_fd, VERSION_V6); + else +#endif + send_version(dns_fd, VERSION); read = handshake_waitdns(dns_fd, in, sizeof(in), 'v', 'V', i+1); @@ -1493,7 +1498,15 @@ handshake_version(int dns_fd, int *seed) fprintf(stderr, "Version ok, both using protocol v 0x%08x. You are user #%d\n", VERSION, userid); return 0; } else if (strncmp("VNAK", in, 4) == 0) { - warnx("You use protocol v 0x%08x, server uses v 0x%08x. Giving up", +#ifdef LINUX + if (_v6) + warnx( + "You use protocol v 0x%08x, server uses v 0x%08x. Giving up", + VERSION_V6, payload); + else +#endif + warnx( + "You use protocol v 0x%08x, server uses v 0x%08x. Giving up", VERSION, payload); return 1; } else if (strncmp("VFUL", in, 4) == 0) { diff --git a/src/iodined.c b/src/iodined.c index f72933d..627fa0f 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -726,7 +726,11 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len) ((unpacked[3] & 0xff))); } +#ifdef LINUX + if (version == v6 ? VERSION_V6 : VERSION) { +#else if (version == VERSION) { +#endif userid = find_available_user(); if (userid >= 0) { int i; @@ -787,7 +791,12 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len) inet_ntoa(((struct sockaddr_in *) &q->from)->sin_addr)); } } else { - send_version_response(dns_fd, VERSION_NACK, VERSION, 0, q); +#ifdef LINUX + if (v6) + send_version_response(dns_fd, VERSION_NACK, VERSION_V6, 0, q); + else +#endif + send_version_response(dns_fd, VERSION_NACK, VERSION, 0, q); syslog(LOG_INFO, "dropped user from %s, sent bad version %08X", inet_ntoa(((struct sockaddr_in *) &q->from)->sin_addr), version); } diff --git a/src/version.h b/src/version.h index 1561b9e..623ac54 100644 --- a/src/version.h +++ b/src/version.h @@ -20,6 +20,7 @@ /* This is the version of the network protocol It is usually equal to the latest iodine version number */ #define VERSION 0x00000502 +#define VERSION_V6 0x00000503 #endif /* _VERSION_H_ */