Skip to content

mapdns appears to be IPv4-only: no AAAA synthesis and no IPv6-addressed mapdns handling #302

@SammyVimes

Description

@SammyVimes

Hi, thanks for hev-socks5-tunnel!

I think mapdns is currently (as of version 2.14.4) IPv4-only, even though the tunnel itself supports dual stack. This becomes a problem on IPv6-first / IPv6-only / NAT64 networks.

The tunnel itself seems to support IPv4/IPv6 dual stack, but mapdns appears to only support IPv4 synthetic mapping:

  1. It only synthesizes A answers, not AAAA.
  2. It only treats the mapped DNS endpoint as special when the destination address is IPv4.

Because of that, on ipv6-heavy networks, DNS/app flows may not work correctly through mapdns.

1. hev_mapped_dns_handle() only handles QTYPE=A

In src/hev-mapped-dns.c:

  • it checks QTYPE == 1 and QCLASS == 1
  • it writes an answer with:
    • type A
    • RDLENGTH = 4
    • a 32-bit mapped IPv4 address

So for an AAAA query, it does not create a mapping and returns a response with ANCOUNT = 0.

2. mapdns interception only triggers for ipv4 destination addresses

In src/hev-socks5-tunnel.c, udp_recv_handler():

if (dns && addr->type == IPADDR_TYPE_V4) {
    int faddr = hev_config_get_mapdns_address ();
    int fport = hev_config_get_mapdns_port ();
    if (fport == port && faddr == ip_2_ip4 (addr)->addr) {
        udp_recv (pcb, dns_recv_handler, dns);
        return;
    }
}

So mapdsn path is only activated for IPv4-addressed DNS traffic.

Is this the intended behavior? If not I'll be happy to fix it (I am working on a proxy app and in a specific region of the country mobile ISPs only use ipv6 or so it seems).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions