diff --git a/doc/proto_00000501.txt b/doc/proto_00000501.txt index 4b36685..5b7fc5d 100644 --- a/doc/proto_00000501.txt +++ b/doc/proto_00000501.txt @@ -54,10 +54,12 @@ Client sends: 5 bits coded as Base32 char, meaning userid 5 bits coded as Base32 char, with value 5 or 6, representing number of raw bits per encoded byte + CMC Server sends: Name of codec if accepted. After this all upstream data packets must be encoded with the new codec. BADCODEC if not accepted. Client must then revert to Base32 + BADLEN if length of query is too short Probe downstream fragment size: Client sends: diff --git a/src/iodine.c b/src/iodine.c index 407de6e..c658021 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -476,9 +476,14 @@ send_version(int fd, uint32_t version) static void send_ip_request(int fd, int userid) { - char buf[512] = "I_."; + char buf[512] = "I____."; buf[1] = b32_5to8(userid); + buf[2] = b32_5to8((rand_seed >> 10) & 0x1f); + buf[3] = b32_5to8((rand_seed >> 5) & 0x1f); + buf[4] = b32_5to8((rand_seed ) & 0x1f); + rand_seed++; + strncat(buf, topdomain, 512 - strlen(buf)); send_query(fd, buf); } @@ -498,10 +503,15 @@ send_case_check(int fd) static void send_codec_switch(int fd, int userid, int bits) { - char buf[512] = "S__."; + char buf[512] = "S_____."; buf[1] = b32_5to8(userid); buf[2] = b32_5to8(bits); + buf[3] = b32_5to8((rand_seed >> 10) & 0x1f); + buf[4] = b32_5to8((rand_seed >> 5) & 0x1f); + buf[5] = b32_5to8((rand_seed ) & 0x1f); + rand_seed++; + strncat(buf, topdomain, 512 - strlen(buf)); send_query(fd, buf); } diff --git a/src/iodined.c b/src/iodined.c index 5a92c20..3f06c29 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -425,7 +425,7 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len) } else if(in[0] == 'S' || in[0] == 's') { int codec; struct encoder *enc; - if (domain_len != 4) { /* len = 4, example: "S15." */ + if (domain_len < 3) { /* len at least 3, example: "S15" */ write_dns(dns_fd, q, "BADLEN", 6); return; }