Class AndroidTorWrapper

  • All Implemented Interfaces:
    net.freehaven.tor.control.EventHandler, org.briarproject.onionwrapper.TorWrapper

    @NotNullByDefault
    public class AndroidTorWrapper
    extends Object
    A Tor wrapper for the Android operating system.
    • Field Detail

      • ioExecutor

        protected final Executor ioExecutor
      • eventExecutor

        protected final Executor eventExecutor
      • state

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

      • AndroidTorWrapper

        public AndroidTorWrapper​(Application app,
                                 org.briarproject.android.dontkillmelib.wakelock.AndroidWakeLockManager wakeLockManager,
                                 Executor ioExecutor,
                                 Executor eventExecutor,
                                 String architecture,
                                 File torDirectory,
                                 int torSocksPort,
                                 int torControlPort)
        Parameters:
        app - The application instance.
        wakeLockManager - The interface for managing a shared wake lock.
        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 Detail

      • getProcessId

        protected int getProcessId()
      • getLastUpdateTime

        protected long getLastUpdateTime()
      • enableNetwork

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

        protected File getTorExecutableFile()
      • getObfs4ExecutableFile

        public File getObfs4ExecutableFile()
        Specified by:
        getObfs4ExecutableFile in interface org.briarproject.onionwrapper.TorWrapper
      • getSnowflakeExecutableFile

        protected File getSnowflakeExecutableFile()
      • installSnowflakeExecutable

        protected void installSnowflakeExecutable()
                                           throws IOException
        Throws:
        IOException
      • setObserver

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

        protected String getExecutableExtension()
      • 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
      • 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
      • 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