Package org.briarproject.onionwrapper
Interface TorWrapper
-
@NotNullByDefault public interface TorWrapper
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTorWrapper.HiddenServicePropertiesstatic interfaceTorWrapper.ObserverAn interface for observing changes to thestateof the Tor process.static classTorWrapper.TorStateThe state of the Tor wrapper.
-
Field Summary
Fields Modifier and Type Field Description static java.util.logging.LoggerLOG
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddisableBridges()Configures Tor not to use bridges for connecting to the Tor network.voidenableBridges(java.util.List<java.lang.String> bridges)Configures Tor to use the given list of bridges for connecting to the Tor network.voidenableConnectionPadding(boolean enable)Enables or disables connection padding.voidenableIpv6(boolean ipv6Only)Configures Tor to use IPv6 or IPv4 for connecting to the Tor network.voidenableNetwork(boolean enable)Enables or disables the Tor process's network connection.java.io.FilegetObfs4ExecutableFile()Returns the Obfs4 executable as a File for use with Moat.TorWrapper.TorStategetTorState()Returns the current state of the wrapper.booleanisTorRunning()TorWrapper.HiddenServicePropertiespublishHiddenService(int localPort, int remotePort, java.lang.String privateKey)Publishes an ephemeral hidden service.voidremoveHiddenService(java.lang.String onion)Removes (unpublishes) an ephemeral hidden service that was created by callingpublishHiddenService(int, int, String).voidsetObserver(TorWrapper.Observer observer)Sets an observer for observing the state of the wrapper, replacing any existing observer, or removes any existing observer if the argument is null.voidstart()Starts the Tor process, but does not yet connect to the Tor Network.voidstop()Tell the Tor process to stop and returns without waiting for the process to exit.
-
-
-
Method Detail
-
start
void start() throws java.io.IOException, java.lang.InterruptedExceptionStarts the Tor process, but does not yet connect to the Tor Network. CallenableNetwork(boolean)for this.This method must only be called once. To restart the Tor process, stop this wrapper instance and then create a new instance.
- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
stop
void stop() throws java.io.IOException
Tell the Tor process to stop and returns without waiting for the process to exit.- Throws:
java.io.IOException
-
setObserver
void setObserver(@Nullable TorWrapper.Observer observer)Sets an observer for observing the state of the wrapper, replacing any existing observer, or removes any existing observer if the argument is null.
-
getTorState
TorWrapper.TorState getTorState()
Returns the current state of the wrapper.
-
isTorRunning
boolean isTorRunning()
-
publishHiddenService
TorWrapper.HiddenServiceProperties publishHiddenService(int localPort, int remotePort, @Nullable java.lang.String privateKey) throws java.io.IOException
Publishes an ephemeral hidden service.- Parameters:
localPort- The local port on which the service is listening.remotePort- The port number that clients of the service will see.privateKey- The private key of the hidden service, in the form returned by a previous call to this method, or null if a new service should be created.- Throws:
java.io.IOException
-
removeHiddenService
void removeHiddenService(java.lang.String onion) throws java.io.IOExceptionRemoves (unpublishes) an ephemeral hidden service that was created by callingpublishHiddenService(int, int, String).- Throws:
java.io.IOException
-
enableNetwork
void enableNetwork(boolean enable) throws java.io.IOExceptionEnables or disables the Tor process's network connection. The network connection is disabled by default.- Throws:
java.io.IOException
-
enableBridges
void enableBridges(java.util.List<java.lang.String> bridges) throws java.io.IOExceptionConfigures Tor to use the given list of bridges for connecting to the Tor network. Bridges are not used by default.Each item in the list should be a bridge line in the same format that would be used in a torrc file (including the Bridge keyword).
- Throws:
java.io.IOException
-
disableBridges
void disableBridges() throws java.io.IOExceptionConfigures Tor not to use bridges for connecting to the Tor network. Bridges are not used by default.- Throws:
java.io.IOException
-
enableConnectionPadding
void enableConnectionPadding(boolean enable) throws java.io.IOExceptionEnables or disables connection padding. Padding is disabled by default.- Throws:
java.io.IOException
-
enableIpv6
void enableIpv6(boolean ipv6Only) throws java.io.IOExceptionConfigures Tor to use IPv6 or IPv4 for connecting to the Tor network. IPv4 is used by default.- Throws:
java.io.IOException
-
getObfs4ExecutableFile
java.io.File getObfs4ExecutableFile()
Returns the Obfs4 executable as a File for use with Moat.
-
-