Package org.briarproject.onionwrapper
Class UnixTorWrapper
- java.lang.Object
-
- org.briarproject.onionwrapper.UnixTorWrapper
-
- All Implemented Interfaces:
net.freehaven.tor.control.EventHandler,org.briarproject.onionwrapper.TorWrapper
@NotNullByDefault public class UnixTorWrapper extends java.lang.ObjectA Tor wrapper for Unix-like operating systems.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutoreventExecutorprotected java.util.concurrent.ExecutorioExecutorprotected org.briarproject.onionwrapper.AbstractTorWrapper.NetworkStatestate
-
Constructor Summary
Constructors Constructor Description UnixTorWrapper(java.util.concurrent.Executor ioExecutor, java.util.concurrent.Executor eventExecutor, java.lang.String architecture, java.io.File torDirectory, int torSocksPort, int torControlPort)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbandwidthUsed(long arg0, long arg1)voidcircuitStatus(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)voidcontrolConnectionClosed()voiddisableBridges()voidenableBridges(java.util.List<java.lang.String> arg0)voidenableConnectionPadding(boolean arg0)voidenableIpv6(boolean arg0)voidenableNetwork(boolean arg0)protected voidextract(java.io.InputStream arg0, java.io.File arg1)protected java.lang.StringgetExecutableExtension()protected longgetLastUpdateTime()java.io.FilegetObfs4ExecutableFile()protected intgetProcessId()protected java.io.InputStreamgetResourceInputStream(java.lang.String name, java.lang.String extension)protected java.io.FilegetSnowflakeExecutableFile()protected java.io.FilegetTorExecutableFile()org.briarproject.onionwrapper.TorWrapper.TorStategetTorState()protected voidinstallObfs4Executable()protected voidinstallSnowflakeExecutable()protected voidinstallTorExecutable()booleanisTorRunning()voidmessage(java.lang.String arg0, java.lang.String arg1)voidnewDescriptors(java.util.List<java.lang.String> arg0)voidorConnStatus(java.lang.String arg0, java.lang.String arg1)org.briarproject.onionwrapper.TorWrapper.HiddenServicePropertiespublishHiddenService(int arg0, int arg1, java.lang.String arg2)voidremoveHiddenService(java.lang.String arg0)voidsetObserver(org.briarproject.onionwrapper.TorWrapper.Observer arg0)voidstart()voidstop()voidstreamStatus(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)voidunrecognized(java.lang.String arg0, java.lang.String arg1)protected voidwaitForTorToStart(java.lang.Process arg0)
-
-
-
Constructor Detail
-
UnixTorWrapper
public UnixTorWrapper(java.util.concurrent.Executor ioExecutor, java.util.concurrent.Executor eventExecutor, java.lang.String architecture, java.io.File torDirectory, int torSocksPort, int torControlPort)- Parameters:
ioExecutor- The wrapper will use this executor to run IO tasks, some of which may run for the lifetime of the wrapper, so the executor should have an unlimited thread pool.eventExecutor- The wrapper will use this executor to call theobserver(if any). To ensure that events are observed in the order they occur, this executor should have a single thread (eg the app's main thread).architecture- The processor architecture of the Tor and pluggable transport binaries.torDirectory- The directory where the Tor process should keep its state.torSocksPort- The port number to use for Tor's SOCKS port.torControlPort- The port number to use for Tor's control port.
-
-
Method Detail
-
getProcessId
protected int getProcessId()
-
getLastUpdateTime
protected long getLastUpdateTime()
-
getResourceInputStream
protected java.io.InputStream getResourceInputStream(java.lang.String name, java.lang.String extension)
-
getTorExecutableFile
protected java.io.File getTorExecutableFile()
-
getObfs4ExecutableFile
public java.io.File getObfs4ExecutableFile()
- Specified by:
getObfs4ExecutableFilein interfaceorg.briarproject.onionwrapper.TorWrapper
-
getSnowflakeExecutableFile
protected java.io.File getSnowflakeExecutableFile()
-
setObserver
public void setObserver(@Nullable org.briarproject.onionwrapper.TorWrapper.Observer arg0)- Specified by:
setObserverin interfaceorg.briarproject.onionwrapper.TorWrapper
-
start
public void start() throws java.io.IOException, java.lang.InterruptedException- Specified by:
startin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
extract
protected void extract(java.io.InputStream arg0, java.io.File arg1) throws java.io.IOException- Throws:
java.io.IOException
-
installTorExecutable
protected void installTorExecutable() throws java.io.IOException- Throws:
java.io.IOException
-
installObfs4Executable
protected void installObfs4Executable() throws java.io.IOException- Throws:
java.io.IOException
-
installSnowflakeExecutable
protected void installSnowflakeExecutable() throws java.io.IOException- Throws:
java.io.IOException
-
getExecutableExtension
protected java.lang.String getExecutableExtension()
-
waitForTorToStart
protected void waitForTorToStart(java.lang.Process arg0) throws java.lang.InterruptedException, java.io.IOException- Throws:
java.lang.InterruptedExceptionjava.io.IOException
-
publishHiddenService
public org.briarproject.onionwrapper.TorWrapper.HiddenServiceProperties publishHiddenService(int arg0, int arg1, @Nullable java.lang.String arg2) throws java.io.IOException- Specified by:
publishHiddenServicein interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
removeHiddenService
public void removeHiddenService(java.lang.String arg0) throws java.io.IOException- Specified by:
removeHiddenServicein interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
enableNetwork
public void enableNetwork(boolean arg0) throws java.io.IOException- Specified by:
enableNetworkin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
enableBridges
public void enableBridges(java.util.List<java.lang.String> arg0) throws java.io.IOException- Specified by:
enableBridgesin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
disableBridges
public void disableBridges() throws java.io.IOException- Specified by:
disableBridgesin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
stop
public void stop() throws java.io.IOException, java.lang.InterruptedException- Specified by:
stopin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
circuitStatus
public void circuitStatus(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)- Specified by:
circuitStatusin interfacenet.freehaven.tor.control.EventHandler
-
streamStatus
public void streamStatus(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)- Specified by:
streamStatusin interfacenet.freehaven.tor.control.EventHandler
-
orConnStatus
public void orConnStatus(java.lang.String arg0, java.lang.String arg1)- Specified by:
orConnStatusin interfacenet.freehaven.tor.control.EventHandler
-
bandwidthUsed
public void bandwidthUsed(long arg0, long arg1)- Specified by:
bandwidthUsedin interfacenet.freehaven.tor.control.EventHandler
-
newDescriptors
public void newDescriptors(java.util.List<java.lang.String> arg0)
- Specified by:
newDescriptorsin interfacenet.freehaven.tor.control.EventHandler
-
message
public void message(java.lang.String arg0, java.lang.String arg1)- Specified by:
messagein interfacenet.freehaven.tor.control.EventHandler
-
unrecognized
public void unrecognized(java.lang.String arg0, java.lang.String arg1)- Specified by:
unrecognizedin interfacenet.freehaven.tor.control.EventHandler
-
controlConnectionClosed
public void controlConnectionClosed()
- Specified by:
controlConnectionClosedin interfacenet.freehaven.tor.control.EventHandler
-
enableConnectionPadding
public void enableConnectionPadding(boolean arg0) throws java.io.IOException- Specified by:
enableConnectionPaddingin interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
enableIpv6
public void enableIpv6(boolean arg0) throws java.io.IOException- Specified by:
enableIpv6in interfaceorg.briarproject.onionwrapper.TorWrapper- Throws:
java.io.IOException
-
getTorState
public org.briarproject.onionwrapper.TorWrapper.TorState getTorState()
- Specified by:
getTorStatein interfaceorg.briarproject.onionwrapper.TorWrapper
-
isTorRunning
public boolean isTorRunning()
- Specified by:
isTorRunningin interfaceorg.briarproject.onionwrapper.TorWrapper
-
-