mirror of
https://github.com/yarrick/iodine.git
synced 2024-12-22 21:33:33 +02: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:
parent
3341f3c268
commit
76ec4ab895
1 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue