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

#11 routing between clients implemented. clients need to poll more often to get reasonable packetloss due to no queue

This commit is contained in:
Erik Ekman 2007-02-11 16:39:09 +00:00
parent 3341f3c268
commit 76ec4ab895

View File

@ -129,12 +129,14 @@ tunnel_dns(int tun_fd, int dns_fd)
{
struct in_addr tempip;
struct user dummy;
struct ip *hdr;
unsigned long outlen;
char logindata[16];
char out[64*1024];
char in[64*1024];
char *tmp[2];
int userid;
int touser;
int version;
int read;
int code;
@ -248,8 +250,20 @@ tunnel_dns(int tun_fd, int dns_fd)
uncompress((uint8_t*)out, &outlen,
(uint8_t*)users[userid].inpacket.data, users[userid].inpacket.len);
write_tun(tun_fd, out, outlen);
hdr = (struct ip*) (out + 4);
touser = find_user_by_ip(hdr->ip_dst.s_addr);
if (touser == -1) {
/* send the uncompressed packet to tun device */
write_tun(tun_fd, out, outlen);
} else {
/* send the compressed packet to other client
* if another packet is queued, throw away this one. TODO build queue */
if (users[touser].outpacket.len == 0) {
memcpy(users[touser].outpacket.data, users[userid].inpacket.data, users[userid].inpacket.len);
users[touser].outpacket.len = users[userid].inpacket.len;
}
}
users[userid].inpacket.len = users[userid].inpacket.offset = 0;
}
}