1
0
mirror of https://github.com/yarrick/iodine.git synced 2024-11-29 00:25:28 +03:00

Do not validate the autodetected IPs of additional address families when using -4 (IPV4 only) and -6 (IPv6 only) flags

This commit is contained in:
Will Szumski 2016-11-23 01:00:11 +00:00
parent 8e15a73a77
commit 1ad7c05b92

View File

@ -1844,10 +1844,10 @@ tunnel(int tun_fd, struct dnsfd *dns_fds, int bind_fd, int max_idle_time)
if (FD_ISSET(tun_fd, &fds)) { if (FD_ISSET(tun_fd, &fds)) {
tunnel_tun(tun_fd, dns_fds); tunnel_tun(tun_fd, dns_fds);
} }
if (FD_ISSET(dns_fds->v4fd, &fds)) { if (dns_fds->v4fd >= 0 && FD_ISSET(dns_fds->v4fd, &fds)) {
tunnel_dns(tun_fd, dns_fds->v4fd, dns_fds, bind_fd); tunnel_dns(tun_fd, dns_fds->v4fd, dns_fds, bind_fd);
} }
if (FD_ISSET(dns_fds->v6fd, &fds)) { if (dns_fds->v6fd >= 0 && FD_ISSET(dns_fds->v6fd, &fds)) {
tunnel_dns(tun_fd, dns_fds->v6fd, dns_fds, bind_fd); tunnel_dns(tun_fd, dns_fds->v6fd, dns_fds, bind_fd);
} }
if (FD_ISSET(bind_fd, &fds)) { if (FD_ISSET(bind_fd, &fds)) {
@ -2592,16 +2592,19 @@ main(int argc, char **argv)
fprintf(stderr, "Add more -D switches to set higher debug level.\n"); fprintf(stderr, "Add more -D switches to set higher debug level.\n");
foreground = 1; foreground = 1;
} }
if (addrfamily == AF_UNSPEC || addrfamily == AF_INET) {
dns4addr_len = get_addr(listen_ip4, port, AF_INET, AI_PASSIVE | AI_NUMERICHOST, &dns4addr); dns4addr_len = get_addr(listen_ip4, port, AF_INET, AI_PASSIVE | AI_NUMERICHOST, &dns4addr);
if (dns4addr_len < 0) { if (dns4addr_len < 0) {
warnx("Bad IPv4 address to listen on."); warnx("Bad IPv4 address to listen on.");
usage(); usage();
}
} }
dns6addr_len = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE | AI_NUMERICHOST, &dns6addr); if (addrfamily == AF_UNSPEC || addrfamily == AF_INET6) {
if (dns6addr_len < 0) { dns6addr_len = get_addr(listen_ip6, port, AF_INET6, AI_PASSIVE | AI_NUMERICHOST, &dns6addr);
warnx("Bad IPv6 address to listen on."); if (dns6addr_len < 0) {
usage(); warnx("Bad IPv6 address to listen on.");
usage();
}
} }
if(bind_enable) { if(bind_enable) {