Skip to content

Commit

Permalink
Added dnscrypt-proxy log to advanced settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbeans committed Nov 16, 2019
1 parent 3adad68 commit 0fb52dc
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 84 deletions.
142 changes: 76 additions & 66 deletions SimpleDnsCrypt/Config/Global.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
namespace SimpleDnsCrypt.Config
{
public static class Global
{
{
/// <summary>
/// The name of this application.
/// </summary>
public const string ApplicationName = "Simple DNSCrypt";

/// <summary>
/// Remote URI where the application will find the update informations.
/// </summary>
public const string ApplicationUpdateUri =
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update.yml";
/// <summary>
/// Remote URI where the application will find the update informations.
/// </summary>
public const string ApplicationUpdateUri =
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update.yml";

/// <summary>
/// Remote URI where the application will find the update informations.
/// </summary>
public const string ApplicationUpdateUri64 =
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update64.yml";
/// <summary>
/// Remote URI where the application will find the update informations.
/// </summary>
public const string ApplicationUpdateUri64 =
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update64.yml";

/// <summary>
/// The public key to validate the installer.
Expand All @@ -34,83 +34,93 @@ public static class Global
/// </summary>
public const string RedistributablePackage64 = "https://aka.ms/vs/16/release/VC_redist.x64.exe";

/// <summary>
/// Output folder for logs.
/// </summary>
public const string LogDirectory = "logs";

/// <summary>
/// The folder where the dnscrypt-proxy lives in.
/// </summary>
public const string DnsCryptProxyFolder = "dnscrypt-proxy";

public const string DnsCryptProxyExecutableName = "dnscrypt-proxy.exe";
public const string DnsCryptProxyExecutableName = "dnscrypt-proxy.exe";

public const string DnsCryptConfigurationFile = "dnscrypt-proxy.toml";

/// <summary>
/// Time we wait on a service restart (ms).
/// </summary>
public const int ServiceRestartTime = 5000;
/// <summary>
/// Logfile name of dnscrypt-proxy.
/// </summary>
public const string DnsCryptLogFile = "dnscrypt-proxy.log";

/// <summary>
/// Time we wait on a service start (ms).
/// </summary>
public const int ServiceStartTime = 2500;
/// <summary>
/// Time we wait on a service restart (ms).
/// </summary>
public const int ServiceRestartTime = 5000;

/// <summary>
/// Time we wait on a service stop (ms).
/// </summary>
public const int ServiceStopTime = 2500;
/// <summary>
/// Time we wait on a service start (ms).
/// </summary>
public const int ServiceStartTime = 2500;

/// <summary>
/// Time we wait on a service uninstall (ms).
/// </summary>
public const int ServiceUninstallTime = 2500;
/// <summary>
/// Time we wait on a service stop (ms).
/// </summary>
public const int ServiceStopTime = 2500;

/// <summary>
/// Time we wait on a service install (ms).
/// </summary>
public const int ServiceInstallTime = 3000;
/// <summary>
/// Time we wait on a service uninstall (ms).
/// </summary>
public const int ServiceUninstallTime = 2500;

public const string DomainBlockLogFileName = "blocked.log";
public const string QueryLogFileName = "query.log";
/// <summary>
/// Time we wait on a service install (ms).
/// </summary>
public const int ServiceInstallTime = 3000;

public const string DomainBlockLogFileName = "blocked.log";
public const string QueryLogFileName = "query.log";

public const string WhitelistRuleFileName = "domain-whitelist.txt";
public const string BlacklistRuleFileName = "domain-blacklist.txt";
public const string BlacklistFileName = "blacklist.txt";
public const string WhitelistRuleFileName = "domain-whitelist.txt";
public const string BlacklistRuleFileName = "domain-blacklist.txt";
public const string BlacklistFileName = "blacklist.txt";

public const string CloakingRulesFileName = "cloaking-rules.txt";
public const string ForwardingRulesFileName = "forwarding-rules.txt";
public const string CloakingRulesFileName = "cloaking-rules.txt";
public const string ForwardingRulesFileName = "forwarding-rules.txt";

public const string GlobalResolver = "0.0.0.0:53";
public const string DefaultResolverIpv4 = "127.0.0.1:53";
public const string DefaultResolverIpv6 = "[::1]:53";
public const string DefaultResolverIpv4 = "127.0.0.1:53";
public const string DefaultResolverIpv6 = "[::1]:53";

/// <summary>
/// List of files must exist.
/// </summary>
public static readonly string[] DnsCryptProxyFiles =
{
"dnscrypt-proxy.exe",
{
"dnscrypt-proxy.exe",
"dnscrypt-proxy.toml",
"LICENSE"
};

/// <summary>
/// List of interfaces, marked as hidden.
/// </summary>
public static readonly string[] NetworkInterfaceBlacklist =
{
"Microsoft Virtual",
"Hamachi Network",
"VMware Virtual",
"VirtualBox",
"Software Loopback",
"Microsoft ISATAP",
"Microsoft-ISATAP",
"Teredo Tunneling Pseudo-Interface",
"Microsoft Wi-Fi Direct Virtual",
"Microsoft Teredo Tunneling Adapter",
"Von Microsoft gehosteter",
"Microsoft hosted",
"Virtueller Microsoft-Adapter",
"TAP"
};
}
};

/// <summary>
/// List of interfaces, marked as hidden.
/// </summary>
public static readonly string[] NetworkInterfaceBlacklist =
{
"Microsoft Virtual",
"Hamachi Network",
"VMware Virtual",
"VirtualBox",
"Software Loopback",
"Microsoft ISATAP",
"Microsoft-ISATAP",
"Teredo Tunneling Pseudo-Interface",
"Microsoft Wi-Fi Direct Virtual",
"Microsoft Teredo Tunneling Adapter",
"Von Microsoft gehosteter",
"Microsoft hosted",
"Virtueller Microsoft-Adapter",
"TAP"
};
}
}
34 changes: 34 additions & 0 deletions SimpleDnsCrypt/Models/DnscryptProxyConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Caliburn.Micro;
using DnsCrypt.Models;
using Nett;
using SimpleDnsCrypt.Config;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;

// ReSharper disable InconsistentNaming

Expand All @@ -29,6 +31,7 @@ public class DnscryptProxyConfiguration : PropertyChangedBase
private int _cert_refresh_delay;
private bool _dnscrypt_ephemeral_keys;
private bool _tls_disable_session_tickets;
private bool _log;
private int _log_level;
private string _log_file;
private Dictionary<string, Source> _sources;
Expand Down Expand Up @@ -401,6 +404,37 @@ public string netprobe_address
}
}

/// <summary>
/// Enable or disable dnscrypt proxy logging.
/// </summary>
[TomlIgnore]
public bool log
{
get
{
if (string.IsNullOrEmpty(log_file)) return false;
//TODO: make Configurable
var logFile = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory, Global.DnsCryptLogFile);
return log_file.Equals(logFile);
}
set
{
_log = value;
if (value)
{
var logFile = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory, Global.DnsCryptLogFile);
_log_level = 0;
_log_file = logFile;
}
else
{
_log_level = 0;
_log_file = null;
}
NotifyOfPropertyChange(() => log);
}
}

/// <summary>
/// Log level (0-6, default: 2 - 0 is very verbose, 6 only contains fatal errors).
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion SimpleDnsCrypt/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ public void OpenLogDirectory()
{
try
{
var logDirectory = Path.Combine(Directory.GetCurrentDirectory(), "logs");
var logDirectory = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory);
if (!Directory.Exists(logDirectory))
{
Directory.CreateDirectory(logDirectory);
Expand Down
72 changes: 55 additions & 17 deletions SimpleDnsCrypt/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@
</DrawingBrush>
</Border.BorderBrush>
<StackPanel Orientation="Vertical">
<!-- Listen Addresses begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -639,6 +640,8 @@
Grid.Row="0" Grid.Column="1" Cursor="Hand" Content="{lex:Loc Key=address_settings_manage_listen_addresses}" x:Name="ListenAddresses" Margin="0,0,0,5"
HorizontalAlignment="Right" Style="{DynamicResource CustomAccentedSquareButtonStyle}" VerticalAlignment="Top"></Button>
</Grid>
<!-- Listen Addresses end -->
<!-- DNS Cache begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -679,6 +682,8 @@
HorizontalAlignment="Right" VerticalAlignment="Top">
</controls:ToggleSwitchButton>
</Grid>
<!-- DNS Cache end -->
<!-- Block IPv6 begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -719,6 +724,8 @@
HorizontalAlignment="Right" VerticalAlignment="Top">
</controls:ToggleSwitchButton>
</Grid>
<!-- Block IPv6 end -->
<!-- Force TCP begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -759,6 +766,8 @@
HorizontalAlignment="Right" VerticalAlignment="Top">
</controls:ToggleSwitchButton>
</Grid>
<!-- Force TCP end -->
<!-- Global Resolver begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -799,6 +808,8 @@
HorizontalAlignment="Right" VerticalAlignment="Top">
</controls:ToggleSwitchButton>
</Grid>
<!-- Global Resolver end -->
<!-- Fallback Resolver begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -851,6 +862,8 @@
</Validation.ErrorTemplate>
</TextBox>
</Grid>
<!-- Fallback Resolver end -->
<!-- Netprobe Timeout begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -891,25 +904,50 @@
Opacity="0.8" BorderBrush="#FF575757"
HorizontalAlignment="Right" VerticalAlignment="Top"
TextAlignment="Right"/>
<!-- <TextBox
</Grid>
<!-- Netprobe Timeout end -->
<!-- Logging begin -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<iconPacks:PackIconMaterial Grid.Column="0" Grid.Row="0" Height="20"
Width="20" Kind="Text"
Opacity="0.7"
Foreground="#FF8ab329"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Grid.Row="0"
Text="Proxy Logging"
TextWrapping="Wrap" VerticalAlignment="Center"
Foreground="#FF8ab329" FontSize="20"
Opacity="0.7" Margin="5,0,0,3" FontWeight="Bold">
</TextBlock>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="35" />
</Grid.RowDefinitions>
<TextBlock Foreground="#FF575757" Grid.Row="0" Grid.Column="0"
TextWrapping="Wrap"
Text="Log to dnscrypt-proxy.log (log_level: 0)"
VerticalAlignment="Bottom"
HorizontalAlignment="Left" Margin="0,0,0,5">
</TextBlock>
<controls:ToggleSwitchButton
IsEnabled="{Binding IsWorkingOnService, Converter={StaticResource ReverseBoolToEnabledConverter}}"
Grid.Row="0" Grid.Column="2" Cursor="Hand" Width="Auto"
controls:TextBoxHelper.Watermark="0" Background="#FF8ab329"
Opacity="0.8" BorderBrush="#FF575757"
HorizontalAlignment="Right" VerticalAlignment="Top"
TextAlignment="Right" IsTabStop="False" Margin="0,0,-1,0">
<Validation.ErrorTemplate>
<ControlTemplate>
<Grid>
<Border BorderThickness="1" BorderBrush="DarkOrange">
<AdornedElementPlaceholder />
</Border>
</Grid>
</ControlTemplate>
</Validation.ErrorTemplate>
</TextBox>-->
Grid.Row="0" Grid.Column="1" Cursor="Hand"
IsChecked="{Binding DnscryptProxyConfiguration.log}"
HorizontalAlignment="Right" VerticalAlignment="Top">
</controls:ToggleSwitchButton>
</Grid>
<!-- Logging end -->
<Button x:Name="SaveAdvancedSettings"
Cursor="Hand"
Content="{lex:Loc Key=default_settings_apply_settings}"
Expand Down

0 comments on commit 0fb52dc

Please sign in to comment.