Package com.wireguard.android.util
Class ModuleLoader
- java.lang.Object
-
- com.wireguard.android.util.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 devicestatic 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.
-
-
-
Constructor Detail
-
ModuleLoader
public ModuleLoader(android.content.Context context, RootShell rootShell, java.lang.String userAgent)
Public constructor for ModuleLoader- Parameters:
context
- AContext
instance.rootShell
- ARootShell
instance used to run elevated commands required for module loading.userAgent
- AString
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
- ifRootShell
has a failure executing elevated commands.java.security.NoSuchAlgorithmException
- if SHA256 algorithm is not available in device JDK.
-
loadModule
public void loadModule() throws java.io.IOException, RootShell.RootShellException
Load the downloaded module. ModuleLoader#download must be called before this.- Throws:
java.io.IOException
- ifRootShell
has a failure executing elevated commands.RootShell.RootShellException
- ifRootShell
has a failure executing elevated commands.
-
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.
-
-