Skip to content

Support incoming UDP traffic via SOCKS5 UDP ASSOCIATE #633

@Manouchehri

Description

@Manouchehri

Currently proxy-chain only handles TCP connections. It would be useful to support SOCKS5 UDP ASSOCIATE (command 0x03 per RFC 1928), which allows clients to send UDP datagrams through the proxy.

Use cases include DNS queries, gaming, VoIP, and QUIC/HTTP3 traffic.

Looking at the code, the server is purely TCP-based. In src/server.ts:115 we create an http.Server, and all connection tracking in registerConnection() at line 303 assumes TCP sockets. There's no dgram usage anywhere.

To add this, we'd need to:

  • Add a dgram.Socket in src/server.ts alongside the HTTP server
  • Create a new module (maybe src/socks5_udp.ts) to handle the UDP ASSOCIATE handshake and relay header format
  • Create UDP relay logic to forward datagrams between clients and targets
  • Extend src/socket.ts types for UDP associations
  • Add UDP-specific error handling in src/statuses.ts
  • Extend byte counting in src/utils/count_target_bytes.ts for UDP stats

Open questions:

  • Should this be opt-in via config flag or enabled by default?
  • What timeout should we use for idle UDP associations?
  • How to surface UDP events to users (new event types on the server?)

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