Skip to content

Commit 0fb52dc

Browse files
committed
Added dnscrypt-proxy log to advanced settings
1 parent 3adad68 commit 0fb52dc

File tree

4 files changed

+166
-84
lines changed

4 files changed

+166
-84
lines changed

SimpleDnsCrypt/Config/Global.cs

Lines changed: 76 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
namespace SimpleDnsCrypt.Config
22
{
33
public static class Global
4-
{
4+
{
55
/// <summary>
66
/// The name of this application.
77
/// </summary>
88
public const string ApplicationName = "Simple DNSCrypt";
99

10-
/// <summary>
11-
/// Remote URI where the application will find the update informations.
12-
/// </summary>
13-
public const string ApplicationUpdateUri =
14-
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update.yml";
10+
/// <summary>
11+
/// Remote URI where the application will find the update informations.
12+
/// </summary>
13+
public const string ApplicationUpdateUri =
14+
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update.yml";
1515

16-
/// <summary>
17-
/// Remote URI where the application will find the update informations.
18-
/// </summary>
19-
public const string ApplicationUpdateUri64 =
20-
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update64.yml";
16+
/// <summary>
17+
/// Remote URI where the application will find the update informations.
18+
/// </summary>
19+
public const string ApplicationUpdateUri64 =
20+
"https://raw.githubusercontent.com/bitbeans/SimpleDnsCrypt/master/update64.yml";
2121

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

37+
/// <summary>
38+
/// Output folder for logs.
39+
/// </summary>
40+
public const string LogDirectory = "logs";
41+
3742
/// <summary>
3843
/// The folder where the dnscrypt-proxy lives in.
3944
/// </summary>
4045
public const string DnsCryptProxyFolder = "dnscrypt-proxy";
4146

42-
public const string DnsCryptProxyExecutableName = "dnscrypt-proxy.exe";
47+
public const string DnsCryptProxyExecutableName = "dnscrypt-proxy.exe";
4348

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

46-
/// <summary>
47-
/// Time we wait on a service restart (ms).
48-
/// </summary>
49-
public const int ServiceRestartTime = 5000;
51+
/// <summary>
52+
/// Logfile name of dnscrypt-proxy.
53+
/// </summary>
54+
public const string DnsCryptLogFile = "dnscrypt-proxy.log";
5055

51-
/// <summary>
52-
/// Time we wait on a service start (ms).
53-
/// </summary>
54-
public const int ServiceStartTime = 2500;
56+
/// <summary>
57+
/// Time we wait on a service restart (ms).
58+
/// </summary>
59+
public const int ServiceRestartTime = 5000;
5560

56-
/// <summary>
57-
/// Time we wait on a service stop (ms).
58-
/// </summary>
59-
public const int ServiceStopTime = 2500;
61+
/// <summary>
62+
/// Time we wait on a service start (ms).
63+
/// </summary>
64+
public const int ServiceStartTime = 2500;
6065

61-
/// <summary>
62-
/// Time we wait on a service uninstall (ms).
63-
/// </summary>
64-
public const int ServiceUninstallTime = 2500;
66+
/// <summary>
67+
/// Time we wait on a service stop (ms).
68+
/// </summary>
69+
public const int ServiceStopTime = 2500;
6570

66-
/// <summary>
67-
/// Time we wait on a service install (ms).
68-
/// </summary>
69-
public const int ServiceInstallTime = 3000;
71+
/// <summary>
72+
/// Time we wait on a service uninstall (ms).
73+
/// </summary>
74+
public const int ServiceUninstallTime = 2500;
7075

71-
public const string DomainBlockLogFileName = "blocked.log";
72-
public const string QueryLogFileName = "query.log";
76+
/// <summary>
77+
/// Time we wait on a service install (ms).
78+
/// </summary>
79+
public const int ServiceInstallTime = 3000;
80+
81+
public const string DomainBlockLogFileName = "blocked.log";
82+
public const string QueryLogFileName = "query.log";
7383

74-
public const string WhitelistRuleFileName = "domain-whitelist.txt";
75-
public const string BlacklistRuleFileName = "domain-blacklist.txt";
76-
public const string BlacklistFileName = "blacklist.txt";
84+
public const string WhitelistRuleFileName = "domain-whitelist.txt";
85+
public const string BlacklistRuleFileName = "domain-blacklist.txt";
86+
public const string BlacklistFileName = "blacklist.txt";
7787

78-
public const string CloakingRulesFileName = "cloaking-rules.txt";
79-
public const string ForwardingRulesFileName = "forwarding-rules.txt";
88+
public const string CloakingRulesFileName = "cloaking-rules.txt";
89+
public const string ForwardingRulesFileName = "forwarding-rules.txt";
8090

8191
public const string GlobalResolver = "0.0.0.0:53";
82-
public const string DefaultResolverIpv4 = "127.0.0.1:53";
83-
public const string DefaultResolverIpv6 = "[::1]:53";
92+
public const string DefaultResolverIpv4 = "127.0.0.1:53";
93+
public const string DefaultResolverIpv6 = "[::1]:53";
8494

8595
/// <summary>
8696
/// List of files must exist.
8797
/// </summary>
8898
public static readonly string[] DnsCryptProxyFiles =
89-
{
90-
"dnscrypt-proxy.exe",
99+
{
100+
"dnscrypt-proxy.exe",
91101
"dnscrypt-proxy.toml",
92102
"LICENSE"
93-
};
94-
95-
/// <summary>
96-
/// List of interfaces, marked as hidden.
97-
/// </summary>
98-
public static readonly string[] NetworkInterfaceBlacklist =
99-
{
100-
"Microsoft Virtual",
101-
"Hamachi Network",
102-
"VMware Virtual",
103-
"VirtualBox",
104-
"Software Loopback",
105-
"Microsoft ISATAP",
106-
"Microsoft-ISATAP",
107-
"Teredo Tunneling Pseudo-Interface",
108-
"Microsoft Wi-Fi Direct Virtual",
109-
"Microsoft Teredo Tunneling Adapter",
110-
"Von Microsoft gehosteter",
111-
"Microsoft hosted",
112-
"Virtueller Microsoft-Adapter",
113-
"TAP"
114-
};
115-
}
103+
};
104+
105+
/// <summary>
106+
/// List of interfaces, marked as hidden.
107+
/// </summary>
108+
public static readonly string[] NetworkInterfaceBlacklist =
109+
{
110+
"Microsoft Virtual",
111+
"Hamachi Network",
112+
"VMware Virtual",
113+
"VirtualBox",
114+
"Software Loopback",
115+
"Microsoft ISATAP",
116+
"Microsoft-ISATAP",
117+
"Teredo Tunneling Pseudo-Interface",
118+
"Microsoft Wi-Fi Direct Virtual",
119+
"Microsoft Teredo Tunneling Adapter",
120+
"Von Microsoft gehosteter",
121+
"Microsoft hosted",
122+
"Virtueller Microsoft-Adapter",
123+
"TAP"
124+
};
125+
}
116126
}

SimpleDnsCrypt/Models/DnscryptProxyConfiguration.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using Caliburn.Micro;
22
using DnsCrypt.Models;
33
using Nett;
4+
using SimpleDnsCrypt.Config;
45
using System.Collections.Generic;
56
using System.Collections.ObjectModel;
7+
using System.IO;
68

79
// ReSharper disable InconsistentNaming
810

@@ -29,6 +31,7 @@ public class DnscryptProxyConfiguration : PropertyChangedBase
2931
private int _cert_refresh_delay;
3032
private bool _dnscrypt_ephemeral_keys;
3133
private bool _tls_disable_session_tickets;
34+
private bool _log;
3235
private int _log_level;
3336
private string _log_file;
3437
private Dictionary<string, Source> _sources;
@@ -401,6 +404,37 @@ public string netprobe_address
401404
}
402405
}
403406

407+
/// <summary>
408+
/// Enable or disable dnscrypt proxy logging.
409+
/// </summary>
410+
[TomlIgnore]
411+
public bool log
412+
{
413+
get
414+
{
415+
if (string.IsNullOrEmpty(log_file)) return false;
416+
//TODO: make Configurable
417+
var logFile = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory, Global.DnsCryptLogFile);
418+
return log_file.Equals(logFile);
419+
}
420+
set
421+
{
422+
_log = value;
423+
if (value)
424+
{
425+
var logFile = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory, Global.DnsCryptLogFile);
426+
_log_level = 0;
427+
_log_file = logFile;
428+
}
429+
else
430+
{
431+
_log_level = 0;
432+
_log_file = null;
433+
}
434+
NotifyOfPropertyChange(() => log);
435+
}
436+
}
437+
404438
/// <summary>
405439
/// Log level (0-6, default: 2 - 0 is very verbose, 6 only contains fatal errors).
406440
/// </summary>

SimpleDnsCrypt/ViewModels/MainViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ public void OpenLogDirectory()
886886
{
887887
try
888888
{
889-
var logDirectory = Path.Combine(Directory.GetCurrentDirectory(), "logs");
889+
var logDirectory = Path.Combine(Directory.GetCurrentDirectory(), Global.LogDirectory);
890890
if (!Directory.Exists(logDirectory))
891891
{
892892
Directory.CreateDirectory(logDirectory);

SimpleDnsCrypt/Views/MainView.xaml

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@
602602
</DrawingBrush>
603603
</Border.BorderBrush>
604604
<StackPanel Orientation="Vertical">
605+
<!-- Listen Addresses begin -->
605606
<Grid>
606607
<Grid.ColumnDefinitions>
607608
<ColumnDefinition Width="Auto" />
@@ -639,6 +640,8 @@
639640
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"
640641
HorizontalAlignment="Right" Style="{DynamicResource CustomAccentedSquareButtonStyle}" VerticalAlignment="Top"></Button>
641642
</Grid>
643+
<!-- Listen Addresses end -->
644+
<!-- DNS Cache begin -->
642645
<Grid>
643646
<Grid.ColumnDefinitions>
644647
<ColumnDefinition Width="Auto" />
@@ -679,6 +682,8 @@
679682
HorizontalAlignment="Right" VerticalAlignment="Top">
680683
</controls:ToggleSwitchButton>
681684
</Grid>
685+
<!-- DNS Cache end -->
686+
<!-- Block IPv6 begin -->
682687
<Grid>
683688
<Grid.ColumnDefinitions>
684689
<ColumnDefinition Width="Auto" />
@@ -719,6 +724,8 @@
719724
HorizontalAlignment="Right" VerticalAlignment="Top">
720725
</controls:ToggleSwitchButton>
721726
</Grid>
727+
<!-- Block IPv6 end -->
728+
<!-- Force TCP begin -->
722729
<Grid>
723730
<Grid.ColumnDefinitions>
724731
<ColumnDefinition Width="Auto" />
@@ -759,6 +766,8 @@
759766
HorizontalAlignment="Right" VerticalAlignment="Top">
760767
</controls:ToggleSwitchButton>
761768
</Grid>
769+
<!-- Force TCP end -->
770+
<!-- Global Resolver begin -->
762771
<Grid>
763772
<Grid.ColumnDefinitions>
764773
<ColumnDefinition Width="Auto" />
@@ -799,6 +808,8 @@
799808
HorizontalAlignment="Right" VerticalAlignment="Top">
800809
</controls:ToggleSwitchButton>
801810
</Grid>
811+
<!-- Global Resolver end -->
812+
<!-- Fallback Resolver begin -->
802813
<Grid>
803814
<Grid.ColumnDefinitions>
804815
<ColumnDefinition Width="Auto" />
@@ -851,6 +862,8 @@
851862
</Validation.ErrorTemplate>
852863
</TextBox>
853864
</Grid>
865+
<!-- Fallback Resolver end -->
866+
<!-- Netprobe Timeout begin -->
854867
<Grid>
855868
<Grid.ColumnDefinitions>
856869
<ColumnDefinition Width="Auto" />
@@ -891,25 +904,50 @@
891904
Opacity="0.8" BorderBrush="#FF575757"
892905
HorizontalAlignment="Right" VerticalAlignment="Top"
893906
TextAlignment="Right"/>
894-
<!-- <TextBox
907+
</Grid>
908+
<!-- Netprobe Timeout end -->
909+
<!-- Logging begin -->
910+
<Grid>
911+
<Grid.ColumnDefinitions>
912+
<ColumnDefinition Width="Auto" />
913+
<ColumnDefinition Width="Auto" />
914+
<ColumnDefinition Width="*" />
915+
</Grid.ColumnDefinitions>
916+
<iconPacks:PackIconMaterial Grid.Column="0" Grid.Row="0" Height="20"
917+
Width="20" Kind="Text"
918+
Opacity="0.7"
919+
Foreground="#FF8ab329"
920+
HorizontalAlignment="Left"
921+
VerticalAlignment="Center" />
922+
<TextBlock Grid.Column="1" Grid.Row="0"
923+
Text="Proxy Logging"
924+
TextWrapping="Wrap" VerticalAlignment="Center"
925+
Foreground="#FF8ab329" FontSize="20"
926+
Opacity="0.7" Margin="5,0,0,3" FontWeight="Bold">
927+
</TextBlock>
928+
</Grid>
929+
<Grid>
930+
<Grid.ColumnDefinitions>
931+
<ColumnDefinition Width="Auto" />
932+
<ColumnDefinition />
933+
</Grid.ColumnDefinitions>
934+
<Grid.RowDefinitions>
935+
<RowDefinition Height="35" />
936+
</Grid.RowDefinitions>
937+
<TextBlock Foreground="#FF575757" Grid.Row="0" Grid.Column="0"
938+
TextWrapping="Wrap"
939+
Text="Log to dnscrypt-proxy.log (log_level: 0)"
940+
VerticalAlignment="Bottom"
941+
HorizontalAlignment="Left" Margin="0,0,0,5">
942+
</TextBlock>
943+
<controls:ToggleSwitchButton
895944
IsEnabled="{Binding IsWorkingOnService, Converter={StaticResource ReverseBoolToEnabledConverter}}"
896-
Grid.Row="0" Grid.Column="2" Cursor="Hand" Width="Auto"
897-
898-
controls:TextBoxHelper.Watermark="0" Background="#FF8ab329"
899-
Opacity="0.8" BorderBrush="#FF575757"
900-
HorizontalAlignment="Right" VerticalAlignment="Top"
901-
TextAlignment="Right" IsTabStop="False" Margin="0,0,-1,0">
902-
<Validation.ErrorTemplate>
903-
<ControlTemplate>
904-
<Grid>
905-
<Border BorderThickness="1" BorderBrush="DarkOrange">
906-
<AdornedElementPlaceholder />
907-
</Border>
908-
</Grid>
909-
</ControlTemplate>
910-
</Validation.ErrorTemplate>
911-
</TextBox>-->
945+
Grid.Row="0" Grid.Column="1" Cursor="Hand"
946+
IsChecked="{Binding DnscryptProxyConfiguration.log}"
947+
HorizontalAlignment="Right" VerticalAlignment="Top">
948+
</controls:ToggleSwitchButton>
912949
</Grid>
950+
<!-- Logging end -->
913951
<Button x:Name="SaveAdvancedSettings"
914952
Cursor="Hand"
915953
Content="{lex:Loc Key=default_settings_apply_settings}"

0 commit comments

Comments
 (0)