mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-04 13:53:34 +03:00
Iodine: IPv6
This commit is contained in:
parent
57e7ea905f
commit
c4a11cf849
6 changed files with 49 additions and 23 deletions
30
src/client.c
30
src/client.c
|
@ -363,10 +363,22 @@ client_set_v6_connect(char v6_connect)
|
|||
}
|
||||
#endif
|
||||
|
||||
const char *
|
||||
char *
|
||||
client_get_raw_addr()
|
||||
{
|
||||
return inet_ntoa(raw_serv.sin_addr);
|
||||
#ifdef LINUX
|
||||
if(_v6_connect) {
|
||||
return ipv6_str(&raw_serv6.sin6_addr);
|
||||
} else {
|
||||
#endif
|
||||
char *str = inet_ntoa(raw_serv.sin_addr);
|
||||
size_t size = strlen(str) + 1;
|
||||
char *ret = (char*) malloc(size);
|
||||
memcpy(ret, str, size);
|
||||
return ret;
|
||||
#ifdef LINUX
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1736,7 +1748,14 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||
fprintf(stderr, "Failed to get raw server IP, will use DNS mode.\n");
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "Server is at %s, trying raw login: ", inet_ntoa(server));
|
||||
#ifdef LINUX
|
||||
if(_v6_connect) {
|
||||
char *str = ipv6_str(&server6);
|
||||
fprintf(stderr, "Server is at %s, trying raw login: ", str);
|
||||
free(str);
|
||||
} else
|
||||
#endif
|
||||
fprintf(stderr, "Server is at %s, trying raw login: ", inet_ntoa(server));
|
||||
fflush(stderr);
|
||||
|
||||
/* Store address to iodined server */
|
||||
|
@ -1745,12 +1764,11 @@ handshake_raw_udp(int dns_fd, int seed)
|
|||
raw_serv.sin_port = htons(53);
|
||||
raw_serv.sin_addr = server;
|
||||
|
||||
#ifdef LINUX
|
||||
raw_serv6.sin6_family = AF_INET6;
|
||||
raw_serv6.sin6_port = htons(53);
|
||||
raw_serv6.sin6_addr = server6;
|
||||
// inet_pton(AF_INET6, "::1", &(raw_serv6.sin6_addr));
|
||||
|
||||
ipv6_print(&server6, 00);
|
||||
#endif
|
||||
|
||||
/* do login against port 53 on remote server
|
||||
* based on the old seed. If reply received,
|
||||
|
|
|
@ -22,7 +22,7 @@ void client_init();
|
|||
void client_stop();
|
||||
|
||||
enum connection client_get_conn();
|
||||
const char *client_get_raw_addr();
|
||||
char *client_get_raw_addr();
|
||||
|
||||
void client_set_nameserver(const char *cp, int port);
|
||||
void client_set_topdomain(const char *cp);
|
||||
|
|
12
src/common.c
12
src/common.c
|
@ -449,4 +449,16 @@ void ipv6_print(struct in6_addr *ip, char netmask6) {
|
|||
: "/");
|
||||
printf("%d\n", netmask6);
|
||||
}
|
||||
|
||||
char *ipv6_str(struct in6_addr *ip) {
|
||||
size_t size = 8*4 + 7 + 1;
|
||||
char *str = (char*)malloc(size);
|
||||
int i;
|
||||
size_t position = 0;
|
||||
for (i = 0; i < 8; ++i)
|
||||
position += sprintf(str + position, "%04x%s", ntohs(ip->__in6_u.__u6_addr16[i]), i < 7 ? ":"
|
||||
: "/");
|
||||
str[size - 1] = 0;
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -147,6 +147,7 @@ void ipv6_addr_add(struct in6_addr *addr, uint8_t amount);
|
|||
char ipv6_addr_equals(struct in6_addr *a, struct in6_addr *b);
|
||||
char ipv6_net_check(struct in6_addr *net, char netmask);
|
||||
void ipv6_print(struct in6_addr *ip, char netmask6);
|
||||
char *ipv6_str(struct in6_addr *ip);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -400,7 +400,9 @@ main(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (client_get_conn() == CONN_RAW_UDP) {
|
||||
fprintf(stderr, "Sending raw traffic directly to %s\n", client_get_raw_addr());
|
||||
char *str = client_get_raw_addr();
|
||||
fprintf(stderr, "Sending raw traffic directly to %s\n", str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Connection setup complete, transmitting data.\n");
|
||||
|
|
|
@ -191,8 +191,8 @@ send_raw(int fd, char *buf, int buflen, int user, int cmd, struct query *q)
|
|||
inet_ntoa(tempin->sin_addr), cmd, len);
|
||||
}
|
||||
|
||||
printf("send_raw()");
|
||||
ipv6_print(&q->from.v6.sin6_addr, 66);
|
||||
// printf("send_raw()");
|
||||
// ipv6_print(&q->from.v6.sin6_addr, 66);
|
||||
|
||||
if(v6_listen)
|
||||
sendto(fd, packet, len, 0, &q->from.v6, q->fromlen);
|
||||
|
@ -917,9 +917,6 @@ handle_null_request(int tun_fd, int dns_fd, struct query *q, int domain_len)
|
|||
for(i = 0; i < sizeof(struct in6_addr); i++)
|
||||
reply[i + 1] = replyaddr.__in6_u.__u6_addr8[i];
|
||||
|
||||
printf("tuuuut:\n");
|
||||
ipv6_print((void*)reply + 1, 0);
|
||||
|
||||
write_dns(dns_fd, q, reply, sizeof(reply), 'T');
|
||||
} else {
|
||||
#endif
|
||||
|
@ -2108,15 +2105,19 @@ read_dns(int fd, int tun_fd, struct query *q) /* FIXME: tun_fd is because of raw
|
|||
#endif /* !WINDOWS32 */
|
||||
|
||||
if (r > 0) {
|
||||
#ifdef LINUX
|
||||
if (v6_listen) {
|
||||
memcpy((struct sockaddr*) &q->from, (struct sockaddr*) &from6,
|
||||
sizeof(struct sockaddr_in6));
|
||||
q->fromlen = sizeof(struct sockaddr_in6);
|
||||
} else {
|
||||
#endif
|
||||
memcpy((struct sockaddr*) &q->from, (struct sockaddr*) &from,
|
||||
addrlen);
|
||||
q->fromlen = addrlen;
|
||||
#ifdef LINUX
|
||||
}
|
||||
#endif
|
||||
|
||||
ipv6_print(&(from6.sin6_addr), 42);
|
||||
|
||||
|
@ -2129,16 +2130,9 @@ read_dns(int fd, int tun_fd, struct query *q) /* FIXME: tun_fd is because of raw
|
|||
}
|
||||
|
||||
#ifndef WINDOWS32
|
||||
//memcpy(&q->destination.v6, &in6addr_loopback, sizeof(struct in6_addr));
|
||||
//inet_pton(AF_INET6, "2001:4ca0:2001:18:216:3eff:fe99:4d2b", &q->destination.v6);
|
||||
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
|
||||
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
|
||||
printf("cmsg != NULL!\n");
|
||||
printf("Vaavvaaaa\n");
|
||||
ipv6_print(cmsg->__cmsg_data, 00);
|
||||
|
||||
if (cmsg->cmsg_level == IPPROTO_IP &&
|
||||
cmsg->cmsg_type == DSTADDR_SOCKOPT) {
|
||||
|
||||
|
@ -2146,17 +2140,16 @@ read_dns(int fd, int tun_fd, struct query *q) /* FIXME: tun_fd is because of raw
|
|||
break;// printf("write_dns()\n");
|
||||
// ipv6_print(&q->from.v6, 44);
|
||||
}
|
||||
#ifdef LINUX
|
||||
if (cmsg->cmsg_level == IPPROTO_IPV6 &&
|
||||
cmsg->cmsg_type == IPV6_PKTINFO) {
|
||||
|
||||
memcpy(&q->destination.v6, cmsg->__cmsg_data, sizeof(struct in6_addr));
|
||||
|
||||
printf("hallo\n");
|
||||
ipv6_print(&q->destination.v6, 0);
|
||||
|
||||
break;// printf("write_dns()\n");
|
||||
// ipv6_print(&q->from.v6, 44);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return strlen(q->name);
|
||||
|
|
Loading…
Add table
Reference in a new issue