Interface TorWrapper
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic interfaceAn interface for observing changes to thestateof the Tor process.static enumThe state of the Tor wrapper. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigures Tor not to use bridges for connecting to the Tor network.voidenableBridges(List<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.Returns the Lyrebird executable as a File for use with Moat.Returns the current state of the wrapper.booleanpublishHiddenService(int localPort, int remotePort, String privateKey) Publishes an ephemeral hidden service.voidremoveHiddenService(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 waits for it to stop before returning.
-
Field Details
-
LOG
-
-
Method Details
-
start
Starts the Tor process, but does not yet connect to the Tor network. CallenableNetwork(boolean)for this.This method waits for the Tor process to start before returning. Methods that modify the wrapper's configuration (
publishHiddenService(int, int, String),removeHiddenService(String),enableNetwork(boolean),enableBridges(List),enableConnectionPadding(boolean),enableIpv6(boolean)) should be called after this method returns.Do not call this method concurrently with
stop().- Throws:
IOExceptionInterruptedException
-
stop
Tell the Tor process to stop and waits for it to stop before returning.The wrapper's configuration is reset, so if the wrapper is reused by calling
start()again then any configuration applied viaenableNetwork(boolean)etc must be applied again.Do not call this method concurrently with
start().- Throws:
IOExceptionInterruptedException
-
setObserver
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 String privateKey) throws 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:
IOException
-
removeHiddenService
Removes (unpublishes) an ephemeral hidden service that was created by callingpublishHiddenService(int, int, String).- Throws:
IOException
-
enableNetwork
Enables or disables the Tor process's network connection. The network connection is disabled by default.- Throws:
IOException
-
enableBridges
Configures 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:
IOException
-
disableBridges
Configures Tor not to use bridges for connecting to the Tor network. Bridges are not used by default.- Throws:
IOException
-
enableConnectionPadding
Enables or disables connection padding. Padding is disabled by default.- Throws:
IOException
-
enableIpv6
Configures Tor to use IPv6 or IPv4 for connecting to the Tor network. IPv4 is used by default.- Throws:
IOException
-
getLyrebirdExecutableFile
File getLyrebirdExecutableFile()Returns the Lyrebird executable as a File for use with Moat.
-