summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/config/Peer.java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2018-04-27 22:03:39 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2018-04-28 06:07:48 +0200
commit217ab5e17f31d78a41c575783c0779a54aafff63 (patch)
tree58a988282cda52a6ef0eadcd207eac854b93e649 /app/src/main/java/com/wireguard/config/Peer.java
parentba862b166bd30de8c15593ed3b8dfd457eb39d36 (diff)
config: Minor cleanup
- Stop implicitly assuming locales in String.format - Cleanup method visibilities - Improve uses of Integer methods - Remove unused getToken method Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/wireguard/config/Peer.java')
-rw-r--r--app/src/main/java/com/wireguard/config/Peer.java15
1 files changed, 11 insertions, 4 deletions
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() {