mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-11 21:45:18 +00:00
menu now dynamically populates the network list
This commit is contained in:
parent
005b5aacaf
commit
fd71ceeab5
@ -128,7 +128,9 @@ namespace WinUI
|
|||||||
this.authtoken = authtoken;
|
this.authtoken = authtoken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZeroTierStatus GetStatus()
|
public delegate void StatusCallback(ZeroTierStatus status);
|
||||||
|
|
||||||
|
public void GetStatus(StatusCallback cb)
|
||||||
{
|
{
|
||||||
var request = WebRequest.Create(url + "/status" + "?auth=" + authtoken) as HttpWebRequest;
|
var request = WebRequest.Create(url + "/status" + "?auth=" + authtoken) as HttpWebRequest;
|
||||||
if (request != null)
|
if (request != null)
|
||||||
@ -153,25 +155,27 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
return status;
|
cb(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Net.Sockets.SocketException)
|
catch (System.Net.Sockets.SocketException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
catch (System.Net.WebException)
|
catch (System.Net.WebException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ZeroTierNetwork> GetNetworks()
|
public delegate void NetworkListCallback(List<ZeroTierNetwork> networks);
|
||||||
|
|
||||||
|
public void GetNetworks(NetworkListCallback cb)
|
||||||
{
|
{
|
||||||
var request = WebRequest.Create(url + "/network" + "?auth=" + authtoken) as HttpWebRequest;
|
var request = WebRequest.Create(url + "/network" + "?auth=" + authtoken) as HttpWebRequest;
|
||||||
if (request == null)
|
if (request == null)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.Method = "GET";
|
request.Method = "GET";
|
||||||
@ -188,21 +192,26 @@ namespace WinUI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
networkList = JsonConvert.DeserializeObject<List<ZeroTierNetwork>>(responseText);
|
networkList = JsonConvert.DeserializeObject<List<ZeroTierNetwork>>(responseText);
|
||||||
|
foreach (ZeroTierNetwork n in networkList)
|
||||||
|
{
|
||||||
|
// all networks received via JSON are connected by definition
|
||||||
|
n.IsConnected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (JsonReaderException e)
|
catch (JsonReaderException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
return networkList;
|
cb(networkList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Net.Sockets.SocketException)
|
catch (System.Net.Sockets.SocketException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
catch (System.Net.WebException)
|
catch (System.Net.WebException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +284,14 @@ namespace WinUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ZeroTierPeer> GetPeers()
|
public delegate void PeersCallback(List<ZeroTierPeer> peers);
|
||||||
|
|
||||||
|
public void GetPeers(PeersCallback cb)
|
||||||
{
|
{
|
||||||
var request = WebRequest.Create(url + "/peer" + "?auth=" + authtoken) as HttpWebRequest;
|
var request = WebRequest.Create(url + "/peer" + "?auth=" + authtoken) as HttpWebRequest;
|
||||||
if (request == null)
|
if (request == null)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
request.Method = "GET";
|
request.Method = "GET";
|
||||||
@ -302,16 +313,16 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
return peerList;
|
cb(peerList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Net.Sockets.SocketException)
|
catch (System.Net.Sockets.SocketException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
catch (System.Net.WebException)
|
catch (System.Net.WebException)
|
||||||
{
|
{
|
||||||
return null;
|
cb(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
updateStatus();
|
APIHandler.Instance.GetStatus(updateStatus);
|
||||||
|
|
||||||
if (!connected)
|
if (!connected)
|
||||||
{
|
{
|
||||||
@ -44,19 +44,19 @@ namespace WinUI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNetworks();
|
APIHandler.Instance.GetNetworks(updateNetworks);
|
||||||
|
|
||||||
DataObject.AddPastingHandler(joinNetworkID, OnPaste);
|
DataObject.AddPastingHandler(joinNetworkID, OnPaste);
|
||||||
|
|
||||||
timer.Elapsed += new ElapsedEventHandler(OnUpdateTimer);
|
timer.Elapsed += new ElapsedEventHandler(OnUpdateTimer);
|
||||||
timer.Interval = 2000;
|
timer.Interval = 2000;
|
||||||
timer.Enabled = true;
|
timer.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatus()
|
private void updateStatus(ZeroTierStatus status)
|
||||||
{
|
{
|
||||||
var status = APIHandler.Instance.GetStatus();
|
|
||||||
|
|
||||||
if (status != null)
|
if (status != null)
|
||||||
{
|
{
|
||||||
connected = true;
|
connected = true;
|
||||||
@ -93,31 +93,21 @@ namespace WinUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNetworks()
|
private void updateNetworks(List<ZeroTierNetwork> networks)
|
||||||
|
{
|
||||||
|
if (networks != null)
|
||||||
{
|
{
|
||||||
var networks = APIHandler.Instance.GetNetworks();
|
|
||||||
|
|
||||||
networksPage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
networksPage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||||
{
|
{
|
||||||
networksPage.setNetworks(networks);
|
networksPage.setNetworks(networks);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePeers()
|
|
||||||
{
|
|
||||||
//var peers = handler.GetPeers();
|
|
||||||
|
|
||||||
//peersPage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
|
||||||
//{
|
|
||||||
// peersPage.SetPeers(peers);
|
|
||||||
//}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdateTimer(object source, ElapsedEventArgs e)
|
private void OnUpdateTimer(object source, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
updateStatus();
|
APIHandler.Instance.GetStatus(updateStatus);
|
||||||
updateNetworks();
|
APIHandler.Instance.GetNetworks(updateNetworks);
|
||||||
//updatePeers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinButton_Click(object sender, RoutedEventArgs e)
|
private void joinButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
@ -1,14 +1,32 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace WinUI
|
namespace WinUI
|
||||||
{
|
{
|
||||||
public class NetworkRoute
|
[Serializable]
|
||||||
|
public class NetworkRoute : ISerializable
|
||||||
{
|
{
|
||||||
|
protected NetworkRoute(SerializationInfo info, StreamingContext ctx)
|
||||||
|
{
|
||||||
|
Target = info.GetString("Target");
|
||||||
|
Via = info.GetString("Via");
|
||||||
|
Flags = info.GetInt32("Flags");
|
||||||
|
Metric = info.GetInt32("Metric");
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
||||||
|
{
|
||||||
|
info.AddValue("Target", Target);
|
||||||
|
info.AddValue("Via", Via);
|
||||||
|
info.AddValue("Flags", Flags);
|
||||||
|
info.AddValue("Metric", Metric);
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty("target")]
|
[JsonProperty("target")]
|
||||||
public string Target { get; set; }
|
public string Target { get; set; }
|
||||||
|
|
||||||
|
@ -5,8 +5,18 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:WinUI"
|
xmlns:local="clr-namespace:WinUI"
|
||||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||||
|
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Height="300" Width="300" Visibility="Hidden">
|
Height="300" Width="300" Visibility="Hidden" Name="Toolbar">
|
||||||
|
|
||||||
|
<Window.Resources>
|
||||||
|
<CollectionViewSource Source="{Binding ElementName=Toolbar, Path=NetworkCollection}" x:Key="KnownNetworks">
|
||||||
|
<CollectionViewSource.SortDescriptions>
|
||||||
|
<scm:SortDescription PropertyName="NetworkId" Direction="Ascending"/>
|
||||||
|
</CollectionViewSource.SortDescriptions>
|
||||||
|
</CollectionViewSource>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<tb:TaskbarIcon x:Name="MyNotifyIcon"
|
<tb:TaskbarIcon x:Name="MyNotifyIcon"
|
||||||
IconSource="ZeroTierIcon.ico"
|
IconSource="ZeroTierIcon.ico"
|
||||||
@ -16,12 +26,29 @@
|
|||||||
<tb:TaskbarIcon.ContextMenu>
|
<tb:TaskbarIcon.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Node ID: abeb9f9bc5"
|
<MenuItem Header="Node ID: abeb9f9bc5"
|
||||||
Click="ToolbarItem_NodeIDClicked"/>
|
Click="ToolbarItem_NodeIDClicked"
|
||||||
|
x:Name="nodeIdMenuItem"/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem Header="Join Network..."/>
|
<MenuItem Header="Join Network..."
|
||||||
|
Click="ToolbarItem_JoinNetworkClicked"/>
|
||||||
<MenuItem Header="Show Networks..."
|
<MenuItem Header="Show Networks..."
|
||||||
Click="ToolbarItem_ShowNetworksClicked"/>
|
Click="ToolbarItem_ShowNetworksClicked"/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
|
<MenuItem Header="Networks">
|
||||||
|
<MenuItem.ItemsSource>
|
||||||
|
<CompositeCollection>
|
||||||
|
<CollectionContainer Collection="{Binding Source={StaticResource KnownNetworks}}"/>
|
||||||
|
</CompositeCollection>
|
||||||
|
</MenuItem.ItemsSource>
|
||||||
|
<MenuItem.ItemContainerStyle>
|
||||||
|
<Style>
|
||||||
|
<Setter Property="MenuItem.Header" Value="{Binding Title}"/>
|
||||||
|
<Setter Property="MenuItem.IsCheckable" Value="True"/>
|
||||||
|
<Setter Property="MenuItem.IsChecked" Value="{Binding IsConnected}"/>
|
||||||
|
</Style>
|
||||||
|
</MenuItem.ItemContainerStyle>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator/>
|
||||||
<MenuItem Header="About..."/>
|
<MenuItem Header="About..."/>
|
||||||
<MenuItem Header="Preferences..."/>
|
<MenuItem Header="Preferences..."/>
|
||||||
<Separator/>
|
<Separator/>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -26,11 +27,75 @@ namespace WinUI
|
|||||||
{
|
{
|
||||||
private APIHandler handler = APIHandler.Instance;
|
private APIHandler handler = APIHandler.Instance;
|
||||||
|
|
||||||
NetworkListView netList = null;
|
private NetworkListView netListView = null;
|
||||||
|
private List<ZeroTierNetwork> networkList = null;
|
||||||
|
|
||||||
|
private ObservableCollection<ZeroTierNetwork> _networkCollection = new ObservableCollection<ZeroTierNetwork>();
|
||||||
|
|
||||||
|
public ObservableCollection<ZeroTierNetwork> NetworkCollection
|
||||||
|
{
|
||||||
|
get { return _networkCollection; }
|
||||||
|
set { _networkCollection = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private Timer timer = null;
|
||||||
|
|
||||||
public ToolbarItem()
|
public ToolbarItem()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
onUpdateTimer(this, null);
|
||||||
|
|
||||||
|
timer = new Timer();
|
||||||
|
timer.Elapsed += new ElapsedEventHandler(onUpdateTimer);
|
||||||
|
timer.Interval = 2000;
|
||||||
|
timer.Enabled = true;
|
||||||
|
|
||||||
|
nodeIdMenuItem.Header = "OFFLINE";
|
||||||
|
nodeIdMenuItem.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateNetworks(List<ZeroTierNetwork> networks)
|
||||||
|
{
|
||||||
|
if (networks != null)
|
||||||
|
{
|
||||||
|
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||||
|
{
|
||||||
|
foreach (ZeroTierNetwork n in networks)
|
||||||
|
{
|
||||||
|
int index = _networkCollection.IndexOf(n);
|
||||||
|
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
_networkCollection.Add(n);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_networkCollection[index] = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.networkList = networks;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatus(ZeroTierStatus status)
|
||||||
|
{
|
||||||
|
if (status != null)
|
||||||
|
{
|
||||||
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||||
|
{
|
||||||
|
nodeIdMenuItem.Header = "Node ID: " + status.Address;
|
||||||
|
nodeIdMenuItem.IsEnabled = true;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onUpdateTimer(object source, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
APIHandler.Instance.GetStatus(updateStatus);
|
||||||
|
APIHandler.Instance.GetNetworks(updateNetworks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToolbarItem_TrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
|
private void ToolbarItem_TrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
|
||||||
@ -50,17 +115,27 @@ namespace WinUI
|
|||||||
|
|
||||||
private void ToolbarItem_ShowNetworksClicked(object sender, System.Windows.RoutedEventArgs e)
|
private void ToolbarItem_ShowNetworksClicked(object sender, System.Windows.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (netList == null)
|
if (netListView == null)
|
||||||
{
|
{
|
||||||
netList = new WinUI.NetworkListView();
|
netListView = new WinUI.NetworkListView();
|
||||||
netList.Closed += ShowNetworksClosed;
|
netListView.Closed += ShowNetworksClosed;
|
||||||
netList.Show();
|
netListView.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowNetworksClosed(object sender, System.EventArgs e)
|
private void ShowNetworksClosed(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
netList = null;
|
netListView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToolbarItem_JoinNetworkClicked(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void JoinNetworkClosed(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,60 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace WinUI
|
namespace WinUI
|
||||||
{
|
{
|
||||||
public class ZeroTierNetwork
|
[Serializable]
|
||||||
|
public class ZeroTierNetwork : ISerializable, IEquatable<ZeroTierNetwork>, IComparable<ZeroTierNetwork>
|
||||||
{
|
{
|
||||||
|
protected ZeroTierNetwork(SerializationInfo info, StreamingContext ctx)
|
||||||
|
{
|
||||||
|
NetworkId = info.GetString("NetworkId");
|
||||||
|
MacAddress = info.GetString("MacAddress");
|
||||||
|
NetworkName = info.GetString("NetworkName");
|
||||||
|
NetworkStatus = info.GetString("NetworkStatus");
|
||||||
|
NetworkType = info.GetString("NetworkType");
|
||||||
|
MTU = info.GetInt32("MTU");
|
||||||
|
DHCP = info.GetBoolean("DHCP");
|
||||||
|
Bridge = info.GetBoolean("Bridge");
|
||||||
|
BroadcastEnabled = info.GetBoolean("BroadcastEnabled");
|
||||||
|
PortError = info.GetInt32("PortError");
|
||||||
|
NetconfRevision = info.GetInt32("NetconfRevision");
|
||||||
|
AssignedAddresses = (string[])info.GetValue("AssignedAddresses", typeof(string[]));
|
||||||
|
Routes = (NetworkRoute[])info.GetValue("Routes", typeof(NetworkRoute[]));
|
||||||
|
DeviceName = info.GetString("DeviceName");
|
||||||
|
AllowManaged = info.GetBoolean("AllowManaged");
|
||||||
|
AllowGlobal = info.GetBoolean("AllowGlobal");
|
||||||
|
AllowDefault = info.GetBoolean("AllowDefault");
|
||||||
|
IsConnected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctx)
|
||||||
|
{
|
||||||
|
info.AddValue("NetworkId", NetworkId);
|
||||||
|
info.AddValue("MacAddress", MacAddress);
|
||||||
|
info.AddValue("NetworkName", NetworkName);
|
||||||
|
info.AddValue("NetworkStatus", NetworkStatus);
|
||||||
|
info.AddValue("NetworkType", NetworkType);
|
||||||
|
info.AddValue("MTU", MTU);
|
||||||
|
info.AddValue("DHCP", DHCP);
|
||||||
|
info.AddValue("Bridge", Bridge);
|
||||||
|
info.AddValue("BroadcastEnabled", BroadcastEnabled);
|
||||||
|
info.AddValue("PortError", PortError);
|
||||||
|
info.AddValue("NetconfRevision", NetconfRevision);
|
||||||
|
info.AddValue("AssignedAddresses", AssignedAddresses);
|
||||||
|
info.AddValue("Routes", Routes);
|
||||||
|
info.AddValue("DeviceName", DeviceName);
|
||||||
|
info.AddValue("AllowManaged", AllowManaged);
|
||||||
|
info.AddValue("AllowGlobal", AllowGlobal);
|
||||||
|
info.AddValue("AllowDefault", AllowDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[JsonProperty("nwid")]
|
[JsonProperty("nwid")]
|
||||||
public string NetworkId { get; set; }
|
public string NetworkId { get; set; }
|
||||||
|
|
||||||
@ -59,5 +105,47 @@ namespace WinUI
|
|||||||
|
|
||||||
[JsonProperty("allowDefault")]
|
[JsonProperty("allowDefault")]
|
||||||
public bool AllowDefault { get; set; }
|
public bool AllowDefault { get; set; }
|
||||||
|
|
||||||
|
public bool IsConnected { get; set; } = false;
|
||||||
|
|
||||||
|
public String Title
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
|
||||||
|
if (NetworkName != null && NetworkName.Length > 0)
|
||||||
|
{
|
||||||
|
return NetworkId + " (" + NetworkName + ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NetworkId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(ZeroTierNetwork network)
|
||||||
|
{
|
||||||
|
return NetworkId.Equals(network.NetworkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(ZeroTierNetwork network)
|
||||||
|
{
|
||||||
|
UInt64 thisNwid = UInt64.Parse(NetworkId, System.Globalization.NumberStyles.HexNumber);
|
||||||
|
UInt64 otherNwid = UInt64.Parse(network.NetworkId, System.Globalization.NumberStyles.HexNumber);
|
||||||
|
|
||||||
|
if (thisNwid > otherNwid)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if (thisNwid < otherNwid)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user