mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-08 10:19:18 +02:00
Create send_chunk() on server
This commit is contained in:
parent
f8eb4c952b
commit
7dd38fec17
|
@ -116,6 +116,8 @@ tunnel_tun(int tun_fd, int dns_fd)
|
|||
if (users[userid].outpacket.len == 0) {
|
||||
memcpy(users[userid].outpacket.data, out, outlen);
|
||||
users[userid].outpacket.len = outlen;
|
||||
users[userid].outpacket.offset = 0;
|
||||
users[userid].outpacket.sentlen = 0;
|
||||
users[userid].outpacket.seqno++;
|
||||
users[userid].outpacket.fragment = 0;
|
||||
return outlen;
|
||||
|
@ -156,6 +158,18 @@ send_version_response(int fd, version_ack_t ack, uint32_t payload, int userid, s
|
|||
write_dns(fd, q, out, sizeof(out));
|
||||
}
|
||||
|
||||
static void
|
||||
send_chunk(int dns_fd, int userid) {
|
||||
if (debug >= 1) {
|
||||
printf("OUT pkt seq# %d, frag %d (last=%d), fragsize %d, total %d, to user %d\n",
|
||||
users[userid].outpacket.seqno & 7, users[userid].outpacket.fragment & 15,
|
||||
1, users[userid].outpacket.len, users[userid].outpacket.len, userid);
|
||||
}
|
||||
write_dns(dns_fd, &users[userid].q, users[userid].outpacket.data, users[userid].outpacket.len);
|
||||
users[userid].outpacket.len = 0;
|
||||
users[userid].q.id = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
update_downstream_seqno(int dns_fd, int userid, int down_seq, int down_frag)
|
||||
{
|
||||
|
@ -173,14 +187,7 @@ update_downstream_seqno(int dns_fd, int userid, int down_seq, int down_frag)
|
|||
|
||||
/* Send reply if waiting */
|
||||
if (users[userid].outpacket.len > 0) {
|
||||
if (debug >= 1) {
|
||||
printf("OUT pkt seq# %d, frag %d (last=%d), fragsize %d, total %d, to user %d\n",
|
||||
users[userid].outpacket.seqno & 7, users[userid].outpacket.fragment & 15,
|
||||
1, users[userid].outpacket.len, users[userid].outpacket.len, userid);
|
||||
}
|
||||
write_dns(dns_fd, &users[userid].q, users[userid].outpacket.data, users[userid].outpacket.len);
|
||||
users[userid].outpacket.len = 0;
|
||||
users[userid].q.id = 0;
|
||||
send_chunk(dns_fd, userid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,16 +628,7 @@ tunnel(int tun_fd, int dns_fd, int bind_fd)
|
|||
int j;
|
||||
for (j = 0; j < USERS; j++) {
|
||||
if (users[j].q.id != 0) {
|
||||
if (debug >= 1 && users[j].outpacket.len > 0) {
|
||||
printf("OUT pkt seq# %d, frag %d (last=%d), "
|
||||
"fragsize %d of total %d, to user %d\n",
|
||||
users[j].outpacket.seqno & 7,
|
||||
users[j].outpacket.fragment & 15, 1,
|
||||
users[j].outpacket.len, users[j].outpacket.len, j);
|
||||
}
|
||||
write_dns(dns_fd, &(users[j].q), users[j].outpacket.data, users[j].outpacket.len);
|
||||
users[j].outpacket.len = 0;
|
||||
users[j].q.id = 0;
|
||||
send_chunk(dns_fd, j);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue