Skip to content

[BUG] IPv6 addresses in offline detection are incorrect - decimal literals instead of hex #166

@jordangarside

Description

@jordangarside

Summary

The IPv6 addresses used for offline connectivity checks are incorrect. The address groups are written as decimal literals in Rust, but IPv6 groups are hexadecimal values. This causes connections to completely wrong addresses, making IPv6 offline detection non-functional.

The Bug

In crates/utils/src/net.rs, the IPv6 addresses are defined like:

SocketAddr::from(([2606, 4700, 4700, 0, 0, 0, 0, 1111], 53))  // Intended: Cloudflare 2606:4700:4700::1111
SocketAddr::from(([2001, 4860, 4860, 0, 0, 0, 0, 8888], 53))  // Intended: Google 2001:4860:4860::8888

However, Rust interprets these as decimal values, not hex:

  • 2606 decimal = 0x0a2e hex
  • 4700 decimal = 0x125c hex
  • 1111 decimal = 0x0457 hex

This produces 0a2e:125c:125c::0457 instead of 2606:4700:4700::1111.

Evidence

With MOON_LOG=trace, the addresses being checked show the mangled values:

[TRACE] starbase_utils::net::offline  Resolving [a2e:125c:125c::457]:53
[TRACE] starbase_utils::net::offline  Resolving [7d1:12fc:12fc::22b8]:53

These are unroutable addresses that always timeout, causing ~3-4 second delays on IPv6-only networks as each address fails sequentially.

The Fix

Use hex literals:

SocketAddr::from(([0x2606, 0x4700, 0x4700, 0, 0, 0, 0, 0x1111], 53))  // Cloudflare
SocketAddr::from(([0x2606, 0x4700, 0x4700, 0, 0, 0, 0, 0x1001], 53))  // Cloudflare
SocketAddr::from(([0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8888], 53))  // Google
SocketAddr::from(([0x2001, 0x4860, 0x4860, 0, 0, 0, 0, 0x8844], 53))  // Google

Impact

  • IPv6 offline detection has never worked correctly
  • IPv6-only hosts experience 3-4 second delays on every moon run command
  • Each malformed address times out at PROTO_OFFLINE_TIMEOUT (default 750ms) sequentially

Environment

  • moon v1.41.7
  • IPv6-only network with NAT64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions