mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
C#-ifying stuff
This commit is contained in:
parent
fe6960888a
commit
62059a91aa
@ -80,10 +80,10 @@
|
||||
<StatusBarItem Grid.Column="2" x:Name="versionString" Content="1.0.5" Foreground="White" Margin="0"/>
|
||||
<StatusBarItem Grid.Column="3" x:Name="blank" Content="" Height="43" Foreground="White" Margin="6,0,-6,-9"/>
|
||||
<StatusBarItem Grid.Column="4">
|
||||
<TextBox x:Name="joinNetworkID" Height="23" TextWrapping="Wrap" Width="120" HorizontalAlignment="Right" RenderTransformOrigin="1.168,0.478" ToolTip="Enter Network ID"/>
|
||||
<TextBox x:Name="joinNetworkID" Height="23" TextWrapping="Wrap" Width="120" HorizontalAlignment="Right" RenderTransformOrigin="1.168,0.478" ToolTip="Enter Network ID" TextChanged="joinNetworkID_TextChanged"/>
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Grid.Column="5" x:Name="statusBarButton" Foreground="White" RenderTransformOrigin="0.789,0.442">
|
||||
<Button x:Name="joinButton" Content="Join" Background="#FFFFB354" Width="77.423"/>
|
||||
<Button x:Name="joinButton" Content="Join" Background="#FFFFB354" Width="77.423" Click="joinButton_Click"/>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
<TabControl>
|
||||
|
@ -32,18 +32,30 @@ namespace WinUI
|
||||
|
||||
private void updateStatus()
|
||||
{
|
||||
var status = handler.getStatus();
|
||||
var status = handler.GetStatus();
|
||||
|
||||
this.networkId.Content = status.address;
|
||||
this.versionString.Content = status.version;
|
||||
this.onlineStatus.Content = (status.online ? "ONLINE" : "OFFLINE");
|
||||
this.networkId.Content = status.Address;
|
||||
this.versionString.Content = status.Version;
|
||||
this.onlineStatus.Content = (status.Online ? "ONLINE" : "OFFLINE");
|
||||
}
|
||||
|
||||
private void updateNetworks()
|
||||
{
|
||||
var networks = handler.getNetworks();
|
||||
var networks = handler.GetNetworks();
|
||||
|
||||
networksPage.setNetworks(networks);
|
||||
}
|
||||
|
||||
private void joinButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void joinNetworkID_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,35 +27,35 @@ namespace WinUI
|
||||
InitializeComponent();
|
||||
this.network = network;
|
||||
|
||||
updateNetworkData();
|
||||
UpdateNetworkData();
|
||||
}
|
||||
|
||||
private void updateNetworkData()
|
||||
private void UpdateNetworkData()
|
||||
{
|
||||
this.networkId.Text = network.nwid;
|
||||
this.networkName.Text = network.name;
|
||||
this.networkStatus.Text = network.status;
|
||||
this.networkType.Text = network.type;
|
||||
this.macAddress.Text = network.mac;
|
||||
this.mtu.Text = network.mtu.ToString();
|
||||
this.broadcastEnabled.Text = (network.broadcastEnabled ? "ENABLED" : "DISABLED");
|
||||
this.bridgingEnabled.Text = (network.bridge ? "ENABLED" : "DISABLED");
|
||||
this.deviceName.Text = network.portDeviceName;
|
||||
this.networkId.Text = network.NetworkId;
|
||||
this.networkName.Text = network.NetworkName;
|
||||
this.networkStatus.Text = network.NetworkStatus;
|
||||
this.networkType.Text = network.NetworkType;
|
||||
this.macAddress.Text = network.MacAddress;
|
||||
this.mtu.Text = network.MTU.ToString();
|
||||
this.broadcastEnabled.Text = (network.BroadcastEnabled ? "ENABLED" : "DISABLED");
|
||||
this.bridgingEnabled.Text = (network.Bridge ? "ENABLED" : "DISABLED");
|
||||
this.deviceName.Text = network.DeviceName;
|
||||
|
||||
string iplist = "";
|
||||
for (int i = 0; i < network.assignedAddresses.Length; ++i)
|
||||
for (int i = 0; i < network.AssignedAddresses.Length; ++i)
|
||||
{
|
||||
iplist += network.assignedAddresses[i];
|
||||
if (i < (network.assignedAddresses.Length - 1))
|
||||
iplist += network.AssignedAddresses[i];
|
||||
if (i < (network.AssignedAddresses.Length - 1))
|
||||
iplist += "\n";
|
||||
}
|
||||
|
||||
this.managedIps.Text = iplist;
|
||||
}
|
||||
|
||||
public bool hasNetwork(ZeroTierNetwork network)
|
||||
public bool HasNetwork(ZeroTierNetwork network)
|
||||
{
|
||||
if (this.network.nwid.Equals(network.nwid))
|
||||
if (this.network.NetworkId.Equals(network.NetworkId))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -100,6 +100,8 @@
|
||||
<Compile Include="NetworksPage.xaml.cs">
|
||||
<DependentUpon>NetworksPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ZeroTierPeerPhysicalPath.cs" />
|
||||
<Compile Include="ZeroTierPeer.cs" />
|
||||
<Compile Include="ZeroTierNetwork.cs" />
|
||||
<Compile Include="ZeroTierStatus.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
|
@ -3,24 +3,52 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WinUI
|
||||
{
|
||||
public class ZeroTierNetwork
|
||||
{
|
||||
public string nwid;
|
||||
public string mac;
|
||||
public string name;
|
||||
public string status;
|
||||
public string type;
|
||||
public int mtu;
|
||||
public bool dhcp;
|
||||
public bool bridge;
|
||||
public bool broadcastEnabled;
|
||||
public int portError;
|
||||
public int netconfRevision;
|
||||
public string[] multicastSubscriptions;
|
||||
public string[] assignedAddresses;
|
||||
public string portDeviceName;
|
||||
[JsonProperty("nwid")]
|
||||
public string NetworkId { get; set; }
|
||||
|
||||
[JsonProperty("mac")]
|
||||
public string MacAddress { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string NetworkName { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public string NetworkStatus { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string NetworkType { get; set; }
|
||||
|
||||
[JsonProperty("mtu")]
|
||||
public int MTU { get; set; }
|
||||
|
||||
[JsonProperty("dhcp")]
|
||||
public bool DHCP { get; set; }
|
||||
|
||||
[JsonProperty("bridge")]
|
||||
public bool Bridge { get; set ; }
|
||||
|
||||
[JsonProperty("broadcastEnabled")]
|
||||
public bool BroadcastEnabled { get ; set; }
|
||||
|
||||
[JsonProperty("portError")]
|
||||
public int PortError { get; set; }
|
||||
|
||||
[JsonProperty("netconfRevision")]
|
||||
public int NetconfRevision { get; set; }
|
||||
|
||||
[JsonProperty("multicastSubscriptions")]
|
||||
public string[] MulticastSubscriptions { get; set; }
|
||||
|
||||
[JsonProperty("assignedAddresses")]
|
||||
public string[] AssignedAddresses { get; set; }
|
||||
|
||||
[JsonProperty("portDeviceName")]
|
||||
public string DeviceName { get; set; }
|
||||
}
|
||||
}
|
||||
|
42
windows/WinUI/ZeroTierPeer.cs
Normal file
42
windows/WinUI/ZeroTierPeer.cs
Normal file
@ -0,0 +1,42 @@
|
||||
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; }
|
||||
|
||||
[JsonProperty("lastUnicastFrame")]
|
||||
public int LastUnicastFrame { get; set; }
|
||||
|
||||
[JsonProperty("lastMulticastFrame")]
|
||||
public int LastMulticastFrame { get; set; }
|
||||
|
||||
[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; }
|
||||
|
||||
[JsonProperty("latency")]
|
||||
public string Latency { get; set; }
|
||||
|
||||
[JsonProperty("role")]
|
||||
public string Role { get; set; }
|
||||
|
||||
[JsonProperty("paths")]
|
||||
public List<ZeroTierPeerPhysicalPath> Paths { get; set; }
|
||||
}
|
||||
}
|
27
windows/WinUI/ZeroTierPeerPhysicalPath.cs
Normal file
27
windows/WinUI/ZeroTierPeerPhysicalPath.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WinUI
|
||||
{
|
||||
public class ZeroTierPeerPhysicalPath
|
||||
{
|
||||
[JsonProperty("address")]
|
||||
public string Address { get; set; }
|
||||
|
||||
[JsonProperty("lastSend")]
|
||||
public int LastSend { get; set; }
|
||||
|
||||
[JsonProperty("lastReceive")]
|
||||
public int LastReceive { get; set; }
|
||||
|
||||
[JsonProperty("fixed")]
|
||||
public bool Fixed { get; set; }
|
||||
|
||||
[JsonProperty("preferred")]
|
||||
public bool Preferred { get; set; }
|
||||
}
|
||||
}
|
@ -3,19 +3,37 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WinUI
|
||||
{
|
||||
public class ZeroTierStatus
|
||||
{
|
||||
public string address;
|
||||
public string publicIdentity;
|
||||
public bool online;
|
||||
public bool tcpFallbackActive;
|
||||
public int versionMajor;
|
||||
public int versionMinor;
|
||||
public int versionRev;
|
||||
public string version;
|
||||
public UInt64 clock;
|
||||
[JsonProperty("address")]
|
||||
public string Address { get; set; }
|
||||
|
||||
[JsonProperty("publicIdentity")]
|
||||
public string PublicIdentity { get; set; }
|
||||
|
||||
[JsonProperty("online")]
|
||||
public bool Online { get; set; }
|
||||
|
||||
[JsonProperty("tcpFallbackActive")]
|
||||
public bool TcpFallbackActive { get; set; }
|
||||
|
||||
[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; }
|
||||
|
||||
[JsonProperty("clock")]
|
||||
public UInt64 Clock { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user