chiark / gitweb /
noip.c: Support IPv6-mapped IPv4 addresses (nearly) correctly.
There's a longstanding bug here. If a program makes an `AF_INET6'
socket, and then tries to connect to a v6-mapped v4 address, then `noip'
/ought/ to match that against an existing binding of the corresponding
real IPv4 address, and /vice versa/.
Also, to support non-`IPV6_V6ONLY' server sockets, when trying to
resolve an IPv4 connection, consider the IPv6 wildcard address as a
suitable match.
There's unfortunately quite a lot here, but it all really needs to be
done in one go to work properly.
* Add `map_ipv4_sockaddr' and `unmap_ipv4_sockaddr' functions to
do the grunt-work of the address handling.
* In `encode_unused_inet_addr', check that a proposed v4 socket
address doesn't conflict with any v6-mapped and/or wildcard sockets.
* In `encode_inet_addr', try to match v4 remote addresses against
local v6-mapped and/or wildcard sockets.
* Complicate `return_fake_name' to optionally v6-map an IPv4 address.
* Introduce and deploy a new `return_fake_peer' function, which
inspects a socket's local address to discover what its `native'
address family is, so that it can map the remote address if
necessary.
* Complicate `do_implicit_bind' so that it will v6-map the local
address it's decided on, if necessary. This is essential now as a
means of recording the socket's `native' address family, as used by
`return_fake_peer'.
* Complicate `fixup_client_socket' to unmap remote v6-mapped v4
addresses before trying to encode them as Unix-domain addresses.