This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-zerotierone/windows/WinUI/ZeroTierPeer.cs

99 lines
2.5 KiB
C#
Raw Normal View History

2015-10-23 15:36:42 -07:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WinUI
{
public class ZeroTierPeer
{
[JsonProperty("address")]
public string Address { get; set; }
2015-11-04 20:03:25 -08:00
private Int64 _lastUnicast;
2015-10-23 15:36:42 -07:00
[JsonProperty("lastUnicastFrame")]
2015-11-04 20:03:25 -08:00
public Int64 LastUnicastFrame
{
get
{
if (_lastUnicast == 0)
return 0;
2015-10-23 15:36:42 -07:00
2015-11-04 20:03:25 -08:00
TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
Int64 millisecondsSinceEpoch = (Int64)t.TotalMilliseconds;
return (millisecondsSinceEpoch - _lastUnicast) / 1000;
}
set
{
_lastUnicast = value;
}
}
private Int64 _lastMulticast;
2015-10-23 15:36:42 -07:00
[JsonProperty("lastMulticastFrame")]
2015-11-04 20:03:25 -08:00
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;
}
}
2015-10-23 15:36:42 -07:00
[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; }
2015-10-26 19:21:21 -07:00
public string VersionString
{
get
{
if (Version == "-1.-1.-1")
return "-";
else
return Version;
}
}
2015-10-23 15:36:42 -07:00
[JsonProperty("latency")]
public string Latency { get; set; }
[JsonProperty("role")]
public string Role { get; set; }
[JsonProperty("paths")]
public List<ZeroTierPeerPhysicalPath> Paths { get; set; }
2015-10-26 19:21:21 -07:00
public string DataPaths
{
get
{
string pathStr = "";
foreach(ZeroTierPeerPhysicalPath path in Paths)
{
pathStr += path.Address + "\n";
}
return pathStr;
}
}
2015-10-23 15:36:42 -07:00
}
}