Skip to content

StreamParameters API doesn't provide a good way to say "make sure that IPv6-only addresses will work"

@morgan notes that when you try to use Arti to connect to a hostname that only has an IPv6 address, it frequently chooses an exit that doesn't support IPv6.

Here's the trouble. In arti-client, in order to open a stream, we need to tell tor-circmgr which TargetPorts we want to connect to. We choose those ports with StreamPrefs::wrap_target_port as follows:

    fn wrap_target_port(&self, port: u16) -> TargetPort {
        match self.ip_ver_pref {
            IpVersionPreference::Ipv6Only => TargetPort::ipv6(port),
            _ => TargetPort::ipv4(port),
        }
    }

Ignoring the specifics, there's a problem: None of these options is correct when the target address might be IPv4 or might be IPv6, and we want to make sure that either family will work.

So, we have two two things to do here—one easy, one hard.

  • The easy thing: wrap_target_port should sometimes return [TargetPort::ipv6(port), TargetPort::ipv4(port)] to indicate that we want an exit that supports both families?
    • (Or conceivably, TargetPort should have a "both families" mode and/or an "any family" mode.)
  • The hard thing: We need to decide when wrap_target_port will indicate that we want an exit that supports both families.
    • Maybe we can copy C tor's behavior if it's sensible?

cc @morgan