Class ModuleLoader


  • public class ModuleLoader
    extends java.lang.Object
    Class that implements the logic for downloading and loading signed, prebuilt modules for WireGuard into the running kernel.
    • Constructor Summary

      Constructors 
      Constructor Description
      ModuleLoader​(android.content.Context context, RootShell rootShell, java.lang.String userAgent)
      Public constructor for ModuleLoader
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Integer download()
      Download the correct WireGuard module for the device
      static boolean isModuleLoaded()
      Check whether a WireGuard module is already loaded into the kernel.
      void loadModule()
      Load the downloaded module.
      boolean moduleMightExist()
      Check if the module might already exist in the app's data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ModuleLoader

        public ModuleLoader​(android.content.Context context,
                            RootShell rootShell,
                            java.lang.String userAgent)
        Public constructor for ModuleLoader
        Parameters:
        context - A Context instance.
        rootShell - A RootShell instance used to run elevated commands required for module loading.
        userAgent - A String that represents the User-Agent string used for connections to the upstream server.
    • Method Detail

      • isModuleLoaded

        public static boolean isModuleLoaded()
        Check whether a WireGuard module is already loaded into the kernel.
        Returns:
        boolean indicating if WireGuard is already enabled in the kernel.
      • download

        public java.lang.Integer download()
                                   throws java.io.IOException,
                                          RootShell.RootShellException,
                                          java.security.NoSuchAlgorithmException
        Download the correct WireGuard module for the device
        Returns:
        OsConstants.EXIT_SUCCESS if everything succeeds, ENOENT otherwise.
        Throws:
        java.io.IOException - if the remote hash list was not found or empty.
        RootShell.RootShellException - if RootShell has a failure executing elevated commands.
        java.security.NoSuchAlgorithmException - if SHA256 algorithm is not available in device JDK.
      • moduleMightExist

        public boolean moduleMightExist()
        Check if the module might already exist in the app's data.
        Returns:
        boolean indicating whether downloadable module might exist already.