mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-04 15:33:19 +00:00
Remove fastpolling, discard chunk on packetloss
This commit is contained in:
parent
4bcc25da64
commit
824f5fda90
13
dns.c
13
dns.c
|
@ -42,6 +42,8 @@ int packetpos;
|
|||
int packetlen;
|
||||
uint16_t chunkid;
|
||||
|
||||
uint16_t pingid;
|
||||
|
||||
static int
|
||||
readname(char *packet, char *dst, char *src)
|
||||
{
|
||||
|
@ -137,6 +139,7 @@ open_dns(const char *host, const char *domain)
|
|||
|
||||
// Init chunk id
|
||||
chunkid = 0;
|
||||
pingid = 0;
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
@ -181,12 +184,12 @@ void
|
|||
dns_ping(int dns_fd)
|
||||
{
|
||||
if (dns_sending()) {
|
||||
// Resend latest chunk
|
||||
printf("No reply on chunk, resending\n");
|
||||
dns_send_chunk(dns_fd);
|
||||
} else {
|
||||
dns_write(dns_fd, 0, "", 0);
|
||||
printf("No reply on chunk, discarding\n");
|
||||
lastlen = 0;
|
||||
packetpos = 0;
|
||||
packetlen = 0;
|
||||
}
|
||||
dns_write(dns_fd, ++pingid, "", 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
16
dnstun.c
16
dnstun.c
|
@ -35,11 +35,6 @@
|
|||
|
||||
#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;
|
||||
|
||||
static void
|
||||
|
@ -52,21 +47,15 @@ tunnel(int tun_fd, int dns_fd)
|
|||
{
|
||||
int i;
|
||||
int read;
|
||||
int fastpoll;
|
||||
fd_set fds;
|
||||
struct timeval tv;
|
||||
struct tun_frame *frame;
|
||||
|
||||
frame = malloc(FRAMESIZE);
|
||||
fastpoll = 0;
|
||||
|
||||
while (running) {
|
||||
if (fastpoll > 0) {
|
||||
fastpoll--;
|
||||
printf("Fast poll %d\n", fastpoll);
|
||||
}
|
||||
tv.tv_sec = poll_sec[fastpoll];
|
||||
tv.tv_usec = poll_usec[fastpoll];
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
if (!dns_sending())
|
||||
|
@ -105,7 +94,6 @@ tunnel(int tun_fd, int dns_fd)
|
|||
#endif
|
||||
|
||||
write_tun(tun_fd, frame, read + 4);
|
||||
fastpoll = POLL_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue