mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-13 22:11:03 +00:00
2. getPeers parsing fixes
This commit is contained in:
parent
bca4b88d3d
commit
010051da50
@ -269,7 +269,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
thread(start = true) {
|
thread(start = true) {
|
||||||
while(true) {
|
while(true) {
|
||||||
Thread.sleep(5000)
|
Thread.sleep(5000)
|
||||||
if(isStarted) {
|
if(isStarted && this.currentPeers.isEmpty()) {
|
||||||
updatePeers()
|
updatePeers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val listView = findViewById<ListView>(R.id.peers)
|
val listView = findViewById<ListView>(R.id.peers)
|
||||||
val adapter = PeerInfoListAdapter(
|
val adapter = PeerInfoListAdapter(
|
||||||
this@MainActivity,
|
this@MainActivity,
|
||||||
meshPeers.sortedWith(compareBy { it.ping })
|
meshPeers.filter { it.schema!="self" }.sortedWith(compareBy { it.ping })
|
||||||
)
|
)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
listView.adapter = adapter
|
listView.adapter = adapter
|
||||||
|
@ -6,6 +6,7 @@ import io.github.chronosx88.yggdrasil.models.PeerInfo
|
|||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.net.Socket
|
import java.net.Socket
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
|
||||||
@ -119,11 +120,14 @@ class Utils {
|
|||||||
if(p.endpoint == "(self)"){
|
if(p.endpoint == "(self)"){
|
||||||
out.add(PeerInfo(p.protocol, InetAddress.getByName("localhost"), p.port, null, true))
|
out.add(PeerInfo(p.protocol, InetAddress.getByName("localhost"), p.port, null, true))
|
||||||
} else {
|
} else {
|
||||||
|
var fixWlanPart = p.endpoint.substring(p.endpoint.indexOf('%'), p.endpoint.indexOf(']'))
|
||||||
|
var fixedUrlString = p.endpoint.replace(fixWlanPart, "")
|
||||||
|
var url = URI(fixedUrlString)
|
||||||
out.add(
|
out.add(
|
||||||
PeerInfo(
|
PeerInfo(
|
||||||
p.protocol,
|
url.scheme,
|
||||||
InetAddress.getByName(p.endpoint),
|
InetAddress.getByName(url.host),
|
||||||
p.port,
|
url.port,
|
||||||
null,
|
null,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user