Skip to content

Commit 9ed4f18

Browse files
committed
Patch config on restore
1 parent 0b25e39 commit 9ed4f18

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace SimpleDnsCrypt.Helper
2+
{
3+
/// <summary>
4+
/// Class to update the configuration file.
5+
/// </summary>
6+
public static class PatchHelper
7+
{
8+
public static bool Patch()
9+
{
10+
var version = VersionHelper.PublishVersion;
11+
if (!DnscryptProxyConfigurationManager.LoadConfiguration()) return false;
12+
if (version.Equals("0.6.5"))
13+
{
14+
//added: netprobe_address = '255.255.255.0:53'
15+
//changed: netprobe_timeout = 0
16+
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.netprobe_address = "255.255.255.0:53";
17+
DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.netprobe_timeout = 0;
18+
return DnscryptProxyConfigurationManager.SaveConfiguration();
19+
}
20+
return false;
21+
}
22+
}
23+
}

SimpleDnsCrypt/SimpleDnsCrypt.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<Compile Include="Helper\LocalNetworkInterfaceManager.cs" />
183183
<Compile Include="Helper\LogManagerHelper.cs" />
184184
<Compile Include="Helper\NavigationService.cs" />
185+
<Compile Include="Helper\PatchHelper.cs" />
185186
<Compile Include="Helper\PrerequisiteHelper.cs" />
186187
<Compile Include="Helper\ValidationHelper.cs" />
187188
<Compile Include="Helper\VersionHelper.cs" />

SimpleDnsCrypt/ViewModels/LoaderViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ private async void InitializeApplication()
168168
File.Move(configFile, configFile + ".bak");
169169
}
170170
File.Move(tmpConfigPath, configFile);
171+
// update the configuration file
172+
if (PatchHelper.Patch())
173+
{
174+
await Task.Delay(500).ConfigureAwait(false);
175+
}
171176
}
172177
}
173178

0 commit comments

Comments
 (0)