summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-23 18:02:37 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-23 18:02:37 -0500
commit0e46f9566838c529ad5b43034ea1e6686f6c7d8b (patch)
treedf81b87a01bffb55ed2a17e9e1ce4a3f13598be7 /app/src
parentd3e6b311cafc13c627201220d183d07ef748f2bb (diff)
Config/Interface: Allow copyFrom() to work on null
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/config/Config.java21
-rw-r--r--app/src/main/java/com/wireguard/config/Interface.java18
2 files changed, 28 insertions, 11 deletions
diff --git a/app/src/main/java/com/wireguard/config/Config.java b/app/src/main/java/com/wireguard/config/Config.java
index c7fdcc87..8f61dbdd 100644
--- a/app/src/main/java/com/wireguard/config/Config.java
+++ b/app/src/main/java/com/wireguard/config/Config.java
@@ -61,12 +61,21 @@ public class Config extends BaseObservable
@Override
public void copyFrom(final Config source) {
- iface.copyFrom(source.iface);
- isEnabled = source.isEnabled;
- name = source.name;
- peers.clear();
- for (final Peer peer : source.peers)
- addPeer(peer);
+ if (source != null) {
+ iface.copyFrom(source.iface);
+ isEnabled = source.isEnabled;
+ isPrimary = source.isPrimary;
+ name = source.name;
+ peers.clear();
+ for (final Peer peer : source.peers)
+ addPeer(peer);
+ } else {
+ iface.copyFrom(null);
+ isEnabled = false;
+ isPrimary = false;
+ name = null;
+ peers.clear();
+ }
}
public Interface getInterface() {
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java
index 0ab15a7d..b81b6d99 100644
--- a/app/src/main/java/com/wireguard/config/Interface.java
+++ b/app/src/main/java/com/wireguard/config/Interface.java
@@ -29,11 +29,19 @@ public class Interface extends BaseObservable implements Copyable<Interface>, Ob
@Override
public void copyFrom(final Interface source) {
- address = source.address;
- dns = source.dns;
- listenPort = source.listenPort;
- setPrivateKey(source.privateKey);
- mtu = source.mtu;
+ if (source != null) {
+ address = source.address;
+ dns = source.dns;
+ listenPort = source.listenPort;
+ mtu = source.mtu;
+ setPrivateKey(source.privateKey);
+ } else {
+ address = null;
+ dns = null;
+ listenPort = null;
+ mtu = null;
+ setPrivateKey(null);
+ }
}
public void generateKeypair() {