Class UnixTorWrapper

java.lang.Object
org.briarproject.onionwrapper.UnixTorWrapper
All Implemented Interfaces:
net.freehaven.tor.control.EventHandler, org.briarproject.onionwrapper.TorWrapper
Direct Known Subclasses:
MacTorWrapper

@NotNullByDefault public class UnixTorWrapper extends Object
A Tor wrapper for Unix-like operating systems.
  • Field Details

    • ioExecutor

      protected final Executor ioExecutor
    • eventExecutor

      protected final Executor eventExecutor
    • architecture

      protected final String architecture
    • torDirectory

      protected final File torDirectory
    • state

      protected final org.briarproject.onionwrapper.AbstractTorWrapper.NetworkState state
  • Constructor Details

    • UnixTorWrapper

      public UnixTorWrapper(Executor ioExecutor, Executor eventExecutor, String architecture, 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 the observer (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 Details

    • getProcessId

      protected int getProcessId()
    • getLastUpdateTime

      protected long getLastUpdateTime()
    • getResourceInputStream

      protected InputStream getResourceInputStream(String name, String extension)
    • getTorExecutableFile

      protected File getTorExecutableFile()
    • getLyrebirdExecutableFile

      public File getLyrebirdExecutableFile()
      Specified by:
      getLyrebirdExecutableFile in interface org.briarproject.onionwrapper.TorWrapper
    • setObserver

      public void setObserver(@Nullable org.briarproject.onionwrapper.TorWrapper.Observer arg0)
      Specified by:
      setObserver in interface org.briarproject.onionwrapper.TorWrapper
    • start

      public void start() throws IOException, InterruptedException
      Specified by:
      start in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
      InterruptedException
    • extract

      protected void extract(InputStream arg0, File arg1) throws IOException
      Throws:
      IOException
    • installTorExecutable

      protected void installTorExecutable() throws IOException
      Throws:
      IOException
    • installLyrebirdExecutable

      protected void installLyrebirdExecutable() throws IOException
      Throws:
      IOException
    • getExecutableInputStream

      protected InputStream getExecutableInputStream(String arg0)
    • getExecutableExtension

      protected String getExecutableExtension()
    • waitForTorToStart

      protected void waitForTorToStart(Process arg0) throws InterruptedException, IOException
      Throws:
      InterruptedException
      IOException
    • publishHiddenService

      public org.briarproject.onionwrapper.TorWrapper.HiddenServiceProperties publishHiddenService(int arg0, int arg1, @Nullable String arg2) throws IOException
      Specified by:
      publishHiddenService in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • removeHiddenService

      public void removeHiddenService(String arg0) throws IOException
      Specified by:
      removeHiddenService in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • enableNetwork

      public void enableNetwork(boolean arg0) throws IOException
      Specified by:
      enableNetwork in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • enableBridges

      public void enableBridges(List<String> arg0) throws IOException
      Specified by:
      enableBridges in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • disableBridges

      public void disableBridges() throws IOException
      Specified by:
      disableBridges in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • stop

      public void stop() throws IOException, InterruptedException
      Specified by:
      stop in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
      InterruptedException
    • circuitStatus

      public void circuitStatus(String arg0, String arg1, String arg2)
      Specified by:
      circuitStatus in interface net.freehaven.tor.control.EventHandler
    • streamStatus

      public void streamStatus(String arg0, String arg1, String arg2)
      Specified by:
      streamStatus in interface net.freehaven.tor.control.EventHandler
    • orConnStatus

      public void orConnStatus(String arg0, String arg1)
      Specified by:
      orConnStatus in interface net.freehaven.tor.control.EventHandler
    • bandwidthUsed

      public void bandwidthUsed(long arg0, long arg1)
      Specified by:
      bandwidthUsed in interface net.freehaven.tor.control.EventHandler
    • newDescriptors

      public void newDescriptors(List<String> arg0)
      Specified by:
      newDescriptors in interface net.freehaven.tor.control.EventHandler
    • message

      public void message(String arg0, String arg1)
      Specified by:
      message in interface net.freehaven.tor.control.EventHandler
    • unrecognized

      public void unrecognized(String arg0, String arg1)
      Specified by:
      unrecognized in interface net.freehaven.tor.control.EventHandler
    • controlConnectionClosed

      public void controlConnectionClosed()
      Specified by:
      controlConnectionClosed in interface net.freehaven.tor.control.EventHandler
    • enableConnectionPadding

      public void enableConnectionPadding(boolean arg0) throws IOException
      Specified by:
      enableConnectionPadding in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • enableIpv6

      public void enableIpv6(boolean arg0) throws IOException
      Specified by:
      enableIpv6 in interface org.briarproject.onionwrapper.TorWrapper
      Throws:
      IOException
    • getTorState

      public org.briarproject.onionwrapper.TorWrapper.TorState getTorState()
      Specified by:
      getTorState in interface org.briarproject.onionwrapper.TorWrapper
    • isTorRunning

      public boolean isTorRunning()
      Specified by:
      isTorRunning in interface org.briarproject.onionwrapper.TorWrapper