2. getPeers parsing fixes

This commit is contained in:
vadym 2020-07-01 02:56:30 -07:00
parent bca4b88d3d
commit 010051da50
2 changed files with 9 additions and 5 deletions

View File

@ -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<ListView>(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

View File

@ -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
)