Skip to content

Commit

Permalink
Update for dnscrypt-proxy 2.1.0+ compatibility (bitbeans#558)
Browse files Browse the repository at this point in the history
* Update config generation for dnscrypt-proxy 2.1.0+

* Update .NET SDK version

* Fix AL1073 warning

* Update toml for version 2.1.0

* Update dnscrypt-proxy

* Remove legacy option

* Further config updates for 2.1.0

* Update version

* Automatically remove legacy config
  • Loading branch information
Dola-Shuvi authored Dec 30, 2021
1 parent bc47278 commit 46dcbb7
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 66 deletions.
35 changes: 14 additions & 21 deletions SimpleDnsCrypt/App.config
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="SimpleDnsCrypt.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SimpleDnsCrypt.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}"
archiveEvery="Day"
maxArchiveFiles="1"
fileName="${basedir}/logs/${cached:${date:format=yyyy-MM-dd HH_mm_ss}}_${level}.log"
archiveFileName="${basedir}/logs/{#}.log"
archiveDateFormat="yyyy-MM-dd HH_mm_ss"
archiveNumbering="Date"/>
<target name="file" xsi:type="File" layout="${longdate} ${logger} ${message}" archiveEvery="Day" maxArchiveFiles="1" fileName="${basedir}/logs/${cached:${date:format=yyyy-MM-dd HH_mm_ss}}_${level}.log" archiveFileName="${basedir}/logs/{#}.log" archiveDateFormat="yyyy-MM-dd HH_mm_ss" archiveNumbering="Date"/>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
<logger name="*" minlevel="Debug" writeTo="file"/>
</rules>
</nlog>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<SimpleDnsCrypt.Properties.Settings>
Expand All @@ -45,7 +38,7 @@
<value>True</value>
</setting>
<setting name="PreferredLanguage" serializeAs="String">
<value />
<value/>
</setting>
<setting name="MinUpdateType" serializeAs="String">
<value>2</value>
Expand All @@ -54,16 +47,16 @@
<value>True</value>
</setting>
<setting name="DomainWhitelistRules" serializeAs="String">
<value />
<value/>
</setting>
<setting name="DomainBlacklistRules" serializeAs="String">
<value />
<value/>
</setting>
<setting name="DomainBlacklistFile" serializeAs="String">
<value />
<value/>
</setting>
<setting name="QueryLogFile" serializeAs="String">
<value />
<value/>
</setting>
<setting name="UpgradeRequired" serializeAs="String">
<value>True</value>
Expand All @@ -84,13 +77,13 @@
<value>True</value>
</setting>
<setting name="CloakingRulesFile" serializeAs="String">
<value />
<value/>
</setting>
<setting name="IsCloakAndForwardTabVisible" serializeAs="String">
<value>False</value>
</setting>
<setting name="ForwardingRulesFile" serializeAs="String">
<value />
<value/>
</setting>
<setting name="WindowWidth" serializeAs="String">
<value>825</value>
Expand All @@ -100,4 +93,4 @@
</setting>
</SimpleDnsCrypt.Properties.Settings>
</userSettings>
</configuration>
</configuration>
Binary file modified SimpleDnsCrypt/DNSx64/dnscrypt-proxy.exe
Binary file not shown.
Binary file modified SimpleDnsCrypt/DNSx86/dnscrypt-proxy.exe
Binary file not shown.
13 changes: 13 additions & 0 deletions SimpleDnsCrypt/Helper/PatchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ public static bool Patch()
};
return DnscryptProxyConfigurationManager.SaveConfiguration();
}
if (version.Equals("0.7.2"))
{
//removed: daemonize
var configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), Global.DnsCryptProxyFolder, Global.DnsCryptConfigurationFile);
if (!System.IO.File.Exists(configFile)) return false;
var settings = Nett.TomlSettings.Create(s => s.ConfigurePropertyMapping(m => m.UseTargetPropertySelector(standardSelectors => standardSelectors.IgnoreCase)));

Nett.TomlTable toml = Nett.Toml.ReadFile(configFile);
toml.Remove("daemonize");
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration = Nett.Toml.ReadString<DnscryptProxyConfiguration>(toml.ToString(), settings);

return DnscryptProxyConfigurationManager.SaveConfiguration();
}

return false;
}
Expand Down
19 changes: 7 additions & 12 deletions SimpleDnsCrypt/Models/DnscryptProxyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ public bool require_nofilter
}
}

/// <summary>
/// linux only.
/// </summary>
public bool daemonize { get; set; } = false;

/// <summary>
/// Always use TCP to connect to upstream servers.
/// </summary>
Expand Down Expand Up @@ -742,12 +737,12 @@ public int cache_neg_max_ttl
/// <summary>
/// Pattern-based blocking (blacklists).
/// </summary>
public Blacklist blacklist { get; set; }
public Blacklist blocked_names { get; set; }

/// <summary>
/// Pattern-based IP blocking (IP blacklists).
/// </summary>
public Blacklist ip_blacklist { get; set; }
public Blacklist blocked_ips { get; set; }

public AnonymizedDns anonymized_dns { get; set; }

Expand Down Expand Up @@ -986,7 +981,7 @@ public string file
public class Blacklist : PropertyChangedBase
{
private string _log_format;
private string _blacklist_file;
private string _blocked_names_file;
private string _log_file;

[TomlIgnore]
Expand All @@ -999,13 +994,13 @@ public class Blacklist : PropertyChangedBase
/// <summary>
/// Path to the file of blocking rules.
/// </summary>
public string blacklist_file
public string blocked_names_file
{
get => _blacklist_file;
get => _blocked_names_file;
set
{
_blacklist_file = value;
NotifyOfPropertyChange(() => blacklist_file);
_blocked_names_file = value;
NotifyOfPropertyChange(() => blocked_names_file);
}
}

Expand Down
4 changes: 2 additions & 2 deletions SimpleDnsCrypt/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("0.7.1")]
[assembly: AssemblyFileVersion("0.7.1")]
[assembly: AssemblyVersion("0.7.2")]
[assembly: AssemblyFileVersion("0.7.2")]
2 changes: 1 addition & 1 deletion SimpleDnsCrypt/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SimpleDnsCrypt/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SimpleDnsCrypt/Resources/Translation.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions SimpleDnsCrypt/SimpleDnsCrypt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<OutputType>WinExe</OutputType>
<RootNamespace>SimpleDnsCrypt</RootNamespace>
<AssemblyName>SimpleDnsCrypt</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
Expand Down Expand Up @@ -562,7 +563,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)$(PlatformTarget)\</TargetFrameworkSDKToolsDirectory>
<TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)\</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)DNS$(PlatformName)\*" "$(ProjectDir)$(OutDir)\dnscrypt-proxy\"</PostBuildEvent>
Expand Down
18 changes: 9 additions & 9 deletions SimpleDnsCrypt/ViewModels/DomainBlacklistViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,26 @@ private async void ManageDnsCryptBlacklist(DnscryptProxyConfiguration dnscryptPr
if (dnscryptProxyConfiguration == null) return;

var saveAndRestartService = false;
if (dnscryptProxyConfiguration.blacklist == null)
if (dnscryptProxyConfiguration.blocked_names == null)
{
dnscryptProxyConfiguration.blacklist = new Blacklist
dnscryptProxyConfiguration.blocked_names = new Blacklist
{
blacklist_file = _domainBlacklistFile,
blocked_names_file = _domainBlacklistFile,
log_format = defaultLogFormat
};
saveAndRestartService = true;
}

if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blacklist.log_format) ||
!dnscryptProxyConfiguration.blacklist.log_format.Equals(defaultLogFormat))
if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blocked_names.log_format) ||
!dnscryptProxyConfiguration.blocked_names.log_format.Equals(defaultLogFormat))
{
dnscryptProxyConfiguration.blacklist.log_format = defaultLogFormat;
dnscryptProxyConfiguration.blocked_names.log_format = defaultLogFormat;
saveAndRestartService = true;
}

if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blacklist.blacklist_file))
if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blocked_names.blocked_names_file))
{
dnscryptProxyConfiguration.blacklist.blacklist_file = _domainBlacklistFile;
dnscryptProxyConfiguration.blocked_names.blocked_names_file = _domainBlacklistFile;
saveAndRestartService = true;
}

Expand Down Expand Up @@ -196,7 +196,7 @@ private async void ManageDnsCryptBlacklist(DnscryptProxyConfiguration dnscryptPr
{
//disable blacklist again
_isBlacklistEnabled = false;
dnscryptProxyConfiguration.blacklist.blacklist_file = null;
dnscryptProxyConfiguration.blocked_names.blocked_names_file = null;
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration = dnscryptProxyConfiguration;
DnscryptProxyConfigurationManager.SaveConfiguration();
if (DnsCryptProxyManager.IsDnsCryptProxyRunning())
Expand Down
18 changes: 9 additions & 9 deletions SimpleDnsCrypt/ViewModels/DomainBlockLogViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,26 @@ private async void DomainBlockLog(DnscryptProxyConfiguration dnscryptProxyConfig
if (dnscryptProxyConfiguration == null) return;

var saveAndRestartService = false;
if (dnscryptProxyConfiguration.blacklist == null)
if (dnscryptProxyConfiguration.blocked_names == null)
{
dnscryptProxyConfiguration.blacklist = new Blacklist
dnscryptProxyConfiguration.blocked_names = new Blacklist
{
log_file = Global.DomainBlockLogFileName,
log_format = defaultLogFormat
};
saveAndRestartService = true;
}

if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blacklist.log_format) ||
!dnscryptProxyConfiguration.blacklist.log_format.Equals(defaultLogFormat))
if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blocked_names.log_format) ||
!dnscryptProxyConfiguration.blocked_names.log_format.Equals(defaultLogFormat))
{
dnscryptProxyConfiguration.blacklist.log_format = defaultLogFormat;
dnscryptProxyConfiguration.blocked_names.log_format = defaultLogFormat;
saveAndRestartService = true;
}

if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blacklist.log_file))
if (string.IsNullOrEmpty(dnscryptProxyConfiguration.blocked_names.log_file))
{
dnscryptProxyConfiguration.blacklist.log_file = Global.DomainBlockLogFileName;
dnscryptProxyConfiguration.blocked_names.log_file = Global.DomainBlockLogFileName;
saveAndRestartService = true;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ private async void DomainBlockLog(DnscryptProxyConfiguration dnscryptProxyConfig
}

DomainBlockLogFile = Path.Combine(Directory.GetCurrentDirectory(), Global.DnsCryptProxyFolder,
dnscryptProxyConfiguration.blacklist.log_file);
dnscryptProxyConfiguration.blocked_names.log_file);

if (!string.IsNullOrEmpty(_domainBlockLogFile))
{
Expand Down Expand Up @@ -238,7 +238,7 @@ await Task.Run(() =>
{
//disable block log again
_isDomainBlockLogLogging = false;
dnscryptProxyConfiguration.blacklist.log_file = null;
dnscryptProxyConfiguration.blocked_names.log_file = null;
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration = dnscryptProxyConfiguration;
DnscryptProxyConfigurationManager.SaveConfiguration();
if (DnsCryptProxyManager.IsDnsCryptProxyRunning())
Expand Down
12 changes: 6 additions & 6 deletions SimpleDnsCrypt/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,20 +497,20 @@ public void Initialize()
QueryLogViewModel.IsQueryLogLogging = true;
}

if (!string.IsNullOrEmpty(DnscryptProxyConfiguration?.blacklist?.log_file))
if (!string.IsNullOrEmpty(DnscryptProxyConfiguration?.blocked_names?.log_file))
{
if (!File.Exists(DnscryptProxyConfiguration.blacklist.log_file))
if (!File.Exists(DnscryptProxyConfiguration.blocked_names.log_file))
{
File.Create(DnscryptProxyConfiguration.blacklist.log_file).Dispose();
File.Create(DnscryptProxyConfiguration.blocked_names.log_file).Dispose();
}
DomainBlockLogViewModel.IsDomainBlockLogLogging = true;
}

if (!string.IsNullOrEmpty(DnscryptProxyConfiguration?.blacklist?.blacklist_file))
if (!string.IsNullOrEmpty(DnscryptProxyConfiguration?.blocked_names?.blocked_names_file))
{
if (!File.Exists(DnscryptProxyConfiguration.blacklist.blacklist_file))
if (!File.Exists(DnscryptProxyConfiguration.blocked_names.blocked_names_file))
{
File.Create(DnscryptProxyConfiguration.blacklist.blacklist_file).Dispose();
File.Create(DnscryptProxyConfiguration.blocked_names.blocked_names_file).Dispose();
}
DomainBlacklistViewModel.IsBlacklistEnabled = true;
}
Expand Down
4 changes: 2 additions & 2 deletions SimpleDnsCrypt/dnscrypt-proxy/dnscrypt-proxy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ format = 'ltsv'
[nx_log]
format = 'ltsv'

[blacklist]
[blocked_names]

[ip_blacklist]
[blocked_ips]

[broken_implementations]
fragments_blocked = ['cisco', 'cisco-ipv6', 'cisco-familyshield', 'cisco-familyshield-ipv6', 'quad9-dnscrypt-ip4-filter-alt', 'quad9-dnscrypt-ip4-filter-pri', 'quad9-dnscrypt-ip4-nofilter-alt', 'quad9-dnscrypt-ip4-nofilter-pri', 'quad9-dnscrypt-ip6-filter-alt', 'quad9-dnscrypt-ip6-filter-pri', 'quad9-dnscrypt-ip6-nofilter-alt', 'quad9-dnscrypt-ip6-nofilter-pri', 'cleanbrowsing-adult', 'cleanbrowsing-family-ipv6', 'cleanbrowsing-family', 'cleanbrowsing-security']
Expand Down

0 comments on commit 46dcbb7

Please sign in to comment.