add Allow DNS settings to win UI

This commit is contained in:
Grant Limberg 2020-09-18 10:12:11 -07:00
parent e7dafb3ae6
commit 45c5abe05b
6 changed files with 58 additions and 13 deletions

View File

@ -272,7 +272,7 @@ namespace WinUI
}
}
public void JoinNetwork(Dispatcher d, string nwid, bool allowManaged = true, bool allowGlobal = false, bool allowDefault = false)
public void JoinNetwork(Dispatcher d, string nwid, bool allowManaged = true, bool allowGlobal = false, bool allowDefault = false, bool allowDNS = false)
{
Task.Factory.StartNew(() =>
{
@ -291,7 +291,8 @@ namespace WinUI
{
string json = "{\"allowManaged\":" + (allowManaged ? "true" : "false") + "," +
"\"allowGlobal\":" + (allowGlobal ? "true" : "false") + "," +
"\"allowDefault\":" + (allowDefault ? "true" : "false") + "}";
"\"allowDefault\":" + (allowDefault ? "true" : "false") + "," +
"\"allowDNS\":" + (allowDNS ? "true" : "false") + "}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();

View File

@ -10,7 +10,8 @@
<TextBox x:Name="joinNetworkBox" HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="291" PreviewTextInput="joinNetworkBox_OnTextEntered" PreviewKeyDown="joinNetworkBox_OnKeyDown"/>
<CheckBox x:Name="allowManagedCheckbox" Content="Allow Managed" HorizontalAlignment="Left" Margin="10,38,0,0" VerticalAlignment="Top" IsChecked="True"/>
<CheckBox x:Name="allowGlobalCheckbox" Content="Allow Global" HorizontalAlignment="Left" Margin="118,38,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="allowDefaultCheckbox" Content="Allow Default" HorizontalAlignment="Left" Margin="210,38,-6,0" VerticalAlignment="Top"/>
<CheckBox x:Name="allowDefaultCheckbox" Content="Allow Default" HorizontalAlignment="Left" Margin="10,58,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="allowDNSCheckbox" Content="Allow DNS" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="118,58,0,0"/>
<Button x:Name="joinButton" Content="Join" HorizontalAlignment="Left" Margin="226,58,0,10" Background="#FFFFB354" VerticalAlignment="Top" Width="75" Click="joinButton_Click" IsEnabled="False"/>
</Grid>
</Window>

View File

@ -117,8 +117,9 @@ namespace WinUI
bool allowDefault = allowDefaultCheckbox.IsChecked.Value;
bool allowGlobal = allowGlobalCheckbox.IsChecked.Value;
bool allowManaged = allowManagedCheckbox.IsChecked.Value;
bool allowDNS = allowDNSCheckbox.IsChecked.Value;
APIHandler.Instance.JoinNetwork(this.Dispatcher, joinNetworkBox.Text, allowManaged, allowGlobal, allowDefault);
APIHandler.Instance.JoinNetwork(this.Dispatcher, joinNetworkBox.Text, allowManaged, allowGlobal, allowDefault, allowDNS);
Close();
}

View File

@ -29,6 +29,7 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3">
@ -54,8 +55,9 @@
<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="11" Fill="#FFEEEEEE"/>
<TextBlock TextWrapping="Wrap" Text="Allow DNS" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="13" Foreground="#FF000000"/>
<Rectangle Grid.Column="2" Grid.Row="2" Grid.RowSpan="12" 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"/>
@ -68,10 +70,11 @@
<CheckBox x:Name="allowGlobal" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="10" />
<CheckBox x:Name="allowManaged" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="11" />
<CheckBox x:Name="allowDefault" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="12" />
<CheckBox x:Name="allowDNS" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="13"/>
<Separator Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="3"/>
<Separator Grid.Column="0" Grid.Row="13" Grid.ColumnSpan="3"/>
<Grid Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="3" Background="GhostWhite">
<Grid Grid.Column="0" Grid.Row="15" Grid.ColumnSpan="3" Background="GhostWhite">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>

View File

@ -36,6 +36,8 @@ namespace WinUI
allowGlobal.Unchecked += AllowGlobal_CheckStateChanged;
allowManaged.Checked += AllowManaged_CheckStateChanged;
allowManaged.Unchecked += AllowManaged_CheckStateChanged;
allowDNS.Checked += AllowDNS_CheckStateChanged;
allowDNS.Unchecked += AllowDNS_CheckStateChanged;
}
private void UpdateNetworkData()
@ -79,6 +81,7 @@ namespace WinUI
this.allowDefault.IsChecked = network.AllowDefault;
this.allowGlobal.IsChecked = network.AllowGlobal;
this.allowManaged.IsChecked = network.AllowManaged;
this.allowDNS.IsChecked = network.AllowDNS;
this.connectedCheckBox.Checked -= connectedCheckBox_Checked;
this.connectedCheckBox.Unchecked -= connectedCheckbox_Unchecked;
@ -116,7 +119,8 @@ namespace WinUI
APIHandler.Instance.JoinNetwork(this.Dispatcher, network.NetworkId,
allowManaged.IsChecked ?? false,
allowGlobal.IsChecked ?? false,
allowDefault.IsChecked ?? false);
allowDefault.IsChecked ?? false,
allowDNS.IsChecked ?? false);
}
private void AllowGlobal_CheckStateChanged(object sender, RoutedEventArgs e)
@ -125,7 +129,8 @@ namespace WinUI
APIHandler.Instance.JoinNetwork(this.Dispatcher, network.NetworkId,
allowManaged.IsChecked ?? false,
allowGlobal.IsChecked ?? false,
allowDefault.IsChecked ?? false);
allowDefault.IsChecked ?? false,
allowDNS.IsChecked ?? false);
}
private void AllowDefault_CheckStateChanged(object sender, RoutedEventArgs e)
@ -134,7 +139,18 @@ namespace WinUI
APIHandler.Instance.JoinNetwork(this.Dispatcher, network.NetworkId,
allowManaged.IsChecked ?? false,
allowGlobal.IsChecked ?? false,
allowDefault.IsChecked ?? false);
allowDefault.IsChecked ?? false,
allowDNS.IsChecked ?? false);
}
private void AllowDNS_CheckStateChanged(object sender, RoutedEventArgs e)
{
CheckBox cb = sender as CheckBox;
APIHandler.Instance.JoinNetwork(this.Dispatcher, network.NetworkId,
allowManaged.IsChecked ?? false,
allowGlobal.IsChecked ?? false,
allowDefault.IsChecked ?? false,
allowDNS.IsChecked ?? false);
}
private void connectedCheckBox_Checked(object sender, RoutedEventArgs e)
@ -154,8 +170,9 @@ namespace WinUI
bool global = allowGlobal.IsChecked.Value;
bool managed = allowManaged.IsChecked.Value;
bool defRoute = allowDefault.IsChecked.Value;
bool dns = allowDNS.IsChecked.Value;
APIHandler.Instance.JoinNetwork(this.Dispatcher, networkId.Text, managed, global, defRoute);
APIHandler.Instance.JoinNetwork(this.Dispatcher, networkId.Text, managed, global, defRoute, dns);
}
else
{

View File

@ -30,6 +30,7 @@ namespace WinUI
private bool allowManaged;
private bool allowGlobal;
private bool allowDefault;
private bool allowDNS;
private bool isConnected;
protected ZeroTierNetwork(SerializationInfo info, StreamingContext ctx)
@ -53,6 +54,7 @@ namespace WinUI
AllowManaged = info.GetBoolean("allowManaged");
AllowGlobal = info.GetBoolean("allowGlobal");
AllowDefault = info.GetBoolean("allowDefault");
AllowDNS = info.GetBoolean("allowDNS");
}
catch { }
IsConnected = false;
@ -79,6 +81,7 @@ namespace WinUI
info.AddValue("allowManaged", AllowManaged);
info.AddValue("allowGlobal", AllowGlobal);
info.AddValue("allowDefault", AllowDefault);
info.AddValue("allowDNS", AllowDNS);
}
public void UpdateNetwork(ZeroTierNetwork network)
@ -165,6 +168,11 @@ namespace WinUI
AllowDefault = network.AllowDefault;
}
if (AllowDNS != network.AllowDNS)
{
AllowDNS = network.AllowDNS;
}
if (IsConnected != network.IsConnected)
{
IsConnected = network.IsConnected;
@ -413,6 +421,20 @@ namespace WinUI
NotifyPropertyChanged();
}
}
[JsonProperty("allowDNS")]
public bool AllowDNS
{
get
{
return allowDNS;
}
set
{
allowDNS = value;
NotifyPropertyChanged();
}
}
public bool IsConnected
{