summaryrefslogtreecommitdiffhomepage
path: root/tunnel
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-30 13:57:43 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-30 13:57:43 -0600
commitd74b988f7586ce648be6860a21b22ff5370fb597 (patch)
treed92cc688df5e6fb924d317c25a61f214378b061c /tunnel
parent10e910186e1ae7f4b5336f0a5e81f0a2e411e61f (diff)
global: cleanup code style
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel')
-rw-r--r--tunnel/src/main/AndroidManifest.xml3
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/BackendException.java1
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java1
-rw-r--r--tunnel/src/main/java/com/wireguard/android/util/RootShell.java1
-rw-r--r--tunnel/src/test/java/com/wireguard/config/BadConfigExceptionTest.java19
-rw-r--r--tunnel/src/test/java/com/wireguard/config/ConfigTest.java20
6 files changed, 27 insertions, 18 deletions
diff --git a/tunnel/src/main/AndroidManifest.xml b/tunnel/src/main/AndroidManifest.xml
index 111e5e2d..ba9cc77c 100644
--- a/tunnel/src/main/AndroidManifest.xml
+++ b/tunnel/src/main/AndroidManifest.xml
@@ -5,8 +5,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wireguard.android.tunnel">
+
<application>
- <service
+ <service
android:name="com.wireguard.android.backend.GoBackend$VpnService"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java b/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
index 55fdb602..5552b3ee 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/BackendException.java
@@ -11,6 +11,7 @@ import com.wireguard.util.NonNullForAll;
public final class BackendException extends Exception {
private final Object[] format;
private final Reason reason;
+
public BackendException(final Reason reason, final Object... format) {
this.reason = reason;
this.format = format;
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
index 34008f45..019bc980 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -42,6 +42,7 @@ public final class GoBackend implements Backend {
@Nullable private Config currentConfig;
@Nullable private Tunnel currentTunnel;
private int currentTunnelHandle = -1;
+
public GoBackend(final Context context) {
SharedLibraryLoader.loadSharedLibrary(context, "wg-go");
this.context = context;
diff --git a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
index 9c175552..6fe89a83 100644
--- a/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
+++ b/tunnel/src/main/java/com/wireguard/android/util/RootShell.java
@@ -189,6 +189,7 @@ public class RootShell {
public static class RootShellException extends Exception {
private final Object[] format;
private final Reason reason;
+
public RootShellException(final Reason reason, final Object... format) {
this.reason = reason;
this.format = format;
diff --git a/tunnel/src/test/java/com/wireguard/config/BadConfigExceptionTest.java b/tunnel/src/test/java/com/wireguard/config/BadConfigExceptionTest.java
index 54935510..3743852d 100644
--- a/tunnel/src/test/java/com/wireguard/config/BadConfigExceptionTest.java
+++ b/tunnel/src/test/java/com/wireguard/config/BadConfigExceptionTest.java
@@ -18,9 +18,11 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
public class BadConfigExceptionTest {
+ private static final Map<String, InputStream> CONFIG_MAP = new HashMap<>();
private static final String[] CONFIG_NAMES = {
"invalid-key",
"invalid-number",
@@ -31,14 +33,6 @@ public class BadConfigExceptionTest {
"unknown-attribute",
"unknown-section"
};
- private static final Map<String, InputStream> CONFIG_MAP = new HashMap<>();
-
- @BeforeClass
- public static void readConfigs() {
- for (final String config: CONFIG_NAMES) {
- CONFIG_MAP.put(config, BadConfigExceptionTest.class.getClassLoader().getResourceAsStream(config + ".conf"));
- }
- }
@AfterClass
public static void closeStreams() {
@@ -50,6 +44,13 @@ public class BadConfigExceptionTest {
}
}
+ @BeforeClass
+ public static void readConfigs() {
+ for (final String config : CONFIG_NAMES) {
+ CONFIG_MAP.put(config, BadConfigExceptionTest.class.getClassLoader().getResourceAsStream(config + ".conf"));
+ }
+ }
+
@Test
public void throws_correctly_with_INVALID_KEY_reason() {
try {
diff --git a/tunnel/src/test/java/com/wireguard/config/ConfigTest.java b/tunnel/src/test/java/com/wireguard/config/ConfigTest.java
index 6d599217..693a37ea 100644
--- a/tunnel/src/test/java/com/wireguard/config/ConfigTest.java
+++ b/tunnel/src/test/java/com/wireguard/config/ConfigTest.java
@@ -5,7 +5,6 @@
package com.wireguard.config;
-import static org.junit.Assert.*;
import org.junit.Test;
import java.io.IOException;
@@ -15,8 +14,20 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public class ConfigTest {
+ @Test(expected = BadConfigException.class)
+ public void invalid_config_throws() throws IOException, BadConfigException {
+ try (final InputStream is = Objects.requireNonNull(getClass().getClassLoader()).getResourceAsStream("broken.conf")) {
+ Config.parse(is);
+ }
+ }
+
@Test
public void valid_config_parses_correctly() throws IOException, ParseException {
Config config = null;
@@ -35,11 +46,4 @@ public class ConfigTest {
assertEquals("Test config's allowed IPs are 0.0.0.0/0 and ::0/0", config.getPeers().get(0).getAllowedIps(), expectedAllowedIps);
assertEquals("Test config has one DNS server", 1, config.getInterface().getDnsServers().size());
}
-
- @Test(expected = BadConfigException.class)
- public void invalid_config_throws() throws IOException, BadConfigException {
- try (final InputStream is = Objects.requireNonNull(getClass().getClassLoader()).getResourceAsStream("broken.conf")) {
- Config.parse(is);
- }
- }
}