socks-extensions.txt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Tor's extensions to the SOCKS protocol
  2. 1. Overview
  3. The SOCKS protocol provides a generic interface for TCP proxies. Client
  4. software connects to a SOCKS server via TCP, and requests a TCP connection
  5. to another address and port. The SOCKS server establishes the connection,
  6. and reports success or failure to the client. After the connection has
  7. been established, the client application uses the TCP stream as usual.
  8. Tor supports SOCKS4 as defined in [1], SOCKS4A as defined in [2], and
  9. SOCKS5 as defined in [3].
  10. The stickiest issue for Tor in supporting clients, in practice, is forcing
  11. DNS lookups to occur at the OR side: if clients do their own DNS lookup,
  12. the DNS server can learn which addresses the client wants to reach.
  13. SOCKS4 supports addressing by IPv4 address; SOCKS4A is a kludge on top of
  14. SOCKS4 to allow addressing by hostname; SOCKS5 supports IPv4, IPv6, and
  15. hostnames.
  16. 1.1. Extent of support
  17. Tor supports the SOCKS4, SOCKS4A, and SOCKS5 standards, except as follows:
  18. BOTH:
  19. - The BIND command is not supported.
  20. SOCKS4,4A:
  21. - SOCKS4 usernames are ignored.
  22. SOCKS5:
  23. - The (SOCKS5) "UDP ASSOCIATE" command is not supported.
  24. - IPv6 is not supported in CONNECT commands.
  25. - Only the "NO AUTHENTICATION" (SOCKS5) authentication method [00] is
  26. supported.
  27. 2. Name lookup
  28. As an extension to SOCKS4A and SOCKS5, Tor implements a new command value,
  29. "RESOLVE" [F0]. When Tor receives a "RESOLVE" SOCKS command, it initiates
  30. a remote lookup of the hostname provided as the target address in the SOCKS
  31. request. The reply is either an error (if the address couldn't be
  32. resolved) or a success response. In the case of success, the address is
  33. stored in the portion of the SOCKS response reserved for remote IP address.
  34. (We support RESOLVE in SOCKS4 too, even though it is unnecessary.)
  35. For SOCKS5 only, we support reverse resolution with a new command value,
  36. "RESOLVE_PTR" [F1]. In response to a "RESOLVE_PTR" SOCKS5 command with
  37. an IPv4 address as its target, Tor attempts to find the canonical
  38. hostname for that IPv4 record, and returns it in the "server bound
  39. address" portion of the reply.
  40. (This command was not supported before Tor 0.1.2.2-alpha.)
  41. 3. Other command extensions.
  42. Tor 0.1.2.4-alpha added a new command value: "CONNECT_DIR" [F2].
  43. In this case, Tor will open an encrypted direct TCP connection to the
  44. directory port of the Tor server specified by address:port (the port
  45. specified should be the ORPort of the server). It uses a one-hop tunnel
  46. and a "BEGIN_DIR" relay cell to accomplish this secure connection.
  47. The F2 command value was removed in Tor 0.2.0.10-alpha in favor of a
  48. new use_begindir flag in edge_connection_t.
  49. 4. HTTP-resistance
  50. Tor checks the first byte of each SOCKS request to see whether it looks
  51. more like an HTTP request (that is, it starts with a "G", "H", or "P"). If
  52. so, Tor returns a small webpage, telling the user that his/her browser is
  53. misconfigured. This is helpful for the many users who mistakenly try to
  54. use Tor as an HTTP proxy instead of a SOCKS proxy.
  55. References:
  56. [1] http://archive.socks.permeo.com/protocol/socks4.protocol
  57. [2] http://archive.socks.permeo.com/protocol/socks4a.protocol
  58. [3] SOCKS5: RFC1928