mirror of
https://github.com/yggdrasil-network/yggdrasil-ios.git
synced 2025-04-28 14:15:09 +03:00
App updates
This commit is contained in:
parent
2cb5eebcd2
commit
5fbb735f56
9 changed files with 204 additions and 91 deletions
|
@ -98,25 +98,28 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
|
|||
let request = String(data: messageData, encoding: .utf8)
|
||||
switch request {
|
||||
case "summary":
|
||||
let pj = self.yggdrasil.getPeersJSON()
|
||||
var peers: [YggdrasilPeer] = []
|
||||
do {
|
||||
peers = try JSONDecoder().decode(
|
||||
[YggdrasilPeer].self,
|
||||
from: pj.data(using: .utf8)!
|
||||
)
|
||||
} catch {
|
||||
NSLog("JSON Error: \(error)")
|
||||
}
|
||||
let summary = YggdrasilSummary(
|
||||
address: self.yggdrasil.getAddressString(),
|
||||
subnet: self.yggdrasil.getSubnetString(),
|
||||
publicKey: self.yggdrasil.getPublicKeyString()
|
||||
publicKey: self.yggdrasil.getPublicKeyString(),
|
||||
enabled: true,
|
||||
peers: peers.sorted(by: { a, b in
|
||||
a.remote < b.remote
|
||||
})
|
||||
)
|
||||
if let json = try? JSONEncoder().encode(summary) {
|
||||
completionHandler?(json)
|
||||
}
|
||||
|
||||
case "status":
|
||||
let status = YggdrasilStatus(
|
||||
enabled: true,
|
||||
coords: self.yggdrasil.getCoordsString(),
|
||||
peers: self.yggdrasil.getPeersJSON().data(using: .utf8) ?? Data(),
|
||||
dht: self.yggdrasil.getDHTJSON().data(using: .utf8) ?? Data()
|
||||
)
|
||||
if let json = try? JSONEncoder().encode(status) {
|
||||
completionHandler?(json)
|
||||
}
|
||||
|
||||
default:
|
||||
completionHandler?(nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue