*Tor Router* is a simple SOCKS5 proxy server for distributing traffic across multiple instances of Tor. At startup Tor Router will run an arbitrary number of instances Tor and each request will be sent to a different instance in round-robin fashion. This can be used to increase anonymity, because each request will be sent on a different circuit and will most likely use a different exit-node, and also to increase performance since outbound traffic is now split across several instances of Tor.
Tor Router also includes a DNS proxy server and a HTTP proxy as well, which like the SOCKS proxy will distribute traffic across multiple instances of Tor in round-robin fashion. The HTTP proxy server can be used to access Tor via an HTTP Proxy.
The only installation requirement is node.js. Tor is bundled with the application. To use an external Tor executable use the `--torPath` command line switch or set the `TOR_PATH` environment variable.
|-f, --config | |Path to a JSON configuration file to use|
|-c, --controlHost |CONTROL_HOST |Host the control server will bind to and listen for TCP traffic (see below)|
|-w, --websocketControlHost |WEBSOCKET_CONTROL_HOST |Host the control server will bind to and listen for WebSocket traffic|
|-j, --instances |INSTANCES |Number of Tor instances to spawn|
|-s, --socksHost |SOCKS_HOST |Host the SOCKS proxy will bind to|
|-d, --dnsHost |DNS_HOST |Host the DNS proxy will bind to|
|-h, --httpHost |HTTP_HOST |Host the HTTP proxy will bind to|
|-l, --logLevel |LOG_LEVEL |Log level (defaults to "info") set to "null" to disable logging. To see a log of all network traffic set logLevel to "verbose"|
|-p, --parentDataDirectory |PARENT_DATA_DIRECTORY|Parent directory that will contain the data directories for the instances|
|-b, --loadBalanceMethod |LOAD_BALANCE_METHOD |Method that will be used to sort the instances between each request. Currently supports "round_robin" and "weighted". |
|-t, --torPath |TOR_PATH |Provide the path for the Tor executable that will be used|
A full list of all available configuration options and their defaults can be found in [default_config.js](https://github.com/znetstar/tor-router/blob/master/src/default_config.js)
For example: `tor-router -j 3 -s 127.0.0.1:9050` would start the proxy with 3 tor instances and listen for SOCKS connections on localhost:9050.
Instances can optionally be assigned name and a weight. If the `loadBalanceMethod` config variable is set to "weighted" the weight field will determine how frequently the instance is used. If the instance is assigned a name the data directory will be preserved when the process is killed saving time when Tor is restarted. They can also be assigned one or more groups.
If the `proxyByName` (argument `-n`) configuration property is set to "individual" or true you can use the instance name to send requests to a specific instance. The username field in the proxy URL will identify the instance. For example, using `http://instance-1:@localhost:9080` when connecting to the HTTP Proxy would route requests to "instance-1".
This feature works on the HTTP Proxy as well as the SOCKS Proxy, but not the DNS proxy since DNS lacks authentication.
## Groups
Instances can be assigned one or more groups.
```
{
"loadBalanceMethod": "weighted",
"instances": [
{
"Name": "instance-1",
"Group": [ "foo", "bar ]
},
{
"Name": "instance-2",
"Group": [ "foo" ]
},
{
"Name": "instance-3",
"Group": "baz"
}
]
}
```
If the `proxyByName` (argument `-n`) configuration property is set to "group" requests can be routed to a group of instances using the username field in the proxy URL. For example, using `http://foo:@localhost:9080` as the proxy URL will send requests too "instance-1" and "instance-2" rotating them in a round-robin fashion.
A JSON-RPC 2 TCP Server will listen on port 9077 by default. Using the rpc server the client can add/remove Tor instances and get a new identity (which includes a new ip address) while Tor Router is running. The control server will also accept websocket connections if the `--websocketControlHost` or `-w` flag is set.
You can retrieve or set the configuration of instances while they're running via the Tor Control Protocol.
The example below will change the "MaxCircuitDirtiness" value for the first instance in the pool
Example:
```
let rpcRequest = {
"method": "setInstanceConfigAt",
"params": [0, "MaxCircuitDirtiness", "20"],
"jsonrpc":"2.0",
"id": 1
};
client.write(JSON.stringify(rpcRequest));
```
You can also send signals directly to instances or to all instances in the pool via the control protocol. A list of all signals can be [found here](https://gitweb.torproject.org/torspec.git/tree/control-spec.txt)
The example below will set the log level of all instances to "debug".