2020-07-27 20:43:58 +00:00
|
|
|
import 'package:mobile_nebula/models/Certificate.dart';
|
|
|
|
|
|
|
|
class HostInfo {
|
|
|
|
String vpnIp;
|
|
|
|
int localIndex;
|
|
|
|
int remoteIndex;
|
|
|
|
List<UDPAddress> remoteAddresses;
|
|
|
|
int cachedPackets;
|
|
|
|
Certificate cert;
|
|
|
|
UDPAddress currentRemote;
|
|
|
|
int messageCounter;
|
|
|
|
|
|
|
|
HostInfo.fromJson(Map<String, dynamic> json) {
|
|
|
|
vpnIp = json['vpnIp'];
|
|
|
|
localIndex = json['localIndex'];
|
|
|
|
remoteIndex = json['remoteIndex'];
|
|
|
|
cachedPackets = json['cachedPackets'];
|
|
|
|
|
|
|
|
if (json['currentRemote'] != null) {
|
|
|
|
currentRemote = UDPAddress.fromJson(json['currentRemote']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (json['cert'] != null) {
|
|
|
|
cert = Certificate.fromJson(json['cert']);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<dynamic> addrs = json['remoteAddrs'];
|
|
|
|
remoteAddresses = [];
|
|
|
|
addrs?.forEach((val) {
|
|
|
|
remoteAddresses.add(UDPAddress.fromJson(val));
|
|
|
|
});
|
|
|
|
|
|
|
|
messageCounter = json['messageCounter'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class UDPAddress {
|
|
|
|
String ip;
|
|
|
|
int port;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2021-04-23 21:23:06 +00:00
|
|
|
// Simple check on if nebula told us about a v4 or v6 ip address
|
|
|
|
if (ip.contains(':')) {
|
|
|
|
return '[$ip]:$port';
|
|
|
|
}
|
|
|
|
|
2020-07-27 20:43:58 +00:00
|
|
|
return '$ip:$port';
|
|
|
|
}
|
|
|
|
|
|
|
|
UDPAddress.fromJson(Map<String, dynamic> json)
|
2021-04-23 21:23:06 +00:00
|
|
|
: ip = json['ip'],
|
|
|
|
port = json['port'];
|
2020-07-27 20:43:58 +00:00
|
|
|
}
|