The Node socks package uses a SocksClient instance with command: 'associate' for UDP. Its convenient SocksClient.createConnection() factory handles TCP CONNECT instead.

The project's association example combines the SOCKS client with a separate local UDP socket:

  1. Establish UDP ASSOCIATE and retain its TCP control connection.
  2. Read the relay host and port returned by the server.
  3. Use createUDPFrame() to frame outgoing payloads with their destination address.
  4. Send the datagrams to the relay, then use parseUDPFrame() on incoming relay frames before delivering payloads to the application.

Node's dgram socket supplies UDP transport; it does not interpret a SOCKS URL. The association and framing provide the proxy protocol around those datagrams.

The server must support UDP, and the relay endpoint must be reachable. A successful TCP connection to the initial proxy port does not test that path. Close the control and UDP resources when the association is no longer needed.

Tënë sô zo