Skip to content

cleanup: remove misleading forward_datagram stub in relay_server.rs #32

Description

@dirvine

Summary

src/masque/relay_server.rs:457 has a forward_datagram() method that is a no-op stub — it validates the session, checks rate limits, records stats, but never actually forwards the datagram to the target. The _target: SocketAddr parameter is prefixed with underscore and ignored entirely.

pub async fn forward_datagram(
    &self,
    client_addr: SocketAddr,
    _target: SocketAddr,      // ← ignored
    payload: Bytes,
) -> RelayResult<()> {
    // ... session lookup, rate limit, stats ...
    Ok(())  // ← never forwards anything
}

Why this matters

The doc comment says "used for testing" but it's misleading:

  1. It gives the impression the relay data plane works when it doesn't (for this method)
  2. The real relay data plane uses handle_client_datagram() and handle_target_datagram() which are properly implemented
  3. The test in tests/ipv4_ipv6_bridging_tests.rs calls forward_datagram and appears to test relay forwarding, but is actually only testing rate limiting on a no-op
  4. This same stub exists in upstream ant-quic and caused confusion when investigating NAT traversal issues

Suggested action

Either:

  • Remove it — the real data plane is handle_client_datagram/handle_target_datagram
  • Or implement it properly — actually forward the datagram to the target via the session's UDP socket, if there's a test use case that needs it

The bridging test should be updated either way to use the real data plane methods.

Context

Came up while investigating symmetric NAT connectivity. Chris's hole-punching work (PRs #25, #26, #27) correctly uses the PUNCH_ME_NOW coordination path, not this stub. But the stub's existence is a footgun for anyone reading the relay code.

cc @jacderida

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