1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-26 06:56:05 +03:00

Remove fastpolling, discard chunk on packetloss

This commit is contained in:
Erik Ekman 2006-06-06 11:55:21 +00:00
parent 4bcc25da64
commit 824f5fda90
2 changed files with 10 additions and 19 deletions

13
dns.c
View File

@ -42,6 +42,8 @@ int packetpos;
int packetlen; int packetlen;
uint16_t chunkid; uint16_t chunkid;
uint16_t pingid;
static int static int
readname(char *packet, char *dst, char *src) readname(char *packet, char *dst, char *src)
{ {
@ -137,6 +139,7 @@ open_dns(const char *host, const char *domain)
// Init chunk id // Init chunk id
chunkid = 0; chunkid = 0;
pingid = 0;
return fd; return fd;
} }
@ -181,12 +184,12 @@ void
dns_ping(int dns_fd) dns_ping(int dns_fd)
{ {
if (dns_sending()) { if (dns_sending()) {
// Resend latest chunk printf("No reply on chunk, discarding\n");
printf("No reply on chunk, resending\n"); lastlen = 0;
dns_send_chunk(dns_fd); packetpos = 0;
} else { packetlen = 0;
dns_write(dns_fd, 0, "", 0);
} }
dns_write(dns_fd, ++pingid, "", 0);
} }
void void

View File

@ -35,11 +35,6 @@
#define FRAMESIZE (64*1024) #define FRAMESIZE (64*1024)
#define POLL_MAX 4
static int poll_sec[] = {1, 0, 0, 0, 0};
static int poll_usec[] = {0, 400000, 200000, 100000, 50000};
int running = 1; int running = 1;
static void static void
@ -52,21 +47,15 @@ tunnel(int tun_fd, int dns_fd)
{ {
int i; int i;
int read; int read;
int fastpoll;
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
struct tun_frame *frame; struct tun_frame *frame;
frame = malloc(FRAMESIZE); frame = malloc(FRAMESIZE);
fastpoll = 0;
while (running) { while (running) {
if (fastpoll > 0) { tv.tv_sec = 1;
fastpoll--; tv.tv_usec = 0;
printf("Fast poll %d\n", fastpoll);
}
tv.tv_sec = poll_sec[fastpoll];
tv.tv_usec = poll_usec[fastpoll];
FD_ZERO(&fds); FD_ZERO(&fds);
if (!dns_sending()) if (!dns_sending())
@ -105,7 +94,6 @@ tunnel(int tun_fd, int dns_fd)
#endif #endif
write_tun(tun_fd, frame, read + 4); write_tun(tun_fd, frame, read + 4);
fastpoll = POLL_MAX;
} }
} }
} }