mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-11 21:10:56 +00:00
Iodine: Cleaned up
This commit is contained in:
parent
113f384dcc
commit
b30f060eb4
1 changed files with 11 additions and 7 deletions
|
@ -558,11 +558,12 @@ tunnel_tun(int tun_fd, int dns_fd)
|
||||||
char in[64*1024];
|
char in[64*1024];
|
||||||
int userid;
|
int userid;
|
||||||
int read;
|
int read;
|
||||||
|
uint16_t *header_info;
|
||||||
|
|
||||||
if ((read = read_tun(tun_fd, in, sizeof(in))) <= 0)
|
if ((read = read_tun(tun_fd, in, sizeof(in))) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
uint16_t *header_info = (uint16_t*)in;
|
header_info = (uint16_t*)in;
|
||||||
if(header_info[1] == 0x0008) {
|
if(header_info[1] == 0x0008) {
|
||||||
/* find target ip in packet, in is padded with 4 bytes TUN header */
|
/* find target ip in packet, in is padded with 4 bytes TUN header */
|
||||||
header = (struct ip*) (in + 4);
|
header = (struct ip*) (in + 4);
|
||||||
|
@ -573,7 +574,7 @@ tunnel_tun(int tun_fd, int dns_fd)
|
||||||
userid = find_user_by_ip6(header6->ip6_dst);
|
userid = find_user_by_ip6(header6->ip6_dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("tunnel_tun() - userid = %d, header_info[1] = %d\n", userid, header_info[1]);
|
/* printf("tunnel_tun() - userid = %d, header_info[1] = %d\n", userid, header_info[1]); */
|
||||||
|
|
||||||
if (userid < 0)
|
if (userid < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -688,6 +689,8 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len)
|
||||||
char *tmp[2];
|
char *tmp[2];
|
||||||
int userid;
|
int userid;
|
||||||
int read;
|
int read;
|
||||||
|
char server6[41];
|
||||||
|
char client6[41];
|
||||||
|
|
||||||
userid = -1;
|
userid = -1;
|
||||||
|
|
||||||
|
@ -808,11 +811,9 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len)
|
||||||
|
|
||||||
memcpy(&ip6, &my_net6, sizeof(my_net6));
|
memcpy(&ip6, &my_net6, sizeof(my_net6));
|
||||||
ipv6_addr_add(&ip6, 1);
|
ipv6_addr_add(&ip6, 1);
|
||||||
char server6[41];
|
|
||||||
inet_ntop(AF_INET6, &ip6, server6, sizeof(server6));
|
inet_ntop(AF_INET6, &ip6, server6, sizeof(server6));
|
||||||
|
|
||||||
memcpy(&ip6, &(users[userid].tun_ip6), sizeof(my_net6));
|
memcpy(&ip6, &(users[userid].tun_ip6), sizeof(my_net6));
|
||||||
char client6[41];
|
|
||||||
inet_ntop(AF_INET6, &ip6, client6, sizeof(client6));
|
inet_ntop(AF_INET6, &ip6, client6, sizeof(client6));
|
||||||
|
|
||||||
read = snprintf(out, sizeof(out), "%s-%s-%d-%d-%s-%s-%d",
|
read = snprintf(out, sizeof(out), "%s-%s-%d-%d-%s-%s-%d",
|
||||||
|
@ -822,7 +823,7 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len)
|
||||||
read = snprintf(out, sizeof(out), "%s-%s-%d-%d", tmp[0],
|
read = snprintf(out, sizeof(out), "%s-%s-%d-%d", tmp[0],
|
||||||
tmp[1], my_mtu, netmask);
|
tmp[1], my_mtu, netmask);
|
||||||
|
|
||||||
//printf("%s\n", out);
|
/* printf("%s\n", out); */
|
||||||
|
|
||||||
write_dns(dns_fd, q, out, read, users[userid].downenc);
|
write_dns(dns_fd, q, out, read, users[userid].downenc);
|
||||||
q->id = 0;
|
q->id = 0;
|
||||||
|
@ -1757,7 +1758,7 @@ static void
|
||||||
handle_full_packet(int tun_fd, int dns_fd, int userid)
|
handle_full_packet(int tun_fd, int dns_fd, int userid)
|
||||||
{
|
{
|
||||||
unsigned long outlen;
|
unsigned long outlen;
|
||||||
char out[64*1024];
|
unsigned char out[64*1024];
|
||||||
int touser;
|
int touser;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1777,6 +1778,7 @@ handle_full_packet(int tun_fd, int dns_fd, int userid)
|
||||||
touser = find_user_by_ip6(hdr->ip6_dst);
|
touser = find_user_by_ip6(hdr->ip6_dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
struct ip6_hdr *h6;
|
struct ip6_hdr *h6;
|
||||||
h6 = (struct ip6_hdr*) (out + 4);
|
h6 = (struct ip6_hdr*) (out + 4);
|
||||||
printf("hdr->ip6_dst: ");
|
printf("hdr->ip6_dst: ");
|
||||||
|
@ -1786,6 +1788,7 @@ handle_full_packet(int tun_fd, int dns_fd, int userid)
|
||||||
: "\n");
|
: "\n");
|
||||||
|
|
||||||
printf("handle_full_packet() - touser = %d, version = %d\n", touser, hdr->ip_v);
|
printf("handle_full_packet() - touser = %d, version = %d\n", touser, hdr->ip_v);
|
||||||
|
*/
|
||||||
|
|
||||||
if (touser == -1) {
|
if (touser == -1) {
|
||||||
/* send the uncompressed packet to tun device */
|
/* send the uncompressed packet to tun device */
|
||||||
|
@ -2252,6 +2255,7 @@ main(int argc, char **argv)
|
||||||
int skipipconfig;
|
int skipipconfig;
|
||||||
char *netsize;
|
char *netsize;
|
||||||
int retval;
|
int retval;
|
||||||
|
char buf[41];
|
||||||
|
|
||||||
#ifndef WINDOWS32
|
#ifndef WINDOWS32
|
||||||
pw = NULL;
|
pw = NULL;
|
||||||
|
@ -2512,7 +2516,7 @@ main(int argc, char **argv)
|
||||||
memcpy(&my_ip6, &my_net6, sizeof(my_net6));
|
memcpy(&my_ip6, &my_net6, sizeof(my_net6));
|
||||||
ipv6_addr_add(&my_ip6, 1);
|
ipv6_addr_add(&my_ip6, 1);
|
||||||
|
|
||||||
char buf[41];
|
|
||||||
inet_ntop(AF_INET6, &my_ip6, buf, sizeof(buf));
|
inet_ntop(AF_INET6, &my_ip6, buf, sizeof(buf));
|
||||||
if (tun_setip6(buf, netmask6) != 0) {
|
if (tun_setip6(buf, netmask6) != 0) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue