From 010051da50268b069f589d8ac4fe83da6f4c228f Mon Sep 17 00:00:00 2001 From: vadym Date: Wed, 1 Jul 2020 02:56:30 -0700 Subject: [PATCH] 2. getPeers parsing fixes --- .../io/github/chronosx88/yggdrasil/MainActivity.kt | 4 ++-- .../github/chronosx88/yggdrasil/models/config/Utils.kt | 10 +++++++--- 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 8daba64..b28ffa9 100644 --- a/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt +++ b/app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt @@ -269,7 +269,7 @@ class MainActivity : AppCompatActivity() { thread(start = true) { while(true) { Thread.sleep(5000) - if(isStarted) { + if(isStarted && this.currentPeers.isEmpty()) { updatePeers() } } @@ -297,7 +297,7 @@ class MainActivity : AppCompatActivity() { val listView = findViewById(R.id.peers) val adapter = PeerInfoListAdapter( this@MainActivity, - meshPeers.sortedWith(compareBy { it.ping }) + meshPeers.filter { it.schema!="self" }.sortedWith(compareBy { it.ping }) ) runOnUiThread { listView.adapter = adapter 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 f65a557..abbbeef 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 @@ -6,6 +6,7 @@ import io.github.chronosx88.yggdrasil.models.PeerInfo import java.net.InetAddress import java.net.InetSocketAddress import java.net.Socket +import java.net.URI class Utils { @@ -119,11 +120,14 @@ 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 fixedUrlString = p.endpoint.replace(fixWlanPart, "") + var url = URI(fixedUrlString) out.add( PeerInfo( - p.protocol, - InetAddress.getByName(p.endpoint), - p.port, + url.scheme, + InetAddress.getByName(url.host), + url.port, null, true )