This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
fuss:tor [2014/11/24 01:16] – [Last Update: March 10, 2012] office | fuss:tor [2025/02/26 04:25] (current) – office | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Speed ===== | + | ====== Speed ====== |
Some optimisations are possible, for example: | Some optimisations are possible, for example: | ||
Line 37: | Line 37: | ||
Then you can perform your own speed tests and start to eliminate countries that are slow for you. A good resource is the [[http:// | Then you can perform your own speed tests and start to eliminate countries that are slow for you. A good resource is the [[http:// | ||
- | ==== Systematic Approach ==== | + | ===== Systematic Approach |
'' | '' | ||
Line 52: | Line 52: | ||
Also note that the '' | Also note that the '' | ||
- | ==== Speed Patches ==== | + | ===== Speed Patches |
These are various patches, hacking around tor (most likely breaking anonymity in favor of speed). The patches are against the git version but similar code can be found in the release versions. | These are various patches, hacking around tor (most likely breaking anonymity in favor of speed). The patches are against the git version but similar code can be found in the release versions. | ||
- | === Close Nodes === | + | ==== Close Nodes ==== |
tor defines the option '' | tor defines the option '' | ||
Line 77: | Line 77: | ||
This can be found in '' | This can be found in '' | ||
- | === Circuit Length === | + | ==== Circuit Length |
Allow '' | Allow '' | ||
Line 96: | Line 96: | ||
</ | </ | ||
- | ===== Bad Nodes ===== | + | ====== Bad Nodes ====== |
There is an '' | There is an '' | ||
Line 105: | Line 105: | ||
and they can be used to generate '' | and they can be used to generate '' | ||
- | ==== Last Update: March 10, 2012 ==== | + | ===== Last Update: March 10, 2012 ===== |
The following is a generated list of fingerprints that are deemed to be misbehaving. The site above was last active on March 10, 2012 so this list may be outdated. The two lists below should be added to the Tor configuration file: | The following is a generated list of fingerprints that are deemed to be misbehaving. The site above was last active on March 10, 2012 so this list may be outdated. The two lists below should be added to the Tor configuration file: | ||
Line 119: | Line 119: | ||
an effective solution is to add the '' | an effective solution is to add the '' | ||
- | ===== Enable Hardware Acceleration ===== | + | ====== Enable Hardware Acceleration |
To get list of engines, first issue: | To get list of engines, first issue: | ||
Line 140: | Line 140: | ||
in order to use a given engine. | in order to use a given engine. | ||
+ | Under FreeBSD, you should load the '' | ||
+ | <code bash> | ||
+ | kldload cryptodev | ||
+ | </ | ||
+ | |||
+ | which should give you access to the '' | ||
+ | |||
+ | |||
+ | |||
+ | ====== Updated Debian Packages ====== | ||
+ | |||
+ | To install the latest Debian package from '' | ||
+ | < | ||
+ | deb http:// | ||
+ | </ | ||
+ | |||
+ | After that, import the GPG key for the repository by issuing the following commands: | ||
+ | <code bash> | ||
+ | gpg --keyserver keys.gnupg.net --recv 886DDD89 | ||
+ | gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add - | ||
+ | </ | ||
+ | |||
+ | Now update the sources list: | ||
+ | <code bash> | ||
+ | aptitude update | ||
+ | </ | ||
+ | |||
+ | and upgrade: | ||
+ | <code bash> | ||
+ | aptitude upgrade | ||
+ | </ | ||
+ | |||
+ | ====== Compile a Static Tor ====== | ||
+ | |||
+ | First download the relevant packages: | ||
+ | |||
+ | * Tor | ||
+ | * OpenSSL | ||
+ | |||
+ | to, say ''/ | ||
+ | <code bash> | ||
+ | ./config ec_nistp_64_gcc_128 shared zlib-dynamic --openssldir=/ | ||
+ | </ | ||
+ | Note that '' | ||
+ | |||
+ | then you may need to run: | ||
+ | <code bash> | ||
+ | make depend | ||
+ | </ | ||
+ | |||
+ | and then to compile issue: | ||
+ | <code bash> | ||
+ | make | ||
+ | </ | ||
+ | |||
+ | and finally: | ||
+ | <code bash> | ||
+ | make install | ||
+ | </ | ||
+ | |||
+ | which will place openssl into ''/ | ||
+ | |||
+ | The next step is to compile tor statically: | ||
+ | <code bash> | ||
+ | ./configure --prefix=/ | ||
+ | --sysconfdir=/ | ||
+ | --localstatedir=/ | ||
+ | --enable-upnp | ||
+ | --enable-nat-pmp \ | ||
+ | --enable-bufferevents \ | ||
+ | --enable-static-openssl \ | ||
+ | --with-openssl-dir=/ | ||
+ | --enable-static-libevent \ | ||
+ | --with-libevent-dir=/ | ||
+ | </ | ||
+ | |||
+ | In case '' | ||
+ | |||
+ | ====== Increase Logging ====== | ||
+ | |||
+ | When debugging Tor, in particular client transport plugins it is sometimes useful to increase logging in order to determine the cause for something not working right. | ||
+ | |||
+ | Locate the configuration line starting with '' | ||
+ | < | ||
+ | Log notice syslog | ||
+ | </ | ||
+ | to: | ||
+ | < | ||
+ | Log debug syslog | ||
+ | </ | ||
+ | |||
+ | The previous configuration line will turn on debug logging and will send all messages to the system log. | ||
+ | |||
+ | |||
+ | ====== Monitoring tor Health Status ====== | ||
+ | |||
+ | When scaling up and using load balancing and high availability it is important to have a decisive way to determine whether a backend service is alive or not. Usually checks vary from " | ||
+ | |||
+ | In case of tor, given the inner workings, the strongest way perhaps to know whether tor is available, is to check whether a circuit has been established, | ||
+ | |||
+ | In order to do that, the tor control port and password have to be defined in the tor configuration file (usually at ''/ | ||
+ | <code bash> | ||
+ | tor --hash-password " | ||
+ | </ | ||
+ | which will result in a password generated on the standard output: | ||
+ | < | ||
+ | 16: | ||
+ | </ | ||
+ | |||
+ | The password will then be added to the tor configuration: | ||
+ | < | ||
+ | ControlPort 8050 | ||
+ | HashedControlPassword 16: | ||
+ | </ | ||
+ | |||
+ | After restarting tor the control port can be accessed via TCP and the status of the circuit can be checked. Here is a full TCP transcript using netcat: | ||
+ | < | ||
+ | $ nc -nv 192.168.1.1 8050 | ||
+ | Connection to 172.16.1.81 8050 port [tcp/*] succeeded! | ||
+ | AUTHENTICATE " | ||
+ | 250 OK | ||
+ | GETINFO status/ | ||
+ | 250-status/ | ||
+ | 250 OK | ||
+ | |||
+ | </ | ||
+ | where: | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | The useful string to look for in the responses is '' | ||
+ | |||
+ | ===== Monitoring Tor Instances with Monit ===== | ||
+ | |||
+ | With the configuration in place, tor is restarted and the following monit configuration is created: | ||
+ | < | ||
+ | ########################################################################### | ||
+ | ## Copyright (C) Wizardry and Steamworks 2023 - License: GNU GPLv3 ## | ||
+ | ########################################################################### | ||
+ | |||
+ | check process tor-01 with pidfile / | ||
+ | start program | ||
+ | stop program | ||
+ | if failed host 127.0.0.1 port 9050 type tcp then restart | ||
+ | if failed host 127.0.0.1 port 8050 type tcp and | ||
+ | # password is: tor surrounded by quotes 0x22 | ||
+ | send " | ||
+ | | ||
+ | send " | ||
+ | | ||
+ | retry 1 | ||
+ | timeout 5 seconds | ||
+ | then restart | ||
+ | |||
+ | </ | ||
+ | that will restart tor in case a circuit is not built within two minutes (60 seconds standard monit check time and times two for one more retry). | ||
+ | |||
+ | ===== Monitoring tor Instances using Expect ===== | ||
+ | |||
+ | A more versatile variation of the [[/ | ||
+ | |||
+ | < | ||
+ | # | ||
+ | ########################################################################### | ||
+ | ## Copyright (C) Wizardry and Steamworks 2024 - License: MIT ## | ||
+ | ########################################################################### | ||
+ | # This is an " | ||
+ | # circuit and sets the return status depending on whether it has or not. # | ||
+ | # # | ||
+ | # In other words, iff. the script returns 0, then tor has an established | ||
+ | # circuit; otherwise no circuit has been established. | ||
+ | # # | ||
+ | # Requirements: | ||
+ | # * expect (TCL program) | ||
+ | # * tor must expose a control port and must have a control password | ||
+ | # # | ||
+ | # In order to generate a control password, issue: tor --hash-password PWD # | ||
+ | # where PWD is the desired control port password. After that, amend the # | ||
+ | # tor configuration file to set the control port address, port and pass: # | ||
+ | # # | ||
+ | # ControlPort 0.0.0.0: | ||
+ | # HashedControlPassword 16: | ||
+ | # # | ||
+ | # Running: ./ | ||
+ | # where: | ||
+ | # * ADDRESS is the tor listening control address, | ||
+ | # * PORT is the tor listening control port, # | ||
+ | # * PASSWORD is the plaintext control password | ||
+ | # # | ||
+ | # after which the return status can be checked on the shell with: # | ||
+ | # echo $? # | ||
+ | ########################################################################### | ||
+ | |||
+ | set address [lindex $argv 0]; | ||
+ | set port [lindex $argv 1]; | ||
+ | set password [lindex $argv 2]; | ||
+ | |||
+ | set timeout 5 | ||
+ | spawn telnet $address $port | ||
+ | |||
+ | send " | ||
+ | expect "250 OK\r\n" | ||
+ | send " | ||
+ | expect { | ||
+ | timeout { | ||
+ | exit 1 | ||
+ | } | ||
+ | -ex " | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== Load-Balancing Multiple Tor Instances via HAProxy ====== | ||
+ | |||
+ | When running multiple Tor instances, it is possible to load-balance the traffic over all Tor instances whilst having a single SOCKS entry point. | ||
+ | |||
+ | Nevertheless, | ||
+ | |||
+ | < | ||
+ | . multiple Tor instances | ||
+ | . | ||
+ | | ||
+ | +---------+ | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | +---------+ | ||
+ | | ||
+ | . | ||
+ | . | ||
+ | </ | ||
+ | |||
+ | Assuming that multiple Tor instances are set up to listen to an array of ports, HAProxy can be set up with the following minimal configuration changes: | ||
+ | < | ||
+ | defaults | ||
+ | mode tcp | ||
+ | option redispatch | ||
+ | |||
+ | listen socks5-balance | ||
+ | bind 0.0.0.0: | ||
+ | balance leastconn | ||
+ | server socks5-1 127.0.0.1: | ||
+ | server socks5-2 127.0.0.1: | ||
+ | |||
+ | </ | ||
+ | |||
+ | The configuration declares two upstream proxies on '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Finally, by pointing an application at the HAProxy port '' | ||
+ | |||
+ | ===== Availability ===== | ||
+ | |||
+ | Based on [[/ | ||
+ | |||
+ | The tor configuration must be updated in order to open up port '' | ||
+ | < | ||
+ | ControlPort 8050 | ||
+ | HashedControlPassword 16: | ||
+ | </ | ||
+ | |||
+ | For each additional tor instance, a program will be running that will serve the tor circuit status over TCP: | ||
+ | <code bash> | ||
+ | socat TCP-LISTEN: | ||
+ | </ | ||
+ | where: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Finally the HAProxy configuration file should be changed to: | ||
+ | < | ||
+ | defaults | ||
+ | mode tcp | ||
+ | option redispatch | ||
+ | |||
+ | listen socks5-balance | ||
+ | bind 0.0.0.0: | ||
+ | balance leastconn | ||
+ | server socks5-1 127.0.0.1: | ||
+ | server socks5-2 127.0.0.1: | ||
+ | |||
+ | </ | ||
+ | |||
+ | The mechanism will ensure that each '' | ||
+ | |||
+ | Incidentally, | ||
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.