Skip to content

Commit

Permalink
Patch config on restore
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbeans committed Jun 3, 2019
1 parent 0b25e39 commit 9ed4f18
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions SimpleDnsCrypt/Helper/PatchHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace SimpleDnsCrypt.Helper
{
/// <summary>
/// Class to update the configuration file.
/// </summary>
public static class PatchHelper
{
public static bool Patch()
{
var version = VersionHelper.PublishVersion;
if (!DnscryptProxyConfigurationManager.LoadConfiguration()) return false;
if (version.Equals("0.6.5"))
{
//added: netprobe_address = '255.255.255.0:53'
//changed: netprobe_timeout = 0
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.netprobe_address = "255.255.255.0:53";
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.netprobe_timeout = 0;
return DnscryptProxyConfigurationManager.SaveConfiguration();
}
return false;
}
}
}
1 change: 1 addition & 0 deletions SimpleDnsCrypt/SimpleDnsCrypt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<Compile Include="Helper\LocalNetworkInterfaceManager.cs" />
<Compile Include="Helper\LogManagerHelper.cs" />
<Compile Include="Helper\NavigationService.cs" />
<Compile Include="Helper\PatchHelper.cs" />
<Compile Include="Helper\PrerequisiteHelper.cs" />
<Compile Include="Helper\ValidationHelper.cs" />
<Compile Include="Helper\VersionHelper.cs" />
Expand Down
5 changes: 5 additions & 0 deletions SimpleDnsCrypt/ViewModels/LoaderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ private async void InitializeApplication()
File.Move(configFile, configFile + ".bak");
}
File.Move(tmpConfigPath, configFile);
// update the configuration file
if (PatchHelper.Patch())
{
await Task.Delay(500).ConfigureAwait(false);
}
}
}

Expand Down

0 comments on commit 9ed4f18

Please sign in to comment.