mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-24 00:59:19 +02:00
Moved two global vars into main
This commit is contained in:
parent
7de1455c96
commit
9dfc181307
38
src/iodine.c
38
src/iodine.c
|
@ -75,9 +75,6 @@ static int downstream_fragment;
|
||||||
static int down_ack_seqno;
|
static int down_ack_seqno;
|
||||||
static int down_ack_fragment;
|
static int down_ack_fragment;
|
||||||
|
|
||||||
static int max_downstream_frag_size;
|
|
||||||
static int autodetect_frag_size;
|
|
||||||
|
|
||||||
/* Current up/downstream IP packet */
|
/* Current up/downstream IP packet */
|
||||||
static struct packet outpkt;
|
static struct packet outpkt;
|
||||||
static struct packet inpkt;
|
static struct packet inpkt;
|
||||||
|
@ -749,10 +746,11 @@ handshake_autoprobe_fragsize(int dns_fd)
|
||||||
int read;
|
int read;
|
||||||
int proposed_fragsize = 768;
|
int proposed_fragsize = 768;
|
||||||
int range = 768;
|
int range = 768;
|
||||||
|
int max_fragsize = 0;
|
||||||
|
|
||||||
max_downstream_frag_size = 0;
|
max_fragsize = 0;
|
||||||
printf("Autoprobing max downstream fragment size... (skip with -m fragsize)\n");
|
printf("Autoprobing max downstream fragment size... (skip with -m fragsize)\n");
|
||||||
while (running && range > 0 && (range >= 8 || !max_downstream_frag_size)) {
|
while (running && range > 0 && (range >= 8 || !max_fragsize)) {
|
||||||
for (i=0; running && i<3 ;i++) {
|
for (i=0; running && i<3 ;i++) {
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
@ -773,7 +771,7 @@ handshake_autoprobe_fragsize(int dns_fd)
|
||||||
if (read == proposed_fragsize) {
|
if (read == proposed_fragsize) {
|
||||||
printf("%d ok.. ", acked_fragsize);
|
printf("%d ok.. ", acked_fragsize);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
max_downstream_frag_size = acked_fragsize;
|
max_fragsize = acked_fragsize;
|
||||||
range >>= 1;
|
range >>= 1;
|
||||||
proposed_fragsize += range;
|
proposed_fragsize += range;
|
||||||
continue;
|
continue;
|
||||||
|
@ -797,20 +795,20 @@ badlen:
|
||||||
if (!running) {
|
if (!running) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
warnx("stopped while autodetecting fragment size (Try probing manually with -m)");
|
warnx("stopped while autodetecting fragment size (Try probing manually with -m)");
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
if (range == 0) {
|
if (range == 0) {
|
||||||
/* Tried all the way down to 2 and found no good size */
|
/* Tried all the way down to 2 and found no good size */
|
||||||
printf("\n");
|
printf("\n");
|
||||||
warnx("found no accepted fragment size. (Try probing manually with -m)");
|
warnx("found no accepted fragment size. (Try probing manually with -m)");
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("will use %d\n", max_downstream_frag_size);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
printf("will use %d\n", max_fragsize);
|
||||||
|
return max_fragsize;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handshake_set_fragsize(int dns_fd)
|
handshake_set_fragsize(int dns_fd, int fragsize)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
char in[4096];
|
char in[4096];
|
||||||
|
@ -819,12 +817,12 @@ handshake_set_fragsize(int dns_fd)
|
||||||
int r;
|
int r;
|
||||||
int read;
|
int read;
|
||||||
|
|
||||||
printf("Setting downstream fragment size to max %d...\n", max_downstream_frag_size);
|
printf("Setting downstream fragment size to max %d...\n", fragsize);
|
||||||
for (i=0; running && i<5 ;i++) {
|
for (i=0; running && i<5 ;i++) {
|
||||||
tv.tv_sec = i + 1;
|
tv.tv_sec = i + 1;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
send_set_downstream_fragsize(dns_fd, max_downstream_frag_size);
|
send_set_downstream_fragsize(dns_fd, fragsize);
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(dns_fd, &fds);
|
FD_SET(dns_fd, &fds);
|
||||||
|
@ -855,7 +853,7 @@ handshake_set_fragsize(int dns_fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
handshake(int dns_fd)
|
handshake(int dns_fd, int autodetect_frag_size, int fragsize)
|
||||||
{
|
{
|
||||||
int seed;
|
int seed;
|
||||||
int r;
|
int r;
|
||||||
|
@ -877,13 +875,13 @@ handshake(int dns_fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autodetect_frag_size) {
|
if (autodetect_frag_size) {
|
||||||
r = handshake_autoprobe_fragsize(dns_fd);
|
fragsize = handshake_autoprobe_fragsize(dns_fd);
|
||||||
if (r) {
|
if (!fragsize) {
|
||||||
return r;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handshake_set_fragsize(dns_fd);
|
handshake_set_fragsize(dns_fd, fragsize);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -985,6 +983,8 @@ main(int argc, char **argv)
|
||||||
int choice;
|
int choice;
|
||||||
int tun_fd;
|
int tun_fd;
|
||||||
int dns_fd;
|
int dns_fd;
|
||||||
|
int max_downstream_frag_size;
|
||||||
|
int autodetect_frag_size;
|
||||||
|
|
||||||
memset(password, 0, 33);
|
memset(password, 0, 33);
|
||||||
username = NULL;
|
username = NULL;
|
||||||
|
@ -1113,7 +1113,7 @@ main(int argc, char **argv)
|
||||||
signal(SIGINT, sighandler);
|
signal(SIGINT, sighandler);
|
||||||
signal(SIGTERM, sighandler);
|
signal(SIGTERM, sighandler);
|
||||||
|
|
||||||
if(handshake(dns_fd))
|
if(handshake(dns_fd, autodetect_frag_size, max_downstream_frag_size))
|
||||||
goto cleanup2;
|
goto cleanup2;
|
||||||
|
|
||||||
printf("Sending queries for %s to %s\n", topdomain, nameserv_addr);
|
printf("Sending queries for %s to %s\n", topdomain, nameserv_addr);
|
||||||
|
|
Loading…
Reference in New Issue