summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/config/Attribute.java7
-rw-r--r--app/src/main/java/com/wireguard/config/IPCidr.java13
-rw-r--r--app/src/main/java/com/wireguard/config/Interface.java6
-rw-r--r--app/src/main/java/com/wireguard/config/Peer.java15
4 files changed, 23 insertions, 18 deletions
diff --git a/app/src/main/java/com/wireguard/config/Attribute.java b/app/src/main/java/com/wireguard/config/Attribute.java
index 695caeda..5ecd21f4 100644
--- a/app/src/main/java/com/wireguard/config/Attribute.java
+++ b/app/src/main/java/com/wireguard/config/Attribute.java
@@ -7,6 +7,7 @@ import java.lang.reflect.Method;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -88,17 +89,13 @@ enum Attribute {
}
public String composeWith(final int value) {
- return String.format("%s = %d%n", token, value);
+ return String.format(Locale.getDefault(), "%s = %d%n", token, value);
}
public <T> String composeWith(final List<T> value) {
return String.format("%s = %s%n", token, listToString(value));
}
- public String getToken() {
- return token;
- }
-
public String parse(final CharSequence line) {
final Matcher matcher = pattern.matcher(line);
return matcher.matches() ? matcher.group(1) : null;
diff --git a/app/src/main/java/com/wireguard/config/IPCidr.java b/app/src/main/java/com/wireguard/config/IPCidr.java
index aeb5fb36..569fd410 100644
--- a/app/src/main/java/com/wireguard/config/IPCidr.java
+++ b/app/src/main/java/com/wireguard/config/IPCidr.java
@@ -6,10 +6,11 @@ import android.os.Parcelable;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
+import java.util.Locale;
public class IPCidr implements Parcelable {
- InetAddress address;
- int cidr;
+ private InetAddress address;
+ private int cidr;
public static final Parcelable.Creator<IPCidr> CREATOR = new Parcelable.Creator<IPCidr>() {
@@ -24,7 +25,7 @@ public class IPCidr implements Parcelable {
}
};
- public IPCidr(String in) {
+ IPCidr(String in) {
parse(in);
}
@@ -35,7 +36,7 @@ public class IPCidr implements Parcelable {
try {
cidr = Integer.parseInt(in.substring(slash + 1), 10);
in = in.substring(0, slash);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
address = Attribute.parseIPString(in);
@@ -55,7 +56,7 @@ public class IPCidr implements Parcelable {
@Override
public String toString() {
- return String.format("%s/%d", address.getHostAddress(), cidr);
+ return String.format(Locale.getDefault(), "%s/%d", address.getHostAddress(), cidr);
}
@Override
@@ -71,7 +72,7 @@ public class IPCidr implements Parcelable {
private IPCidr(final Parcel in) {
try {
parse(in.readString());
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java
index 2ed2b4e6..5b125f51 100644
--- a/app/src/main/java/com/wireguard/config/Interface.java
+++ b/app/src/main/java/com/wireguard/config/Interface.java
@@ -151,7 +151,7 @@ public class Interface implements Parcelable {
for (int i = 0; i < dnsItems; ++i) {
try {
dnsList.add(InetAddress.getByAddress(in.createByteArray()));
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
listenPort = in.readInt();
@@ -198,7 +198,7 @@ public class Interface implements Parcelable {
private String getListenPortString() {
if (listenPort == 0)
return null;
- return new Integer(listenPort).toString();
+ return Integer.valueOf(listenPort).toString();
}
public int getMtu() {
@@ -208,7 +208,7 @@ public class Interface implements Parcelable {
private String getMtuString() {
if (mtu == 0)
return null;
- return new Integer(mtu).toString();
+ return Integer.toString(mtu);
}
public String getPrivateKey() {
diff --git a/app/src/main/java/com/wireguard/config/Peer.java b/app/src/main/java/com/wireguard/config/Peer.java
index 5c506b36..28495f46 100644
--- a/app/src/main/java/com/wireguard/config/Peer.java
+++ b/app/src/main/java/com/wireguard/config/Peer.java
@@ -15,6 +15,7 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
/**
* Represents the configuration for a WireGuard peer (a [Peer] block).
@@ -167,7 +168,7 @@ public class Peer implements Parcelable {
private String getEndpointString() {
if (endpoint == null)
return null;
- return String.format("%s:%d", endpoint.getHostString(), endpoint.getPort());
+ return String.format(Locale.getDefault(), "%s:%d", endpoint.getHostString(), endpoint.getPort());
}
public String getResolvedEndpointString() throws UnknownHostException {
@@ -178,8 +179,14 @@ public class Peer implements Parcelable {
if (endpoint.isUnresolved())
throw new UnknownHostException(endpoint.getHostString());
if (endpoint.getAddress() instanceof Inet6Address)
- return String.format("[%s]:%d", endpoint.getAddress().getHostAddress(), endpoint.getPort());
- return String.format("%s:%d", endpoint.getAddress().getHostAddress(), endpoint.getPort());
+ return String.format(Locale.getDefault(),
+ "[%s]:%d",
+ endpoint.getAddress().getHostAddress(),
+ endpoint.getPort());
+ return String.format(Locale.getDefault(),
+ "%s:%d",
+ endpoint.getAddress().getHostAddress(),
+ endpoint.getPort());
}
public int getPersistentKeepalive() {
@@ -189,7 +196,7 @@ public class Peer implements Parcelable {
private String getPersistentKeepaliveString() {
if (persistentKeepalive == 0)
return null;
- return new Integer(persistentKeepalive).toString();
+ return Integer.valueOf(persistentKeepalive).toString();
}
public String getPreSharedKey() {