diff --git a/SimpleDnsCrypt/Properties/AssemblyInfo.cs b/SimpleDnsCrypt/Properties/AssemblyInfo.cs index 7eb95b63..e21131e9 100644 --- a/SimpleDnsCrypt/Properties/AssemblyInfo.cs +++ b/SimpleDnsCrypt/Properties/AssemblyInfo.cs @@ -14,5 +14,5 @@ ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("0.3.0")] -[assembly: AssemblyFileVersion("0.3.0")] +[assembly: AssemblyVersion("0.3.1")] +[assembly: AssemblyFileVersion("0.3.1")] diff --git a/SimpleDnsCrypt/Resources/Strings.Designer.cs b/SimpleDnsCrypt/Resources/Strings.Designer.cs index a9ad6227..dccec134 100644 --- a/SimpleDnsCrypt/Resources/Strings.Designer.cs +++ b/SimpleDnsCrypt/Resources/Strings.Designer.cs @@ -249,6 +249,42 @@ internal static string advanced_settings_uninstall_title { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Block addresses ähnelt. + /// + internal static string block_plugin_sub_addresses_header { + get { + return ResourceManager.GetString("block_plugin_sub_addresses_header", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Block domains ähnelt. + /// + internal static string block_plugin_sub_domains_header { + get { + return ResourceManager.GetString("block_plugin_sub_domains_header", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die This plugin returns a REFUSED response if the query name is in a list of blacklisted names, or if at least one of the returned IP addresses happens to be in a list of blacklisted IPs. ähnelt. + /// + internal static string block_plugin_text { + get { + return ResourceManager.GetString("block_plugin_text", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Block addresses and domains ähnelt. + /// + internal static string block_plugin_title { + get { + return ResourceManager.GetString("block_plugin_title", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die cancel ähnelt. /// diff --git a/SimpleDnsCrypt/Resources/Strings.de.resx b/SimpleDnsCrypt/Resources/Strings.de.resx index 520ced9f..90402c7f 100644 --- a/SimpleDnsCrypt/Resources/Strings.de.resx +++ b/SimpleDnsCrypt/Resources/Strings.de.resx @@ -307,4 +307,16 @@ DNSCrypt wird auf diesem Port lauschen (Standard: 53) + + Blockieren von Adressen und Domains + + + Domains blockieren + + + IP Adressen blockieren + + + Dieses Plugin gibt als Response REFUSED zurück, falls die Anfrage in der Domain-Blacklist oder in der IP-Blacklist aufgeführt ist. + \ No newline at end of file diff --git a/SimpleDnsCrypt/Resources/Strings.en.resx b/SimpleDnsCrypt/Resources/Strings.en.resx index 4b9a8aab..5afcb0f9 100644 --- a/SimpleDnsCrypt/Resources/Strings.en.resx +++ b/SimpleDnsCrypt/Resources/Strings.en.resx @@ -308,4 +308,16 @@ The logs are stored in a local file. DNSCrypt will listen on this port (default: 53) + + Block addresses and domains + + + This plugin returns a REFUSED response if the query name is in a list of blacklisted names, or if at least one of the returned IP addresses happens to be in a list of blacklisted IPs. + + + Block domains + + + Block addresses + \ No newline at end of file diff --git a/SimpleDnsCrypt/Resources/Strings.resx b/SimpleDnsCrypt/Resources/Strings.resx index 5ae980af..6e4c89ff 100644 --- a/SimpleDnsCrypt/Resources/Strings.resx +++ b/SimpleDnsCrypt/Resources/Strings.resx @@ -308,4 +308,16 @@ The logs are stored in a local file. DNSCrypt will listen on this port (default: 53) + + Block addresses and domains + + + This plugin returns a REFUSED response if the query name is in a list of blacklisted names, or if at least one of the returned IP addresses happens to be in a list of blacklisted IPs. + + + Block domains + + + Block addresses + \ No newline at end of file diff --git a/SimpleDnsCrypt/ViewModels/MainViewModel.cs b/SimpleDnsCrypt/ViewModels/MainViewModel.cs index eb633fae..8a82aede 100644 --- a/SimpleDnsCrypt/ViewModels/MainViewModel.cs +++ b/SimpleDnsCrypt/ViewModels/MainViewModel.cs @@ -3,6 +3,7 @@ using System.ComponentModel.Composition; using System.Diagnostics; using System.Dynamic; +using System.Globalization; using System.IO; using System.Linq; using System.Net.NetworkInformation; @@ -69,8 +70,8 @@ private MainViewModel(IWindowManager windowManager, IEventAggregator eventAggreg LocalizeDictionary.Instance.SetCurrentThreadCulture = true; LocalizeDictionary.Instance.Culture = Thread.CurrentThread.CurrentCulture; - // this is already defined in the app.manifest, but to be sure check it again - if (!IsAdministrator()) + // this is already defined in the app.manifest, but to be sure check it again + if (!IsAdministrator()) { _windowManager.ShowMetroMessageBox( LocalizationEx.GetUiString("dialog_message_bad_privileges", Thread.CurrentThread.CurrentCulture), diff --git a/SimpleDnsCrypt/ViewModels/PluginManagerViewModel.cs b/SimpleDnsCrypt/ViewModels/PluginManagerViewModel.cs index 0ca141ac..983e1755 100644 --- a/SimpleDnsCrypt/ViewModels/PluginManagerViewModel.cs +++ b/SimpleDnsCrypt/ViewModels/PluginManagerViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel.Composition; using System.IO; using System.Windows.Forms; @@ -14,14 +15,19 @@ namespace SimpleDnsCrypt.ViewModels [Export] public sealed class PluginManagerViewModel : Screen { - private const string LibdcpluginLdns = "libdcplugin_ldns_aaaa_blocking.dll"; - private const string LibdcpluginLogging = "libdcplugin_logging.dll"; + private const string LibdcpluginLdnsIpv6 = "libdcplugin_ldns_aaaa_blocking.dll"; + private const string LibdcpluginLdns = "libdcplugin_ldns_blocking.dll"; + private const string LibdcpluginLogging = "libdcplugin_logging.dll"; private bool _blockIpv6Plugin; private bool _logPlugin; - private string _logPluginPath; + private bool _blacklistPlugin; + private string _addressBlacklistPath; + private string _domainBlacklistPath; + private string _logPluginPath; private List _plugins; + - /// + /// /// PluginManagerViewModel constructor. /// [ImportingConstructor] @@ -43,10 +49,84 @@ public List Plugins } } - /// - /// To manage the block IPv6 plugin. - /// - public bool BlockIpv6Plugin + /// + /// To manage the blacklist plugin. + /// + public bool BlacklistPlugin + { + get { return _blacklistPlugin; } + set + { + _blacklistPlugin = value; + if (value) + { + if (AddressBlacklistPath != null && File.Exists(AddressBlacklistPath) || DomainBlacklistPath != null && File.Exists(DomainBlacklistPath)) + { + var p = LibdcpluginLdns + ""; + var kindCounter = 0; + + if (!string.IsNullOrEmpty(AddressBlacklistPath)) + { + // dnscrypt-proxy will not start if the file is empty + if (File.ReadAllLines(AddressBlacklistPath).Length != 0) + { + p += ",--ips=" + AddressBlacklistPath; + kindCounter++; + } + else + { + // better show a notification to the user + AddressBlacklistPath = string.Empty; + } + } + + if (!string.IsNullOrEmpty(DomainBlacklistPath)) + { + // dnscrypt-proxy will not start if the file is empty + if (File.ReadAllLines(DomainBlacklistPath).Length != 0) + { + p += ",--domains=" + DomainBlacklistPath; + kindCounter++; + } + else + { + // better show a notification to the user + DomainBlacklistPath = string.Empty; + } + } + + if (kindCounter > 0) + { + Plugins.Add(p); + _blacklistPlugin = true; + } + else + { + _blacklistPlugin = false; + } + } + else + { + _blacklistPlugin = false; + } + } + else + { + for (var i = 0; i < Plugins.Count; i++) + { + if (!Plugins[i].StartsWith(LibdcpluginLdns)) continue; + Plugins.RemoveAt(i); + NotifyOfPropertyChange(() => BlacklistPlugin); + } + } + NotifyOfPropertyChange(() => BlacklistPlugin); + } + } + + /// + /// To manage the block IPv6 plugin. + /// + public bool BlockIpv6Plugin { get { return _blockIpv6Plugin; } set @@ -54,11 +134,11 @@ public bool BlockIpv6Plugin _blockIpv6Plugin = value; if (value) { - Plugins.Add(LibdcpluginLdns); + Plugins.Add(LibdcpluginLdnsIpv6); } else { - Plugins.Remove(LibdcpluginLdns); + Plugins.Remove(LibdcpluginLdnsIpv6); } NotifyOfPropertyChange(() => BlockIpv6Plugin); } @@ -113,10 +193,36 @@ public string LogPluginPath } } - /// - /// FolderBrowserDialog to select the log folder. - /// - public void SelectFolder() + /// + /// The full path to the domain blacklist file. + /// + public string DomainBlacklistPath + { + get { return _domainBlacklistPath; } + set + { + _domainBlacklistPath = value; + NotifyOfPropertyChange(() => DomainBlacklistPath); + } + } + + /// + /// The full path to the address blacklist file. + /// + public string AddressBlacklistPath + { + get { return _addressBlacklistPath; } + set + { + _addressBlacklistPath = value; + NotifyOfPropertyChange(() => AddressBlacklistPath); + } + } + + /// + /// FolderBrowserDialog to select the log folder. + /// + public void SelectFolder() { try { @@ -131,20 +237,87 @@ public void SelectFolder() } } - /// - /// Set the used plugins. - /// - /// List of plugins. - public void SetPlugins(List plugins) + /// + /// FileBrowserDialog to select the domain blacklist file. + /// + public void SelectDomainBlacklist() + { + try + { + var dialog = new OpenFileDialog + { + Multiselect = false, + CheckFileExists = true + }; + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + DomainBlacklistPath = dialog.FileName; + } + catch (Exception) + { + DomainBlacklistPath = string.Empty; + } + } + + /// + /// FileBrowserDialog to select the address blacklist file. + /// + public void SelectAddressBlacklist() + { + try + { + var dialog = new OpenFileDialog + { + Multiselect = false, + CheckFileExists = true + }; + var result = dialog.ShowDialog(); + if (result != DialogResult.OK) return; + AddressBlacklistPath = dialog.FileName; + } + catch (Exception) + { + AddressBlacklistPath = string.Empty; + } + } + + /// + /// Set the used plugins. + /// + /// List of plugins. + public void SetPlugins(List plugins) { _plugins = plugins; foreach (var plugin in _plugins) { - if (plugin.Equals(LibdcpluginLdns)) + if (plugin.Equals(LibdcpluginLdnsIpv6)) { _blockIpv6Plugin = true; } - if (plugin.StartsWith(LibdcpluginLogging)) + if (plugin.StartsWith(LibdcpluginLdns)) + { + var a = plugin.Split(','); + + for (var r = 1; r < a.Length; r++) + { + if (a[r].StartsWith("--ips")) + { + var b = a[r].Split('='); + _addressBlacklistPath = b[1]; + } + if (a[r].StartsWith("--domains")) + { + var b = a[r].Split('='); + _domainBlacklistPath = b[1]; + } + } + + if (!string.IsNullOrEmpty(_addressBlacklistPath) || !string.IsNullOrEmpty(_domainBlacklistPath)) + { + _blacklistPlugin = true; + } + } + if (plugin.StartsWith(LibdcpluginLogging)) { var a = plugin.Split(','); _logPluginPath = a[1]; diff --git a/SimpleDnsCrypt/Views/PluginManagerView.xaml b/SimpleDnsCrypt/Views/PluginManagerView.xaml index 070d3d7f..e32e147e 100644 --- a/SimpleDnsCrypt/Views/PluginManagerView.xaml +++ b/SimpleDnsCrypt/Views/PluginManagerView.xaml @@ -13,16 +13,17 @@ lex:ResxLocalizationProvider.DefaultDictionary="Strings" d:DataContext="{d:DesignInstance Type=viewModels:PluginManagerViewModel, IsDesignTimeCreatable=True}" cal:Bind.AtDesignTime="True" - mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="470"> + mc:Ignorable="d" d:DesignHeight="900" d:DesignWidth="470"> - + + + Padding="10"> @@ -39,11 +40,10 @@ - + - + @@ -66,35 +66,35 @@ + FontFamily="/Resources/fontawesome-webfont.ttf#FontAwesome" + FontSize="20" + HorizontalAlignment="Left" VerticalAlignment="Center" + Foreground="#FF8ab329"> + TextWrapping="Wrap" VerticalAlignment="Center" + Foreground="#FF8ab329" FontSize="20" + Opacity="0.7" Margin="5,0,0,3" FontWeight="Bold"> + Text="{lex:Loc Key=ipv6_speed_plugin_text}" + TextWrapping="Wrap" Foreground="#FF575757" FontSize="14"> + IsEnabled="True" Cursor="Hand" + IsChecked="{Binding BlockIpv6Plugin}" + HorizontalAlignment="Right" VerticalAlignment="Top"> + Opacity="0.4"> @@ -117,6 +117,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + + + + +