From fd6f7418693370079ba414cca05b64186f635198 Mon Sep 17 00:00:00 2001 From: vadym Date: Mon, 7 Dec 2020 15:05:10 +0200 Subject: [PATCH] 1. #6. added multicast peers to peer list --- .../java/io/github/chronosx88/yggdrasil/MainActivity.kt | 6 ++---- .../io/github/chronosx88/yggdrasil/models/config/Utils.kt | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt index 25327fd..d7d9300 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt @@ -258,7 +258,7 @@ class MainActivity : AppCompatActivity() { thread(start = true) { while(true) { Thread.sleep(5000) - if(isStarted && this.currentPeers.isEmpty()) { + if(isStarted) { updatePeers() } } @@ -340,9 +340,7 @@ class MainActivity : AppCompatActivity() { when (resultCode) { STATUS_START -> { print("service started") - if (this.currentPeers.isEmpty()) { - checkPeers() - } + checkPeers() } STATUS_FINISH -> { isStarted = true diff --git a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt b/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt index abbbeef..bf4d34b 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/models/config/Utils.kt @@ -120,7 +120,13 @@ class Utils { if(p.endpoint == "(self)"){ out.add(PeerInfo(p.protocol, InetAddress.getByName("localhost"), p.port, null, true)) } else { - var fixWlanPart = p.endpoint.substring(p.endpoint.indexOf('%'), p.endpoint.indexOf(']')) + var fixWlanPart="" + if(p.endpoint.indexOf(']')>0) { + fixWlanPart = p.endpoint.substring( + p.endpoint.indexOf('%'), + p.endpoint.indexOf(']') + ) + } var fixedUrlString = p.endpoint.replace(fixWlanPart, "") var url = URI(fixedUrlString) out.add(