public class TorProcess extends ClientProcess
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMPTYSTRING |
static int |
LOG_DEBUG |
static int |
LOG_INFO |
static int |
LOG_NOTICE |
static int |
TOR_BOOT_ERROR |
static int |
TOR_BOOT_FATAL |
static int |
TOR_BOOT_TIMEOUT |
static int |
TOR_BOOTED |
static int |
TOR_BRIDGE |
static int |
TOR_CLOCK_ERROR |
static int |
TOR_DIRINFO_STALE |
static int |
TOR_MESSAGE |
static int |
TOR_NEWCIRC |
static int |
TOR_NOEXITS |
static int |
TOR_NOHOP0 |
static int |
TOR_NONET_ACTIVITY |
static int |
TOR_NOROUTE |
static int |
TOR_RESTARTED |
static int |
TOR_STOPPED |
CLIENT_RUNNING, CLIENT_STOPPED, CLIENT_TIMEDOUT
Constructor and Description |
---|
TorProcess(java.lang.String clientpath,
java.lang.String configfolder)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clearCLIOption(java.lang.String option)
Remove previously add tor option
|
void |
clearStdout()
Clear the Stdout text area
|
void |
clearTorrcOption(java.lang.String option)
Remove previously add torrc option
|
void |
clientProcessEventFired(java.lang.String data)
Client event handler, can be overriden by parent class
|
void |
createDataFolder()
Creates a data folder for the Tor client to put its cache data
|
void |
createDefaultConfig()
Creates the default Tor config file
|
void |
deleteCacheData()
Delete Tor cache data
|
void |
deleteConfigFile()
Delete the configuration file
|
java.lang.String |
getBridges()
Get bridges
|
float |
getCacheAge()
Get the age of the file cache in minutes
|
java.lang.String |
getCachedDataFolder()
Get the currently set cached data folder
|
java.lang.String |
getClientLocation()
Get Tor client location as a filepath
|
boolean |
getCLIOptionBool(java.lang.String option)
Get a previously added tor option boolean value
|
java.lang.String |
getCLIOptions(java.lang.String option)
Get a previously added tor option string
|
java.lang.String |
getCLIOptionsAsString()
Gets all the currently set tor options as single String for use as
arguments passed to tor client
|
java.lang.String |
getConfigFilePath()
Get the path to the configuration file
|
int |
getControlPort()
Get the control port
|
java.lang.String |
getDataFolder()
Get the datafolder being used by tor client
|
java.lang.String |
getEventMessage(int event)
Get textual representation on an event
|
int |
getListenPort()
Get the listening port
|
java.lang.String |
getOwnershipID()
Return the currently set process ownership ID
|
java.lang.String |
getSecret()
Get the currently set authentification secret
|
java.lang.String |
getTorrcOption(java.lang.String option)
Get a previously added tor option string
|
java.lang.String |
getTorrcOptionsAsString()
Gets all the currently set torrc options as single String
|
float |
getVersion()
Get Tor version as float
|
void |
setBoolTorOption(java.lang.String option,
boolean value)
Add a tor option boolean value
|
void |
setBridges(java.lang.String bridges)
Set Tor bridges, supports multiple addresses
|
void |
setCachedDataFolder(int port)
This populates the the current folder whose name is derived from the
listening port with data from the given source folder derived by the
given port number.
|
void |
setCLIOption(java.lang.String option,
java.lang.String value)
Add a tor option string which is passed to the tor client on startup.
|
void |
setControlPassword(java.lang.String secret,
java.lang.String hashpass) |
void |
setExternalArgs(java.lang.String torargs)
Set external user provided startup arguments
|
void |
setGeoIP4(java.lang.String filepath)
Set the path to the geoip file
|
void |
setGeoIP6(java.lang.String filepath)
Set the path to the geoip file
|
void |
setInitialBootEvent(int event)
Set the event that is issued on process boot completion
|
void |
setListenPort(int port)
Set the listening port
|
void |
setLogLevel(int lev)
Set the Tor stdout log level
|
void |
setMaxHistory(int lines)
Set the maximum no of lines to display in the Stdout output
|
void |
setOwnershipID(java.lang.String processid)
Set Ownership process id, useful for proper process termination in event
of a crash
|
void |
setSilentBootEnabled(boolean enabled)
Enable/Disable bootstrap message events on startup
|
void |
setStdoutTextArea(javax.swing.JTextArea jta)
Set the text area that will receive Stdout output
|
void |
setTorrcOption(java.lang.String option,
java.lang.String value)
Add a torrc option string See Tor documentation for valid options.
|
void |
startProcess()
Starts Tor process, and issues booted event on completion
|
void |
torProcessEventFired(int event,
java.lang.String data)
Called if an event was fired, will be overidden by sub class
|
boolean |
validateBridges(java.lang.String bridges)
Validate bridge addresses
|
boolean |
validateHostPort(java.lang.String hostport)
Validate a host:port ipv4 address
|
getClientStatus, getProcess, sendMessage, setStartupDelay, setStartupTimeout, start, stopProcess
public static final int LOG_DEBUG
public static final int LOG_INFO
public static final int LOG_NOTICE
public static final java.lang.String EMPTYSTRING
public static final int TOR_MESSAGE
public static final int TOR_BOOT_TIMEOUT
public static final int TOR_BOOT_FATAL
public static final int TOR_BOOT_ERROR
public static final int TOR_CLOCK_ERROR
public static final int TOR_NOROUTE
public static final int TOR_BOOTED
public static final int TOR_RESTARTED
public static final int TOR_NOEXITS
public static final int TOR_STOPPED
public static final int TOR_BRIDGE
public static final int TOR_NEWCIRC
public static final int TOR_DIRINFO_STALE
public static final int TOR_NOHOP0
public static final int TOR_NONET_ACTIVITY
public TorProcess(java.lang.String clientpath, java.lang.String configfolder)
clientpath
- Path to Tor clientconfigfolder
- Filepath to torrcpublic final void startProcess()
public final void setLogLevel(int lev)
lev
- public final void setExternalArgs(java.lang.String torargs)
torargs
- public final void setListenPort(int port)
port
- public final void setInitialBootEvent(int event)
event
- public final void clientProcessEventFired(java.lang.String data)
clientProcessEventFired
in class ClientProcess
data
- line data from standard output of Tor clientpublic final void setSilentBootEnabled(boolean enabled)
enabled
- public java.lang.String getEventMessage(int event)
event
- public void torProcessEventFired(int event, java.lang.String data)
event
- data
- public final void setControlPassword(java.lang.String secret, java.lang.String hashpass)
public final java.lang.String getSecret()
public final void setBridges(java.lang.String bridges)
bridges
- public boolean validateBridges(java.lang.String bridges)
bridges
- public final boolean validateHostPort(java.lang.String hostport)
hostport
- public final java.lang.String getBridges()
public void setOwnershipID(java.lang.String processid)
processid
- public java.lang.String getOwnershipID()
public final void setGeoIP4(java.lang.String filepath)
filepath
- File locationpublic final void setGeoIP6(java.lang.String filepath)
filepath
- File locationpublic final java.lang.String getClientLocation()
public final java.lang.String getConfigFilePath()
public final java.lang.String getCLIOptions(java.lang.String option)
option
- Tor option keypublic final void setCLIOption(java.lang.String option, java.lang.String value)
option
- value
- public final void setBoolTorOption(java.lang.String option, boolean value)
option
- value
- public final java.lang.String getTorrcOption(java.lang.String option)
option
- Tor option keypublic final void setTorrcOption(java.lang.String option, java.lang.String value)
option
- value
- public final java.lang.String getTorrcOptionsAsString()
public final void clearTorrcOption(java.lang.String option)
option
- public final boolean getCLIOptionBool(java.lang.String option)
option
- Tor option keypublic final void clearCLIOption(java.lang.String option)
option
- public final java.lang.String getCLIOptionsAsString()
public final int getListenPort()
public final int getControlPort()
public final void createDefaultConfig()
public final void deleteConfigFile()
public final void createDataFolder()
public final java.lang.String getDataFolder()
public float getCacheAge()
public final void deleteCacheData()
public final void setCachedDataFolder(int port)
port
- public final java.lang.String getCachedDataFolder()
public void setStdoutTextArea(javax.swing.JTextArea jta)
jta
- public void setMaxHistory(int lines)
lines
- public void clearStdout()
public final float getVersion()