public class TorController extends TorProcess
Modifier and Type | Field and Description |
---|---|
static int |
EVENT_ABORTED |
static int |
EVENT_CIRCUIT_BUILT |
static int |
EVENT_CIRCUIT_CHANGED |
static int |
EVENT_CIRCUIT_FAILED |
static int |
EVENT_CIRCUITS_BUILT |
static int |
EVENT_CIRCUITS_FAILED |
static int |
EVENT_LATENCY_DONE |
static int |
EVENT_TESTING_DONE |
static long |
LATENCY_FAIL |
static int |
NODE_EXIT |
static int |
NODE_GUARD |
static int |
NODE_MIDDLE |
static int |
STATUS_BOOTING |
static int |
STATUS_CIRCUIT_CREATION |
static int |
STATUS_DEAD |
static int |
STATUS_IDLE |
static int |
STATUS_LATENCY_CHECKING |
static int |
STREAM_IP |
EMPTYSTRING, LOG_DEBUG, LOG_INFO, LOG_NOTICE, TOR_BOOT_ERROR, TOR_BOOT_FATAL, TOR_BOOT_TIMEOUT, TOR_BOOTED, TOR_BRIDGE, TOR_CLOCK_ERROR, TOR_DIRINFO_STALE, TOR_MESSAGE, TOR_NEWCIRC, TOR_NOEXITS, TOR_NOHOP0, TOR_NONET_ACTIVITY, TOR_NOROUTE, TOR_RESTARTED, TOR_STOPPED
CLIENT_RUNNING, CLIENT_STOPPED, CLIENT_TIMEDOUT
Constructor and Description |
---|
TorController(java.lang.String clientpath,
java.lang.String configfolder)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
abortActions()
Abort all current actions
|
void |
abortLatencyCheck()
Abort latency checking
|
void |
activateCircuit(java.lang.String hops)
Activate given circuit, does not block
|
void |
activateNodes(java.lang.String fingers,
int nocircs)
Set the csv list of exit node fingers to be used by tor, a single exit
node may also be specified, this does not block
|
void |
activateNodesBlocking(java.lang.String fingers,
int nocircs)
Set the csv list of exit node fingers to be used by tor, a single exit
node may also be specified, this blocks
|
void |
closeCircuit(java.lang.String id)
Close a circuit with ID
|
void |
closeCircuitsExcept(java.lang.String id,
boolean filtered)
Close open circuits except circuit specified by id
|
void |
controllerEventFired(int event,
java.lang.Object data)
Handle for controllerEventFired should be overridden by parent class
|
java.net.Socket |
createSocks4aSocket(java.lang.String socksaddr,
int socksport,
java.lang.String remotehost,
int remoteport)
Create a Socks4a socket Taken from Wikipedia SOCKS4a is a simple
extension to SOCKS4 protocol that allows a client that cannot resolve the
destination host's domain name to specify it.
|
java.net.Socket |
createTorSocketToURL(java.lang.String url,
boolean nowww)
Create a socks4a socket to this URL on this tor connection, if nowww is
true then remove www.
|
void |
doLatencyCheck(int timeout)
Triggers a socks latency check, EVENT_LATENCY_CHECK is fired on
completion
|
void |
enablePredictiveCircuits(boolean enabled)
Enable/Disable predictive circuit building
|
java.util.ArrayList<java.lang.String> |
getActiveStreams()
Get list of active streams
|
java.lang.String |
getBestHops()
Get best hops
|
long |
getBestLatency()
Get best latency
|
java.util.HashMap<java.lang.String,TorCircuit> |
getBuiltCircuits(boolean filtered)
Get built circuits
|
java.lang.String |
getCountryFromIP(java.lang.String ip)
Attempts to return the Country associated with an ip address
|
java.lang.String |
getEntryGuardsAsCSV()
Get entry guards chosen by tor client
|
java.lang.String |
getEntryNodes()
Get configured entry nodes
|
java.lang.String |
getEventMessage(int event)
Get textual representation on an event
|
java.util.ArrayList<java.lang.String> |
getInfo(java.lang.String property)
Get tor status information for a given property.
|
long |
getLatency()
Get current latency
|
TorCircuit |
getLatestCircuit()
Get the latest circuit
|
int |
getStatus()
Get current status
|
long |
getTorLatency(int timeout)
Returns measured latency for the active circuit without creating a
stream, this blocks so be careful
|
boolean |
haveValidEntryNode() |
boolean |
isIdle()
Convenience test for idle status
|
void |
loadConf()
Load configuration file
|
java.util.ArrayList<java.lang.String> |
resetConf(java.lang.String property)
reset a tor configuration property
|
void |
saveConf()
Save configuration file
|
java.util.ArrayList<java.lang.String> |
sendCommand(java.lang.String command)
Send a command to tor client
|
java.util.ArrayList<java.lang.String> |
setConf(java.lang.String property)
Set a tor configuration property
|
void |
setEntryNodes(java.lang.String fingers)
Set entry nodes
|
void |
setStatus(int status)
Set status flag
|
void |
setTestingURL(java.lang.String url)
Set the url used for latency checking
|
java.util.ArrayList<java.lang.String> |
signal(java.lang.String cmd)
Send signal to tor
|
void |
start()
Start tor controller process and issue the TOR_BOOTED event
|
void |
start(int bootevent)
Start tor controller process and issue the given event
|
void |
stop()
Stop the tor controller process completely
|
void |
testNode(java.lang.String finger)
Test specified node, non blocking
|
void |
torProcessEventFired(int event,
java.lang.String data)
Tor process event
|
boolean |
verifyControlComms()
Verify we have comms on the control socket
|
clearCLIOption, clearStdout, clearTorrcOption, clientProcessEventFired, createDataFolder, createDefaultConfig, deleteCacheData, deleteConfigFile, getBridges, getCacheAge, getCachedDataFolder, getClientLocation, getCLIOptionBool, getCLIOptions, getCLIOptionsAsString, getConfigFilePath, getControlPort, getDataFolder, getListenPort, getOwnershipID, getSecret, getTorrcOption, getTorrcOptionsAsString, getVersion, setBoolTorOption, setBridges, setCachedDataFolder, setCLIOption, setControlPassword, setExternalArgs, setGeoIP4, setGeoIP6, setInitialBootEvent, setListenPort, setLogLevel, setMaxHistory, setOwnershipID, setSilentBootEnabled, setStdoutTextArea, setTorrcOption, startProcess, validateBridges, validateHostPort
getClientStatus, getProcess, sendMessage, setStartupDelay, setStartupTimeout, start, stopProcess
public static final int EVENT_CIRCUITS_BUILT
public static final int EVENT_CIRCUITS_FAILED
public static final int EVENT_CIRCUIT_BUILT
public static final int EVENT_CIRCUIT_FAILED
public static final int EVENT_LATENCY_DONE
public static final int EVENT_TESTING_DONE
public static final int EVENT_CIRCUIT_CHANGED
public static final int EVENT_ABORTED
public static final int STATUS_DEAD
public static final int STATUS_BOOTING
public static final int STATUS_IDLE
public static final int STATUS_CIRCUIT_CREATION
public static final int STATUS_LATENCY_CHECKING
public static final long LATENCY_FAIL
public static final int STREAM_IP
public static final int NODE_GUARD
public static final int NODE_MIDDLE
public static final int NODE_EXIT
public TorController(java.lang.String clientpath, java.lang.String configfolder)
clientpath
- Path to Tor clientconfigfolder
- Location of configuration file torrcpublic final void torProcessEventFired(int event, java.lang.String data)
torProcessEventFired
in class TorProcess
event
- data
- public java.lang.String getEventMessage(int event)
TorProcess
getEventMessage
in class TorProcess
public void controllerEventFired(int event, java.lang.Object data)
event
- data
- public void setStatus(int status)
status
- public int getStatus()
public boolean isIdle()
public final void stop()
public final void start()
public final void start(int bootevent)
bootevent
- public final void abortActions()
public final void abortLatencyCheck()
public void saveConf()
public void loadConf()
public java.lang.String getCountryFromIP(java.lang.String ip)
ip
- public void setTestingURL(java.lang.String url)
url
- public void enablePredictiveCircuits(boolean enabled)
enabled
- public final java.util.ArrayList<java.lang.String> getInfo(java.lang.String property)
property
- public final void closeCircuit(java.lang.String id)
id
- public final java.util.ArrayList<java.lang.String> setConf(java.lang.String property)
property
- public final java.util.ArrayList<java.lang.String> resetConf(java.lang.String property)
property
- public final java.util.ArrayList<java.lang.String> signal(java.lang.String cmd)
cmd
- public java.lang.String getEntryGuardsAsCSV()
public final void doLatencyCheck(int timeout)
timeout
- public final long getLatency()
public long getTorLatency(int timeout)
timeout
- public void closeCircuitsExcept(java.lang.String id, boolean filtered)
id
- filtered
- public final java.util.ArrayList<java.lang.String> getActiveStreams()
public final void activateNodes(java.lang.String fingers, int nocircs)
fingers
- nocircs
- public final void activateCircuit(java.lang.String hops)
hops
- public void setEntryNodes(java.lang.String fingers)
fingers
- public java.lang.String getEntryNodes()
public void activateNodesBlocking(java.lang.String fingers, int nocircs)
fingers
- nocircs
- public boolean haveValidEntryNode()
public void testNode(java.lang.String finger)
finger
- public final long getBestLatency()
public final java.lang.String getBestHops()
public final java.util.HashMap<java.lang.String,TorCircuit> getBuiltCircuits(boolean filtered)
filtered
- Filter out unwanted circuitspublic final boolean verifyControlComms()
public final TorCircuit getLatestCircuit()
public final java.util.ArrayList<java.lang.String> sendCommand(java.lang.String command)
command
- public java.net.Socket createTorSocketToURL(java.lang.String url, boolean nowww)
url
- nowww
- public java.net.Socket createSocks4aSocket(java.lang.String socksaddr, int socksport, java.lang.String remotehost, int remoteport)
socksaddr
- Socks ip addresssocksport
- Socks portremotehost
- Remote hostremoteport
- Remote port