Class TorController
java.lang.Object
org.eblocker.server.common.network.TorController
This class is opening a Telnet connection to the Tor Control-Port,
which should be activated in the 'torrc'-config file by including:
ControlPort 9051 CookieAuthentication 0
See https://gitweb.torproject.org/torspec.git/tree/control-spec.txt for the usage of the control port. It can be used to control and query information of the running Tor instance.
NOTE: To be able to specifiy certain exit nodes for tor to use we need the TOR-GEOIPDB debian package!!! For the BananaPi M2 it can be found in this repository (mirror) : deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTorController(int torControlPort, DataSource dataSource, EblockerDnsServer dnsServer, TelnetConnection telnetConnection, TorExitNodeCountries exitNodeCountries, TorConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeviceUsingTor(Device device) voidClose the telnet connection properly.Get a set of all exit nodes countriesReturn the current defined countries that the Tor instance should choose exit nodes inbooleanThis tells Tor to create a new circuit, and therefore we will also get another IP-address (exit node)voidinit()booleanUse this method to get the latest connection state of the Tor client.voidremoveDeviceNotUsingTor(Device device) voidsetAllowedExitNodesCountries(Set<String> selectedCountries) Reconfigures the Tor instance to use only exit nodes in the given set of countriesvoidstartCheckingConnection(ScheduledExecutorService executor, long milliseconds) Start checking the Tor connection with a delay in between the checks.
-
Field Details
-
STATUS_CIRCUIT_ESTABLISHED
- See Also:
-
STATUS_ENOUGH_DIR_INFO
- See Also:
-
STATUS_BOOTSTRAP_PHASE
- See Also:
-
SUBSCRIBE_STATUS_CLIENT_EVENTS
- See Also:
-
NEW_IDENTITY_COMMAND
- See Also:
-
RECONFIGURE_COMMAND
- See Also:
-
RESPONSE_OK
- See Also:
-
TOR_EVENT_NOT_ENOUGH_DIR_INFO
- See Also:
-
TOR_EVENT_ENOUGH_DIR_INFO
- See Also:
-
TOR_EVENT_CIRCUIT_ESTABLISHED
- See Also:
-
-
Constructor Details
-
TorController
@Inject public TorController(int torControlPort, DataSource dataSource, EblockerDnsServer dnsServer, TelnetConnection telnetConnection, TorExitNodeCountries exitNodeCountries, TorConfiguration configuration)
-
-
Method Details
-
init
public void init() -
startCheckingConnection
Start checking the Tor connection with a delay in between the checks. This will provide the buffer with the connection state (torNetworkConnection) for other objects It automatically handles tries to reconnect to the Tor Control port, if the connection is not established (anymore).- Parameters:
milliseconds- delay in milliseconds between checks
-
isConnectedToTorNetwork
public boolean isConnectedToTorNetwork()Use this method to get the latest connection state of the Tor client.- Returns:
-
getCountryList
Get a set of all exit nodes countries- Returns:
-
setAllowedExitNodesCountries
Reconfigures the Tor instance to use only exit nodes in the given set of countries- Parameters:
selectedCountries- Set of country names that should be used as exit nodes
-
getCurrentExitNodeCountries
Return the current defined countries that the Tor instance should choose exit nodes in- Returns:
-
getNewIdentity
public boolean getNewIdentity()This tells Tor to create a new circuit, and therefore we will also get another IP-address (exit node) -
closeTorTelnetConnection
public void closeTorTelnetConnection()Close the telnet connection properly. -
addDeviceUsingTor
-
removeDeviceNotUsingTor
-