mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-22 16:19:20 +02:00
Adjust indentation
This commit is contained in:
parent
24241666fa
commit
45a5d80c49
294
src/client.c
294
src/client.c
|
@ -1458,32 +1458,30 @@ handshake_version(int dns_fd, int *seed)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'v', 'V', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'v', 'V', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read >= 9) {
|
||||||
if (read >= 9) {
|
payload = (((in[4] & 0xff) << 24) |
|
||||||
payload = (((in[4] & 0xff) << 24) |
|
((in[5] & 0xff) << 16) |
|
||||||
((in[5] & 0xff) << 16) |
|
((in[6] & 0xff) << 8) |
|
||||||
((in[6] & 0xff) << 8) |
|
((in[7] & 0xff)));
|
||||||
((in[7] & 0xff)));
|
|
||||||
|
|
||||||
if (strncmp("VACK", in, 4) == 0) {
|
if (strncmp("VACK", in, 4) == 0) {
|
||||||
*seed = payload;
|
*seed = payload;
|
||||||
userid = in[8];
|
userid = in[8];
|
||||||
userid_char = hex[userid & 15];
|
userid_char = hex[userid & 15];
|
||||||
userid_char2 = hex2[userid & 15];
|
userid_char2 = hex2[userid & 15];
|
||||||
|
|
||||||
fprintf(stderr, "Version ok, both using protocol v 0x%08x. You are user #%d\n", VERSION, userid);
|
fprintf(stderr, "Version ok, both using protocol v 0x%08x. You are user #%d\n", VERSION, userid);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (strncmp("VNAK", in, 4) == 0) {
|
} else if (strncmp("VNAK", in, 4) == 0) {
|
||||||
warnx("You use protocol v 0x%08x, server uses v 0x%08x. Giving up",
|
warnx("You use protocol v 0x%08x, server uses v 0x%08x. Giving up",
|
||||||
VERSION, payload);
|
VERSION, payload);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (strncmp("VFUL", in, 4) == 0) {
|
} else if (strncmp("VFUL", in, 4) == 0) {
|
||||||
warnx("Server full, all %d slots are taken. Try again later", payload);
|
warnx("Server full, all %d slots are taken. Try again later", payload);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (read > 0)
|
} else if (read > 0)
|
||||||
warnx("did not receive proper login challenge");
|
warnx("did not receive proper login challenge");
|
||||||
/*XXX END adjust indent 1 tab back*/
|
|
||||||
|
|
||||||
fprintf(stderr, "Retrying version check...\n");
|
fprintf(stderr, "Retrying version check...\n");
|
||||||
}
|
}
|
||||||
|
@ -1510,30 +1508,28 @@ handshake_login(int dns_fd, int seed)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'l', 'L', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'l', 'L', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
int netmask;
|
||||||
int netmask;
|
if (strncmp("LNAK", in, 4) == 0) {
|
||||||
if (strncmp("LNAK", in, 4) == 0) {
|
fprintf(stderr, "Bad password\n");
|
||||||
fprintf(stderr, "Bad password\n");
|
return 1;
|
||||||
return 1;
|
} else if (sscanf(in, "%64[^-]-%64[^-]-%d-%d",
|
||||||
} else if (sscanf(in, "%64[^-]-%64[^-]-%d-%d",
|
server, client, &mtu, &netmask) == 4) {
|
||||||
server, client, &mtu, &netmask) == 4) {
|
|
||||||
|
|
||||||
server[64] = 0;
|
|
||||||
client[64] = 0;
|
|
||||||
if (tun_setip(client, server, netmask) == 0 &&
|
|
||||||
tun_setmtu(mtu) == 0) {
|
|
||||||
|
|
||||||
fprintf(stderr, "Server tunnel IP is %s\n", server);
|
server[64] = 0;
|
||||||
return 0;
|
client[64] = 0;
|
||||||
} else {
|
if (tun_setip(client, server, netmask) == 0 &&
|
||||||
errx(4, "Failed to set IP and MTU");
|
tun_setmtu(mtu) == 0) {
|
||||||
}
|
|
||||||
|
fprintf(stderr, "Server tunnel IP is %s\n", server);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Received bad handshake\n");
|
errx(4, "Failed to set IP and MTU");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Received bad handshake\n");
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Retrying login...\n");
|
fprintf(stderr, "Retrying login...\n");
|
||||||
}
|
}
|
||||||
|
@ -1560,20 +1556,18 @@ handshake_raw_udp(int dns_fd, int seed)
|
||||||
|
|
||||||
len = handshake_waitdns(dns_fd, in, sizeof(in), 'i', 'I', i+1);
|
len = handshake_waitdns(dns_fd, in, sizeof(in), 'i', 'I', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (len == 5 && in[0] == 'I') {
|
||||||
if (len == 5 && in[0] == 'I') {
|
/* Received IP address */
|
||||||
/* Received IP address */
|
remoteaddr = (in[1] & 0xff);
|
||||||
remoteaddr = (in[1] & 0xff);
|
remoteaddr <<= 8;
|
||||||
remoteaddr <<= 8;
|
remoteaddr |= (in[2] & 0xff);
|
||||||
remoteaddr |= (in[2] & 0xff);
|
remoteaddr <<= 8;
|
||||||
remoteaddr <<= 8;
|
remoteaddr |= (in[3] & 0xff);
|
||||||
remoteaddr |= (in[3] & 0xff);
|
remoteaddr <<= 8;
|
||||||
remoteaddr <<= 8;
|
remoteaddr |= (in[4] & 0xff);
|
||||||
remoteaddr |= (in[4] & 0xff);
|
server.s_addr = ntohl(remoteaddr);
|
||||||
server.s_addr = ntohl(remoteaddr);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
/*XXX END adjust indent 1 tab back*/
|
|
||||||
|
|
||||||
fprintf(stderr, ".");
|
fprintf(stderr, ".");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
@ -2098,24 +2092,22 @@ handshake_switch_codec(int dns_fd, int bits)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 's', 'S', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 's', 'S', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
if (strncmp("BADLEN", in, 6) == 0) {
|
||||||
if (strncmp("BADLEN", in, 6) == 0) {
|
fprintf(stderr, "Server got bad message length. ");
|
||||||
fprintf(stderr, "Server got bad message length. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADIP", in, 5) == 0) {
|
||||||
} else if (strncmp("BADIP", in, 5) == 0) {
|
fprintf(stderr, "Server rejected sender IP address. ");
|
||||||
fprintf(stderr, "Server rejected sender IP address. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
||||||
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
fprintf(stderr, "Server rejected the selected codec. ");
|
||||||
fprintf(stderr, "Server rejected the selected codec. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
|
||||||
}
|
|
||||||
in[read] = 0; /* zero terminate */
|
|
||||||
fprintf(stderr, "Server switched upstream to codec %s\n", in);
|
|
||||||
dataenc = tempenc;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
in[read] = 0; /* zero terminate */
|
||||||
|
fprintf(stderr, "Server switched upstream to codec %s\n", in);
|
||||||
|
dataenc = tempenc;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Retrying codec switch...\n");
|
fprintf(stderr, "Retrying codec switch...\n");
|
||||||
}
|
}
|
||||||
|
@ -2153,23 +2145,21 @@ handshake_switch_downenc(int dns_fd)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
if (strncmp("BADLEN", in, 6) == 0) {
|
||||||
if (strncmp("BADLEN", in, 6) == 0) {
|
fprintf(stderr, "Server got bad message length. ");
|
||||||
fprintf(stderr, "Server got bad message length. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADIP", in, 5) == 0) {
|
||||||
} else if (strncmp("BADIP", in, 5) == 0) {
|
fprintf(stderr, "Server rejected sender IP address. ");
|
||||||
fprintf(stderr, "Server rejected sender IP address. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
||||||
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
fprintf(stderr, "Server rejected the selected codec. ");
|
||||||
fprintf(stderr, "Server rejected the selected codec. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
|
||||||
}
|
|
||||||
in[read] = 0; /* zero terminate */
|
|
||||||
fprintf(stderr, "Server switched downstream to codec %s\n", in);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
in[read] = 0; /* zero terminate */
|
||||||
|
fprintf(stderr, "Server switched downstream to codec %s\n", in);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Retrying codec switch...\n");
|
fprintf(stderr, "Retrying codec switch...\n");
|
||||||
}
|
}
|
||||||
|
@ -2196,24 +2186,22 @@ handshake_try_lazy(int dns_fd)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
if (strncmp("BADLEN", in, 6) == 0) {
|
||||||
if (strncmp("BADLEN", in, 6) == 0) {
|
fprintf(stderr, "Server got bad message length. ");
|
||||||
fprintf(stderr, "Server got bad message length. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADIP", in, 5) == 0) {
|
||||||
} else if (strncmp("BADIP", in, 5) == 0) {
|
fprintf(stderr, "Server rejected sender IP address. ");
|
||||||
fprintf(stderr, "Server rejected sender IP address. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
||||||
} else if (strncmp("BADCODEC", in, 8) == 0) {
|
fprintf(stderr, "Server rejected lazy mode. ");
|
||||||
fprintf(stderr, "Server rejected lazy mode. ");
|
goto codec_revert;
|
||||||
goto codec_revert;
|
} else if (strncmp("Lazy", in, 4) == 0) {
|
||||||
} else if (strncmp("Lazy", in, 4) == 0) {
|
fprintf(stderr, "Server switched to lazy mode\n");
|
||||||
fprintf(stderr, "Server switched to lazy mode\n");
|
lazymode = 1;
|
||||||
lazymode = 1;
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Retrying lazy mode switch...\n");
|
fprintf(stderr, "Retrying lazy mode switch...\n");
|
||||||
}
|
}
|
||||||
|
@ -2242,14 +2230,12 @@ handshake_lazyoff(int dns_fd)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', 1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'o', 'O', 1);
|
||||||
|
|
||||||
/*XXX START adjust indent 2 tabs back*/
|
if (read == 9 && strncmp("Immediate", in, 9) == 0) {
|
||||||
if (read == 9 && strncmp("Immediate", in, 9) == 0) {
|
warnx("Server switched back to legacy mode.\n");
|
||||||
warnx("Server switched back to legacy mode.\n");
|
lazymode = 0;
|
||||||
lazymode = 0;
|
selecttimeout = 1;
|
||||||
selecttimeout = 1;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
/*XXX END adjust indent 2 tabs back*/
|
|
||||||
}
|
}
|
||||||
if (!running)
|
if (!running)
|
||||||
return;
|
return;
|
||||||
|
@ -2304,28 +2290,26 @@ fragsize_check(char *in, int read, int proposed_fragsize, int *max_fragsize)
|
||||||
okay = 1;
|
okay = 1;
|
||||||
v = in[3] & 0xff;
|
v = in[3] & 0xff;
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
for (i = 3; i < read; i++, v = (v + 107) & 0xff)
|
||||||
for (i = 3; i < read; i++, v = (v + 107) & 0xff)
|
if ((in[i] & 0xff) != v) {
|
||||||
if ((in[i] & 0xff) != v) {
|
okay = 0;
|
||||||
okay = 0;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (okay) {
|
|
||||||
fprintf(stderr, "%d ok.. ", acked_fragsize);
|
|
||||||
fflush(stderr);
|
|
||||||
*max_fragsize = acked_fragsize;
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
if (downenc != ' ' && downenc != 'T') {
|
|
||||||
fprintf(stderr, "%d corrupted at %d.. (Try -O Base32)\n", acked_fragsize, i);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "%d corrupted at %d.. ", acked_fragsize, i);
|
|
||||||
}
|
|
||||||
fflush(stderr);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
|
||||||
|
if (okay) {
|
||||||
|
fprintf(stderr, "%d ok.. ", acked_fragsize);
|
||||||
|
fflush(stderr);
|
||||||
|
*max_fragsize = acked_fragsize;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if (downenc != ' ' && downenc != 'T') {
|
||||||
|
fprintf(stderr, "%d corrupted at %d.. (Try -O Base32)\n", acked_fragsize, i);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%d corrupted at %d.. ", acked_fragsize, i);
|
||||||
|
}
|
||||||
|
fflush(stderr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* notreached */
|
/* notreached */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2352,13 +2336,11 @@ handshake_autoprobe_fragsize(int dns_fd)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'r', 'R', 1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'r', 'R', 1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
/* We got a reply */
|
||||||
/* We got a reply */
|
if (fragsize_check(in, read, proposed_fragsize, &max_fragsize) == 1)
|
||||||
if (fragsize_check(in, read, proposed_fragsize, &max_fragsize) == 1)
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
/*XXX END adjust indent 1 tab back*/
|
|
||||||
|
|
||||||
fprintf(stderr, ".");
|
fprintf(stderr, ".");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
@ -2422,22 +2404,20 @@ handshake_set_fragsize(int dns_fd, int fragsize)
|
||||||
|
|
||||||
read = handshake_waitdns(dns_fd, in, sizeof(in), 'n', 'N', i+1);
|
read = handshake_waitdns(dns_fd, in, sizeof(in), 'n', 'N', i+1);
|
||||||
|
|
||||||
/*XXX START adjust indent 1 tab back*/
|
if (read > 0) {
|
||||||
if (read > 0) {
|
int accepted_fragsize;
|
||||||
int accepted_fragsize;
|
|
||||||
|
|
||||||
if (strncmp("BADFRAG", in, 7) == 0) {
|
if (strncmp("BADFRAG", in, 7) == 0) {
|
||||||
fprintf(stderr, "Server rejected fragsize. Keeping default.");
|
fprintf(stderr, "Server rejected fragsize. Keeping default.");
|
||||||
return;
|
return;
|
||||||
} else if (strncmp("BADIP", in, 5) == 0) {
|
} else if (strncmp("BADIP", in, 5) == 0) {
|
||||||
fprintf(stderr, "Server rejected sender IP address.\n");
|
fprintf(stderr, "Server rejected sender IP address.\n");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accepted_fragsize = ((in[0] & 0xff) << 8) | (in[1] & 0xff);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*XXX END adjust indent 1 tab back*/
|
|
||||||
|
accepted_fragsize = ((in[0] & 0xff) << 8) | (in[1] & 0xff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Retrying set fragsize...\n");
|
fprintf(stderr, "Retrying set fragsize...\n");
|
||||||
}
|
}
|
||||||
|
|
16
src/dns.c
16
src/dns.c
|
@ -207,15 +207,13 @@ dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_
|
||||||
(even CNAME/A/MX, 255+255+header would be >512) */
|
(even CNAME/A/MX, 255+255+header would be >512) */
|
||||||
if (dnsc_use_edns0) {
|
if (dnsc_use_edns0) {
|
||||||
header->arcount = htons(1);
|
header->arcount = htons(1);
|
||||||
/*XXX START adjust indent 1 tab forward*/
|
CHECKLEN(11);
|
||||||
CHECKLEN(11);
|
putbyte(&p, 0x00); /* Root */
|
||||||
putbyte(&p, 0x00); /* Root */
|
putshort(&p, 0x0029); /* OPT */
|
||||||
putshort(&p, 0x0029); /* OPT */
|
putshort(&p, 0x1000); /* Payload size: 4096 */
|
||||||
putshort(&p, 0x1000); /* Payload size: 4096 */
|
putshort(&p, 0x0000); /* Higher bits/edns version */
|
||||||
putshort(&p, 0x0000); /* Higher bits/edns version */
|
putshort(&p, 0x8000); /* Z */
|
||||||
putshort(&p, 0x8000); /* Z */
|
putshort(&p, 0x0000); /* Data length */
|
||||||
putshort(&p, 0x0000); /* Data length */
|
|
||||||
/*XXX END adjust indent 1 tab forward*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1742,31 +1742,29 @@ handle_full_packet(int tun_fd, int dns_fd, int userid)
|
||||||
write_tun(tun_fd, out, outlen);
|
write_tun(tun_fd, out, outlen);
|
||||||
} else {
|
} else {
|
||||||
/* send the compressed(!) packet to other client */
|
/* send the compressed(!) packet to other client */
|
||||||
/*XXX START adjust indent 1 tab forward*/
|
if (users[touser].conn == CONN_DNS_NULL) {
|
||||||
if (users[touser].conn == CONN_DNS_NULL) {
|
if (users[touser].outpacket.len == 0) {
|
||||||
if (users[touser].outpacket.len == 0) {
|
start_new_outpacket(touser,
|
||||||
start_new_outpacket(touser,
|
users[userid].inpacket.data,
|
||||||
users[userid].inpacket.data,
|
users[userid].inpacket.len);
|
||||||
users[userid].inpacket.len);
|
|
||||||
|
|
||||||
/* Start sending immediately if query is waiting */
|
/* Start sending immediately if query is waiting */
|
||||||
if (users[touser].q_sendrealsoon.id != 0)
|
if (users[touser].q_sendrealsoon.id != 0)
|
||||||
send_chunk_or_dataless(dns_fd, touser, &users[touser].q_sendrealsoon);
|
send_chunk_or_dataless(dns_fd, touser, &users[touser].q_sendrealsoon);
|
||||||
else if (users[touser].q.id != 0)
|
else if (users[touser].q.id != 0)
|
||||||
send_chunk_or_dataless(dns_fd, touser, &users[touser].q);
|
send_chunk_or_dataless(dns_fd, touser, &users[touser].q);
|
||||||
#ifdef OUTPACKETQ_LEN
|
#ifdef OUTPACKETQ_LEN
|
||||||
} else {
|
} else {
|
||||||
save_to_outpacketq(touser,
|
save_to_outpacketq(touser,
|
||||||
users[userid].inpacket.data,
|
users[userid].inpacket.data,
|
||||||
users[userid].inpacket.len);
|
users[userid].inpacket.len);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
} else{ /* CONN_RAW_UDP */
|
||||||
|
send_raw(dns_fd, users[userid].inpacket.data,
|
||||||
|
users[userid].inpacket.len, touser,
|
||||||
|
RAW_HDR_CMD_DATA, &users[touser].q);
|
||||||
}
|
}
|
||||||
} else{ /* CONN_RAW_UDP */
|
|
||||||
send_raw(dns_fd, users[userid].inpacket.data,
|
|
||||||
users[userid].inpacket.len, touser,
|
|
||||||
RAW_HDR_CMD_DATA, &users[touser].q);
|
|
||||||
}
|
|
||||||
/*XXX END adjust indent 1 tab forward*/
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (debug >= 1)
|
if (debug >= 1)
|
||||||
|
|
Loading…
Reference in New Issue