The basic scenario is a machine, A, that wants to connect to another machine, B:
A => B
Note that here and in the following, A and B and the other players can be referred to as "machines", but any combination of them, even possibly all of them, can easily be located on the same machine, and should really be considered "applications" instead. However, thinking of them as machines will sometimes make it easier to hold an overview of what is actually going on. Typically though, the network on the immediate right side of the (first) proxy is the internet, while other networks involved are typically local, at least for the tunnel examples – but it is not necessarily so.
If A for some reason cannot contact B directly, it can use the help of a proxy that can:
A => P => B
A proxy can be transparent, in which case A isn’t even aware that a proxy is in use, except perhaps through the use of a different ip address and port, but the protocol in the communication at least isn’t aware. A proxy can also be a socks proxy using either socks 4 or socks 5, in which case A must first negotiate with P to establish a connection to B. This is the basic difference between transparent and socks proxies; the proxy needs to know how to contact B, and for a transparent proxy, it must be configured in advance, for a socks proxy, A is required to deliver this information, including any user name and password necessary to access the socks proxy. This requires a more complicated application A, but then the same proxy can be used for different B’s, whereas a transparent proxy can only contact the preconfigured B.
Proxies can be chained, meaning there is a chain of any number of proxies between A and B:
A => P => P => B
For transparent proxies, this is the precise description, but for socks proxies, the situation is more complicated. If the second proxy in the figure above is a socks proxy, then the first proxy will need to know how to communicate with a socks proxy, including socks version and any user name and password - just as A needs to be able to do this in case the first proxy is a socks proxy. The SocksProxy application is doing this through the concept of a "carrier":
A => PC => P => B
The second proxy is considered a "carrier" of the communication from the first proxy to B, so the first proxy must have a carrier interface that can take on the task to communicate with the second proxy, the carrier, on behalf of the first proxy. For a transparent second proxy, no carrier interface is of course required, for any other type of proxy, a properly configured carrier definition must be used. In the following, the word "carrier" is used to refer to the carrier definition belonging to the first proxy, while the physical carrier is refered to simply as the "second proxy".
SocksProxy also offers the use of tunnels, having the benefits of taking some of the danger out of exposing the second proxy to the internet. A tunnel is using a proprietary protocol, it can be encrypted, and it is possible to change SocksProxy to only accept certain ip addresses.
A special kind of tunnel offered is the "reverse tunnel":
A => PC <= P => B
Note that the communication line between the two proxies is created in the
opposite direction.
This can be useful in cases where firewalls or NAT routers are involved, or
if a static ip is not available on the second proxy where it is needed, but
is available only on the first proxy.
SocksSetup can administer the setup of both (user) local and service settings, local settings are used when running the proxy with the -l option. In the SocksSetup application, you will find 3 tabs called "Proxies", "Carriers" and "Names". The "Names" tab can be used to define aliases for ip addresses that can be used just as dns names. This will sometimes make it easier to create and maintain the proxy and carrier definitions, but it is also possible to use the ip adresses or dns names directly, the use of defined names is optional. In the examples below, no names but only ip addresses are used for simplicity.
In the following are shown examples on how to set up the scenarios mentioned above:
To create a connection through first a transparent proxy, and then a socks proxy, A => PC => P => B, the two different proxies should be configured like this:
The structure of the registry keys under the SocksProxy key is as follows:
Proxies\<name>\
Active (DWORD) |
0 not active, 1 active, default 1. |
Authentication (SZ) |
"None" or "UsernamePassword" ("unpw"), default "None". |
Carrier (SZ) |
Name of the carrier to use (optional). |
ChaChaKey (BINARY) |
ChaCha encryption key used for tunnels (32 bytes). |
Compression (SZ) |
Compression method for tunnels: "None", "Runlength", "Huffman". |
DestinationIP (SZ) |
IP address or name of destination, used by Transparent. |
DestinationPort (DWORD) |
Port of destination, used by Transparent. |
Encryption (SZ) |
Encryption method for tunnels: "None", "ChaCha". |
ExternalIP (SZ) |
IP or name used to connect from, 0.0.0.0 means any. Used if no carrier is used. |
Gre (DWORD) |
0 no gre routing, 1 gre routing, used by Transparent. |
InternalIP (SZ) |
IP or name used to connect from when a reverse tunnel connects to the carrier, 0.0.0.0 means any. |
ListenIP (SZ) |
IP or name of listener, 0.0.0.0 to listen on all. |
ListenPort (DWORD) |
Port used by listener. |
PublicIP (SZ) |
IP address used for Socks bind. |
Protocol (SZ) |
Protocol for proxy: "Socks", "Socks4", "Socks5", "Transparent". |
ResolveRemotely (DWORD) |
0 if DestinationIP is a name to be resolved locally, 1 if resolving is to be done by the carrier. |
Carriers\<name>\
Authentication (SZ) |
"None" or "UsernamePassword" ("unpw"), default "None". |
ChaChaKey (BINARY) |
ChaCha encryption key used for tunnels (32 bytes). |
Compression (SZ) |
Compression method for tunnels: "None", "Runlength", "Huffman". |
Encryption (SZ) |
Encryption method for tunnels: "None", "ChaCha". |
ExternalIP (SZ) |
IP or name used to connect from, 0.0.0.0 means any. |
IP (SZ) |
IP or name of the "next" proxy. |
ListenIP (SZ) |
IP or name of listener, 0.0.0.0 to listen on all. Used by reverse tunnel. |
ListenPort (DWORD) |
Port used by listener. Used by reverse tunnel. |
Password (SZ) |
Password if authentication is "UsernamePassword" ("unpw"). |
Port (DWORD) |
Port of the "next" proxy. |
Protocol (SZ) |
Protocol to use when talking to the next proxy. |
Username (SZ) |
Username if authentication is "UsernamePassword" ("unpw"). |
Names\
<name> (SZ) |
IP address or DNS name. |
When configuring a proxy, first consider what type of proxy you need:
Protocol (SZ)
"Transparent" |
Simple forwarding to a fixed destination. Configure your client program to connect to this proxy instead of the real destination, and configure the proxy to connect to the actual destination (see later). |
"Socks" |
Socks proxy, either 4, 4a or 5. The client will need to know one of these protocols, and will itself instruct the proxy where to connect. |
"Socks4" |
As above, but only Socks 4 or 4a. |
"Socks5" |
As above, but only Socks 5. |
"Tunnel" |
For a carrier, this is the client of a tunnel meant to send connection request to another proxy. For a proxy, this is the server end of a tunnel that is to receive request. |
"ReverseTunnel" |
For a carrier, this is the client of a tunnel meant to send connection request to another proxy, but the underlying connection is to be made by the proxy, not the carrier. For a proxy, this is the server end of a tunnel that is to receive request. The server end is to create the connection to use. |
Next, specify the ip and port to listen on. These are the values that you will need to put into your client application. Note that for a reverse tunnel proxy, no ListenIP and -Port are required, rather DestinationIP and -Port as the proxy is to make a connection, not receive one.
ListenIP (SZ) |
IP address or name (see later). |
ListenPort (DWORD) |
Tcp port. |
If your proxy is on a multihomed PC (it usually is), you may configure the ip address to connect from, to ensure that the connection is established on the right network adapter. This address is only used by a reverse tunnel proxy, while a carrier has its own external ip address.
ExternalIP (SZ) |
IP address or name (see later). |
A reverse tunnel proxy will need to connect to the carrier, so just like you configure an external ip address to connect to the requested server from, you can also configure the internal ip address to connect to the carrier from.
InternalIP (SZ) |
IP address or name (see later). |
When using one of the Socks protocols, the required type of authentication must be specified:
Authentication (SZ)
"None" |
No authentication is required. |
"UsernamePassword" |
(Or simply "unpw".) The socks client must specify a username and password. |
Certain elements of the Socks protocol requires the socks proxy to know on which ip address servers will connect to when doing callback. When chaining to another proxy, this is not relevant, but when not chaining, (the most frequent case), that ip can be specified as:
PublicIP (SZ) |
IP address or name (see later). |
If you are configuring a transparent proxy, there are a few more choices to make. For transparent proxies, the client application should be configured with the proxy IP address and port, and the proxy should be configured with the actual destination IP and port. The DestinationIP and -Port are also required by a reverse tunnel proxy and should specify the ip and port of the client's carrier.
DestinationIP (SZ) |
IP address or name (see later). |
DestinationPort (DWORD) |
Tcp port. |
If you are using the transparent proxy to route a Microsoft VPN, you will need to route the GRE protocol as well:
Gre (DWORD) | ||||
|
When configuring tunnels and reverse tunnels, you also have the choice of using compression and encryption.
Compression (SZ) | ||||||
|
Encryption (SZ) | ||||
|
Note that already compressed and/or encrypted streams cannot benefit from further compression, where encryption always adds another layer of security. ChaCha encryption does not offer forward secrecy though, if the shared key is compromised.
Sometimes the proxy server cannot itself connect directly to the desired destination, but will need to connect to another proxy server, possibly even of another brand. This is possible, (except for the transparent protocol) if that other proxy server implements the Socks protocol in a similar manner with respect to authentication. Specify that other server as a carrier:
Carrier (SZ) |
Name of carrier (see later). |
"0.0.0.0" |
Can be used for ListenIP and ExternalIP and means that the proxy will listen on all available addresses, and connect from any suitable address. This is also the default if not specified. |
"0.0.0.1" |
Can be used for PublicIP and means that an external service will be contacted in order to detect the current public ip address. This is also the default. Note that this method CAN fail, if the network or remote service is not available when the proxy server is started, in which case the specific proxy is disabled. |
Protocol (SZ) |
The protocol used by the next proxy, either "Socks4", "Socks5", "Tunnel" or "ReverseTunnel". |
IP (SZ) |
IP address or name of the next proxy to connect to. |
Port (DWORD) |
Tcp port of the next proxy. |
ExternalIP (SZ) |
IP address or name (see later), to connect from to the next proxy. |
Authentication (SZ) |
"None" or "UsernamePassword" ("unpw"), default "None". Used for Socks protocols only. This setting must match how the next proxy server is configured. |
Username (SZ) |
Username if authentication is "UsernamePassword" ("unpw"). Used for Socks protocols only. |
Password (SZ) |
Password if authentication is "UsernamePassword" ("unpw"). Used for Socks protocols only. |
Compression (SZ) |
Compression method for tunnels: "None", "Runlength", "Huffman". See details under "Proxies". |
Encryption (SZ) |
Encryption method for tunnels: "None", "ChaCha". See details under "Proxies". |
ChaChaKey (BINARY) |
ChaCha encryption key used for tunnels (32 bytes). See details under "Proxies". |
ListenIP (SZ) |
For reverse tunnels, this is the IP address or name of the client. Reverse tunnels are created "backwards", and can thus only serve a single preconfigured client. |
ListenPort (DWORD) |
For reverse tunnels, this is the tcp port of the client. |
Examine the log from the proxy server when it is started, to see if all the requested proxies have been correctly started.
Last revised: 2019-05-15
·