diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-28 23:13:31 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-10-28 23:13:31 +0200 |
commit | e0a8b92c42ff86fdd6ee4ba9fce4bd2a32059310 (patch) | |
tree | 99ae058713bf6db73f8ba33866a179d50d2db30b | |
parent | af7b47dba9670b276b6dd2ddd2e1f20ea6763bd0 (diff) |
WIP: tunnel: reduce code duplication
-rw-r--r-- | ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt index 55c84df5..97aae280 100644 --- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt +++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt @@ -203,22 +203,7 @@ class ObservableTunnel internal constructor( private fun onEndpointChanged(publicKey: Key, newEndpoint: InetEndpoint?) { Log.i(TAG, "ObservableTunnel onEndpointChange " + newEndpoint) - var peer: PeerDetail? = null - - configDetail?.peers?.forEach { - if (it.publicKey.equals(publicKey) == true) { - Log.i(TAG, "ObservableTunnel peer " + it + ", " + it.peer) - peer = it; - } - } - - if (peer == null) { - Log.i(TAG, "ObservableTunnel create peer " + publicKey) - peer = PeerDetail(publicKey) - configDetail?.peers?.add(peer) - } - - var peer2: PeerDetail = peer!! + var peer2: PeerDetail = lookupPeer(publicKey) if (newEndpoint != null) { peer2.endpoint = newEndpoint.getResolved() |