summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
Diffstat (limited to 'windows')
-rw-r--r--windows/WinUI/APIHandler.cs13
-rw-r--r--windows/WinUI/NetworkInfoView.xaml17
-rw-r--r--windows/WinUI/NetworkInfoView.xaml.cs31
-rw-r--r--windows/WinUI/NetworkRoute.cs24
-rw-r--r--windows/WinUI/WinUI.csproj1
-rw-r--r--windows/WinUI/ZeroTierNetwork.cs15
6 files changed, 93 insertions, 8 deletions
diff --git a/windows/WinUI/APIHandler.cs b/windows/WinUI/APIHandler.cs
index 92b83021..83a22c66 100644
--- a/windows/WinUI/APIHandler.cs
+++ b/windows/WinUI/APIHandler.cs
@@ -107,7 +107,7 @@ namespace WinUI
}
}
- public void JoinNetwork(string nwid)
+ public void JoinNetwork(string nwid, bool allowManaged = false, bool allowGlobal = false, bool allowDefault = false)
{
var request = WebRequest.Create(url + "/network/" + nwid + "?auth=" + authtoken) as HttpWebRequest;
if (request == null)
@@ -116,6 +116,17 @@ namespace WinUI
}
request.Method = "POST";
+ request.ContentType = "applicaiton/json";
+
+ using (var streamWriter = new StreamWriter(((HttpWebRequest)request).GetRequestStream()))
+ {
+ string json = "{\"allowManaged\":" + (allowManaged ? "true" : "false") + "," +
+ "\"allowGlobal\":" + (allowGlobal ? "true" : "false") + "," +
+ "\"allowDefault\":" + (allowDefault ? "true" : "false") + "}";
+ streamWriter.Write(json);
+ streamWriter.Flush();
+ streamWriter.Close();
+ }
try
{
diff --git a/windows/WinUI/NetworkInfoView.xaml b/windows/WinUI/NetworkInfoView.xaml
index 54ff0375..1ca488b1 100644
--- a/windows/WinUI/NetworkInfoView.xaml
+++ b/windows/WinUI/NetworkInfoView.xaml
@@ -26,6 +26,9 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
+ <RowDefinition Height="auto"/>
+ <RowDefinition Height="auto"/>
+ <RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3">
@@ -48,8 +51,11 @@
<TextBlock TextWrapping="Wrap" Text="Bridging" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="7" Foreground="#FF000000"/>
<TextBlock TextWrapping="Wrap" Text="Device" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="8" Foreground="#FF000000"/>
<TextBlock TextWrapping="Wrap" Text="Managed IPs" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="9" Foreground="#FF000000"/>
+ <TextBlock TextWrapping="Wrap" Text="Allow Global IP" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="10" Foreground="#FF000000"/>
+ <TextBlock TextWrapping="Wrap" Text="Allow Managed IP" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="11" Foreground="#FF000000"/>
+ <TextBlock TextWrapping="Wrap" Text="Allow Default Route" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="12" Foreground="#FF000000"/>
- <Rectangle Grid.Column="2" Grid.Row="2" Grid.RowSpan="8" Fill="#FFEEEEEE"/>
+ <Rectangle Grid.Column="2" Grid.Row="2" Grid.RowSpan="11" Fill="#FFEEEEEE"/>
<TextBlock x:Name="networkStatus" FontFamily="Lucida Console" TextWrapping="Wrap" HorizontalAlignment="Right" Text="OK" TextAlignment="Right" Grid.Column="2" Grid.Row="2" Foreground="#FF000000"/>
<TextBlock x:Name="networkType" FontFamily="Lucida Console" TextWrapping="Wrap" Text="PUBLIC" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="3" Foreground="#FF000000"/>
@@ -59,10 +65,13 @@
<TextBlock x:Name="bridgingEnabled" FontFamily="Lucida Console" TextWrapping="Wrap" Text="DISABLED" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="7" Background="#FFEEEEEE" Foreground="#FF000000"/>
<TextBlock x:Name="deviceName" FontFamily="Lucida Console" TextWrapping="Wrap" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="8" Foreground="#FF000000"><Span><Run Text="ethernet_32771"/></Span></TextBlock>
<TextBlock x:Name="managedIps" TextWrapping="Wrap" FontFamily="Lucida Console" HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="2" Grid.Row="9" Foreground="#FF000000"><Span><Run Text="28.2.169.248/7 "/></Span><LineBreak/><Span><Run Text="fd80:56c2:e21c:0000:0199:9383:4a02:a9f8/88"/></Span></TextBlock>
-
- <Separator Grid.Column="0" Grid.Row="10" Grid.ColumnSpan="3"/>
+ <CheckBox x:Name="allowGlobal" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="10" Checked="AllowGlobal_CheckStateChanged" Unchecked="AllowGlobal_CheckStateChanged"/>
+ <CheckBox x:Name="allowManaged" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="11" Checked="AllowManaged_CheckStateChanged" Unchecked="AllowManaged_CheckStateChanged"/>
+ <CheckBox x:Name="allowDefault" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="12" Checked="AllowDefault_CheckStateChanged" Unchecked="AllowDefault_CheckStateChanged"/>
+
+ <Separator Grid.Column="0" Grid.Row="13" Grid.ColumnSpan="3"/>
- <Grid Grid.Column="0" Grid.Row="11" Grid.ColumnSpan="3" Background="GhostWhite">
+ <Grid Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="3" Background="GhostWhite">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
diff --git a/windows/WinUI/NetworkInfoView.xaml.cs b/windows/WinUI/NetworkInfoView.xaml.cs
index ccdec288..5c96b985 100644
--- a/windows/WinUI/NetworkInfoView.xaml.cs
+++ b/windows/WinUI/NetworkInfoView.xaml.cs
@@ -54,6 +54,10 @@ namespace WinUI
}
this.managedIps.Text = iplist;
+
+ this.allowDefault.IsChecked = network.AllowDefault;
+ this.allowGlobal.IsChecked = network.AllowGlobal;
+ this.allowManaged.IsChecked = network.AllowManaged;
}
public bool HasNetwork(ZeroTierNetwork network)
@@ -68,5 +72,32 @@ namespace WinUI
{
handler.LeaveNetwork(network.NetworkId);
}
+
+ private void AllowManaged_CheckStateChanged(object sender, RoutedEventArgs e)
+ {
+ CheckBox cb = sender as CheckBox;
+ handler.JoinNetwork(network.NetworkId,
+ allowManaged.IsChecked ?? false,
+ allowGlobal.IsChecked ?? false,
+ allowDefault.IsChecked ?? false);
+ }
+
+ private void AllowGlobal_CheckStateChanged(object sender, RoutedEventArgs e)
+ {
+ CheckBox cb = sender as CheckBox;
+ handler.JoinNetwork(network.NetworkId,
+ allowManaged.IsChecked ?? false,
+ allowGlobal.IsChecked ?? false,
+ allowDefault.IsChecked ?? false);
+ }
+
+ private void AllowDefault_CheckStateChanged(object sender, RoutedEventArgs e)
+ {
+ CheckBox cb = sender as CheckBox;
+ handler.JoinNetwork(network.NetworkId,
+ allowManaged.IsChecked ?? false,
+ allowGlobal.IsChecked ?? false,
+ allowDefault.IsChecked ?? false);
+ }
}
}
diff --git a/windows/WinUI/NetworkRoute.cs b/windows/WinUI/NetworkRoute.cs
new file mode 100644
index 00000000..61616f44
--- /dev/null
+++ b/windows/WinUI/NetworkRoute.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
+namespace WinUI
+{
+ public class NetworkRoute
+ {
+ [JsonProperty("target")]
+ public string Target { get; set; }
+
+ [JsonProperty("via")]
+ public string Via { get; set; }
+
+ [JsonProperty("flags")]
+ public int Flags { get; set; }
+
+ [JsonProperty("metric")]
+ public int Metric { get; set; }
+ }
+}
diff --git a/windows/WinUI/WinUI.csproj b/windows/WinUI/WinUI.csproj
index c3eeaba4..9e3527c9 100644
--- a/windows/WinUI/WinUI.csproj
+++ b/windows/WinUI/WinUI.csproj
@@ -99,6 +99,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Compile Include="NetworkRoute.cs" />
<Compile Include="NetworksPage.xaml.cs">
<DependentUpon>NetworksPage.xaml</DependentUpon>
</Compile>
diff --git a/windows/WinUI/ZeroTierNetwork.cs b/windows/WinUI/ZeroTierNetwork.cs
index cce65441..6a6f8498 100644
--- a/windows/WinUI/ZeroTierNetwork.cs
+++ b/windows/WinUI/ZeroTierNetwork.cs
@@ -42,13 +42,22 @@ namespace WinUI
[JsonProperty("netconfRevision")]
public int NetconfRevision { get; set; }
- [JsonProperty("multicastSubscriptions")]
- public string[] MulticastSubscriptions { get; set; }
-
[JsonProperty("assignedAddresses")]
public string[] AssignedAddresses { get; set; }
+ [JsonProperty("routes")]
+ public NetworkRoute[] Routes { get; set; }
+
[JsonProperty("portDeviceName")]
public string DeviceName { get; set; }
+
+ [JsonProperty("allowManaged")]
+ public bool AllowManaged { get; set; }
+
+ [JsonProperty("allowGlobal")]
+ public bool AllowGlobal { get; set; }
+
+ [JsonProperty("allowDefault")]
+ public bool AllowDefault { get; set; }
}
}