A tool that lets you create multiple TOR instances with a load-balancing traffic between them by HAProxy. It’s provides one single endpoint for clients. In addition, you can view previously running TOR processes and create a new identity for all or selected processes.

The multitor has been completely rewritten on the basis of:

Parameters

Provides the following options:

Requirements

Multitor uses external utilities to be installed before running:

How To Use

It’s simple – for install:

For remove:

  • symlink to bin/multitor is placed in /usr/local/bin
  • man page is placed in /usr/local/man/man8

Creating processes

Then an example of starting the tool:

Creates new TOR processes and specifies the number of processes to create:

  • --init 2

Specifies the user from which new processes will be created (the user must exist in the system):

  • -u debian-tor

Specifies the port number for TOR communication. Increased by 1 for each subsequent process:

  • --socks-port 9000

Specifies the port number of the TOR process control. Increased by 1 for each subsequent process:

  • --control-port 9900

Reviewing processes

Examples of obtaining information about a given TOR process created by multitor:

We want to get information about a given TOR process:

  • --show-id

You can use the all value to display all processes.

Specifies the port number for communication. Allows you to find the process after this port number:

  • --socks-port 9000

New TOR identity

There is a “Use new identity” button in TOR Browser or Vidalia. It sends a signal to the control port of TOR, to switch to a new identity. An alternative solution is to restart the multitor or wait for the time defined in the NewCircuitPeriod variable, which default value is 30s.

If there is a need to create a new identity:

We set up creating a new identity for TOR process:

  • --new-id

You can use the all value to regenerate identity for all processes. An alternative option to give new identity is to restart the multitor.

Specifies the port number for communication. Allows you to find the process after this port number:

  • --socks-port 9000

Proxy

See Load balancing.

Output example

So if We created 2 TOR processes by Multitor example output will be given:

Load balancing

Multitor uses two techniques to create a load balancing mechanism – these are socks proxy and http proxy. Each of these types of load balancing is good but its purpose is slightly different.

For browsing websites (generally for http/https traffic) it is recommended to use http proxy. In this configuration, the polipo service is used, which has many very useful functions (including cache memory) which in the case of TOR is not always well-aimed. In addition, we are confident in better handling of ssl traffic.

The socks proxy type is also reliable, however, when browsing websites through TOR nodes it can cause more problems.

Multitor uses HAProxy to create a local proxy server for all created TOR or Polipo instances and distribute traffic between them. The default configuration is in templates/haproxy-template.cfg.

HAProxy uses 16379 to communication, so all of your services to use the load balancer should have this port number.

SOCKS Proxy

Communication architecture:

To run the load balancer you need to add the --proxy socks parameter to the command specified in the example.

After launching, let’s see the working processes:

In order to test the correctness of the setup, you can run the following command:

Communication through socks proxy takes place without a cache (except browsers that have their own cache). Curl and other low-level programs should work without any problems.

HTTP Proxy

Communication architecture:

To run the load balancer you need to add the --proxy http parameter to the command specified in the example.

After launching, let’s see the working processes:

In order to test the correctness of the setup, you can run the following command:

In the default configuration, the Polipo cache has been turned off (look at the configuration template). If you set the network configuration in the browser so that the traffic passes through HAProxy, you must remember that browsers have their own cache, which can cause that each entry to the page will be from the same IP address. This is not a big problem because it is not always the case. After clearing the browser cache again, the web server will receive the request from a different IP address.

You can check it for example in the firefox browsers by installing the “Empty Cache Button by mvm” add-on and enter the http://myexternalip.com/ website.

Port convention

The port numbers for the TOR are set by the user using the --socks-port parameter. Additionally, the standard port on which HAProxy listens is 16379. Polipo uses ports 1000 smaller than those set for TOR.

HAProxy stats interface

If you want to view traffic statistics, go to http://127.0.0.1:16380/stats.

Login: ha_admin

Password: automatically generated (see in etc/haproxy.cfg)

Polipo configuration interface

If you wat to view or changed Polipo params, got to http://127.0.0.1:8000/polipo/config (remember the right port number).

Gateway

If you are building a gateway for TOR connections, you can put HAProxy on an external IP address by changing the bind directive in haproxy-template.cfg:

Password authentication

Multitor uses password for authorization on the control port. The password is generated automatically and contains 18 random characters – it is displayed in the final report after the creation of new processes.

Logging

After running the script, the log/ directory is created and in it the following files with logs:

  • <script_name>.<date>.log – all _logger() function calls are saved in it
  • stdout.log – a standard output and errors from the _init_cmd() and other function are written in it

Important

If you use this tool in other scripts where the output is saved everywhere, not on the screen, remember that you will not be able to use the generated password. I will correct this in the next version. If you do not use regenerate function of single or all TOR circuits with a password, you can safely restart the multitor which will do it for you.

Limitations

  • each TOR process needs a certain number of memory. If the number of processes is too big, the oldest one will be automatic killed by the system
  • Polipo is no longer supported but it is still a very good and light proxy. It is very good for such applications. In the next version I will give you the option to choose a different solution

Contributing

See CONTRIBUTING.md.

Project architecture