blob: 1597cf2dc8de7229750100b17f563094f5bf5615 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WinUI
{
public class ZeroTierPeer : IEquatable<ZeroTierPeer>
{
[JsonProperty("address")]
public string Address { get; set; }
private Int64 _lastUnicast;
[JsonProperty("lastUnicastFrame")]
public Int64 LastUnicastFrame
{
get
{
if (_lastUnicast == 0)
return 0;
TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
Int64 millisecondsSinceEpoch = (Int64)t.TotalMilliseconds;
return (millisecondsSinceEpoch - _lastUnicast) / 1000;
}
set
{
_lastUnicast = value;
}
}
private Int64 _lastMulticast;
[JsonProperty("lastMulticastFrame")]
public Int64 LastMulticastFrame
{
get
{
if (_lastMulticast == 0)
return 0;
TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
Int64 millisecondsSinceEpoch = (Int64)t.TotalMilliseconds;
return (millisecondsSinceEpoch - _lastMulticast) / 1000;
}
set
{
_lastMulticast = value;
}
}
[JsonProperty("versionMajor")]
public int VersionMajor { get; set; }
[JsonProperty("versionMinor")]
public int VersionMinor { get; set; }
[JsonProperty("versionRev")]
public int VersionRev { get; set; }
[JsonProperty("version")]
public string Version { get; set; }
public string VersionString
{
get
{
if (Version == "-1.-1.-1")
return "-";
else
return Version;
}
}
[JsonProperty("latency")]
public string Latency { get; set; }
[JsonProperty("role")]
public string Role { get; set; }
[JsonProperty("paths")]
public List<ZeroTierPeerPhysicalPath> Paths { get; set; }
public string DataPaths
{
get
{
string pathStr = "";
foreach(ZeroTierPeerPhysicalPath path in Paths)
{
pathStr += path.Address + "\n";
}
return pathStr;
}
}
public bool Equals(ZeroTierPeer other)
{
return this.Address.Equals(other.Address, StringComparison.InvariantCultureIgnoreCase);
}
public void Update(ZeroTierPeer other)
{
_lastUnicast = other._lastUnicast;
_lastMulticast = other._lastMulticast;
VersionMajor = other.VersionMajor;
VersionMinor = other.VersionMinor;
VersionRev = other.VersionRev;
Version = other.Version;
Latency = other.Latency;
Role = other.Role;
Paths = other.Paths;
}
}
}
|