Specify that IPv4/IPv6 addresses mean TLS-over-TCP.
[torspec/neena.git] / socks-extensions.txt
blobd2c68f18baa1fb1656bd58ca779f9233c864ffe8
1 Tor's extensions to the SOCKS protocol
3 1. Overview
5   The SOCKS protocol provides a generic interface for TCP proxies.  Client
6   software connects to a SOCKS server via TCP, and requests a TCP connection
7   to another address and port.  The SOCKS server establishes the connection,
8   and reports success or failure to the client.  After the connection has
9   been established, the client application uses the TCP stream as usual.
11   Tor supports SOCKS4 as defined in [1], SOCKS4A as defined in [2], and
12   SOCKS5 as defined in [3].
14   The stickiest issue for Tor in supporting clients, in practice, is forcing
15   DNS lookups to occur at the OR side: if clients do their own DNS lookup,
16   the DNS server can learn which addresses the client wants to reach.
17   SOCKS4 supports addressing by IPv4 address; SOCKS4A is a kludge on top of
18   SOCKS4 to allow addressing by hostname; SOCKS5 supports IPv4, IPv6, and
19   hostnames.
21 1.1. Extent of support
23   Tor supports the SOCKS4, SOCKS4A, and SOCKS5 standards, except as follows:
25   BOTH:
26   - The BIND command is not supported.
28   SOCKS4,4A:
29   - SOCKS4 usernames are ignored.
31   SOCKS5:
32   - The (SOCKS5) "UDP ASSOCIATE" command is not supported.
33   - IPv6 is not supported in CONNECT commands.
34   - The "NO AUTHENTICATION REQUIRED" (SOCKS5) authentication method [00] is
35     supported; and as of Tor 0.2.3.2-alpha, the "USERNAME/PASSWORD" (SOCKS5)
36     authentication method [02] is supported too. Any credentials passed to
37     the latter are ignored. As an extension to support some broken clients,
38     we allow clients to pass "USERNAME/PASSWORD" authentication to us even if
39     no authentication was selected.
41 2. Name lookup
43   As an extension to SOCKS4A and SOCKS5, Tor implements a new command value,
44   "RESOLVE" [F0].  When Tor receives a "RESOLVE" SOCKS command, it initiates
45   a remote lookup of the hostname provided as the target address in the SOCKS
46   request.  The reply is either an error (if the address couldn't be
47   resolved) or a success response.  In the case of success, the address is
48   stored in the portion of the SOCKS response reserved for remote IP address.
50   (We support RESOLVE in SOCKS4 too, even though it is unnecessary.)
52   For SOCKS5 only, we support reverse resolution with a new command value,
53   "RESOLVE_PTR" [F1]. In response to a "RESOLVE_PTR" SOCKS5 command with
54   an IPv4 address as its target, Tor attempts to find the canonical
55   hostname for that IPv4 record, and returns it in the "server bound
56   address" portion of the reply.
57   (This command was not supported before Tor 0.1.2.2-alpha.)
59 3. Other command extensions.
61   Tor 0.1.2.4-alpha added a new command value: "CONNECT_DIR" [F2].
62   In this case, Tor will open an encrypted direct TCP connection to the
63   directory port of the Tor server specified by address:port (the port
64   specified should be the ORPort of the server). It uses a one-hop tunnel
65   and a "BEGIN_DIR" relay cell to accomplish this secure connection.
67   The F2 command value was removed in Tor 0.2.0.10-alpha in favor of a
68   new use_begindir flag in edge_connection_t.
70 4. HTTP-resistance
72   Tor checks the first byte of each SOCKS request to see whether it looks
73   more like an HTTP request (that is, it starts with a "G", "H", or "P").  If
74   so, Tor returns a small webpage, telling the user that his/her browser is
75   misconfigured.  This is helpful for the many users who mistakenly try to
76   use Tor as an HTTP proxy instead of a SOCKS proxy.
78 5. Optimistic data
80   Tor allows SOCKS clients to send connection data before Tor has sent a
81   SOCKS response.  When using an exit node that supports "optimistic data",
82   Tor will send such data to the server without waiting to see whether the
83   connection attempt succeeds.  This behavior can save a single round-trip
84   time when starting connections with a protocol where the client speaks
85   first (like HTTP).  Clients that do this must be ready to hear that
86   their connection has succeeded or failed _after_ they have sent the
87   data.
91 References:
92  [1] http://en.wikipedia.org/wiki/SOCKS#SOCKS4
93  [2] http://en.wikipedia.org/wiki/SOCKS#SOCKS4a
94  [3] SOCKS5: RFC1928