diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7937dd1cb..2365555c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,6 +2,7 @@ variables:
PUBLIC_REPO_URL: git@github.com:ProtonVPN/win-app.git
stages:
+ - release
- bot # comes from translations/generator job
- build
- test
@@ -179,3 +180,14 @@ i18n-manual-sync-crowdin:
variables:
I18N_SYNC_CROWDIN_PROJECT: 'windows-vpn'
extends: .i18n-sync-crowdin-common
+
+create-release:
+ image: debian:stable-slim
+ stage: release
+ when: manual
+ only:
+ refs:
+ - develop
+ script:
+ - apt-get update && apt-get install -y python3 python3-pip git
+ - python3 ci/release.py
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 3eed436c7..93ec19a6e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -3,4 +3,4 @@
url = https://github.com/ProtonMail/go-srp
[submodule "src/ProtonVPN.LocalAgent"]
path = src/ProtonVPN.LocalAgent
- url = https://gitlab.protontech.ch/ProtonVPN/development/clients-shared.git
\ No newline at end of file
+ url = https://github.com/ProtonVPN/go-vpn-lib.git
\ No newline at end of file
diff --git a/Setup/ProtonVPN.aip b/Setup/ProtonVPN.aip
index e45200c1c..0b34868d2 100644
--- a/Setup/ProtonVPN.aip
+++ b/Setup/ProtonVPN.aip
@@ -282,8 +282,8 @@
-
-
+
+
diff --git a/ci/main.py b/ci/main.py
index 87c350bd7..056ecfc71 100644
--- a/ci/main.py
+++ b/ci/main.py
@@ -8,7 +8,6 @@
import tests
import installer
import ssh
-import os
import guest_hole_server_loader
from pathlib import Path
@@ -99,4 +98,4 @@
elif args.command == 'update-gh-list':
print('Executing guest hole server loader')
- guest_hole_server_loader.load()
+ guest_hole_server_loader.load()
\ No newline at end of file
diff --git a/ci/release.py b/ci/release.py
new file mode 100644
index 000000000..af23eb2cf
--- /dev/null
+++ b/ci/release.py
@@ -0,0 +1,64 @@
+import os
+import re
+
+def get_remote_url():
+ repository = os.getenv("CI_REPOSITORY_URL", "")
+ user = f"git:{os.getenv('RELEASE_PAT')}"
+ (_, url) = repository.split("@")
+ return f"https://{user}@{url.replace(':', '/')}"
+
+def configure_git(git_email, git_username):
+ os.system(f"git config user.email \"{git_email}\"")
+ os.system(f"git config user.name \"{git_username}\"")
+
+def checkout_develop():
+ os.system("git fetch origin develop:develop")
+ os.system("git checkout develop")
+ os.system(f"git remote set-url origin {get_remote_url()}")
+
+def checkout_branch(name):
+ os.system(f"git checkout -b {name}")
+
+def push_branch(name):
+ os.system(f"git push --set-upstream origin {name}")
+
+def create_commit(message):
+ os.system(f"git commit -m \"{message}\"")
+
+def create_debug_branch(version):
+ branch = f"debug/{version}"
+ checkout_branch(branch)
+ push_branch(branch)
+
+def create_release_branch(version, commit_message):
+ checkout_develop()
+ branch = f"release/{version}"
+ checkout_branch(branch)
+ update_app_version(version)
+ create_commit(commit_message)
+ push_branch(branch)
+
+def create_release_and_debug_branches(version):
+ create_release_branch(version, f"Increase app version to {version}")
+ create_debug_branch(version)
+
+def update_app_version(version):
+ file_path = 'src/GlobalAssemblyInfo.cs'
+ content = ''
+ with open(file_path, encoding='latin') as f:
+ content = f.read()
+ content = re.sub(r"(AssemblyVersion\(\")([0-9]+\.[0-9]+\.[0-9]+)", rf"\g<1>{version}", content)
+ content = re.sub(r"(AssemblyFileVersion\(\")([0-9]+\.[0-9]+\.[0-9]+)", rf"\g<1>{version}", content)
+ with open(file_path, 'w') as f:
+ f.write(content)
+
+ os.system(f"git add {file_path}")
+
+version = os.getenv('APP_VERSION')
+if version == None:
+ raise Exception("Missing env variable APP_VERSION")
+
+configure_git(os.getenv('RELEASE_GIT_EMAIL'), os.getenv('RELEASE_GIT_USERNAME'))
+
+create_release_and_debug_branches(version)
+create_release_branch('9.9.9', f"Build app version 9.9.9 to test {version} installer")
\ No newline at end of file
diff --git a/src/GlobalAssemblyInfo.cs b/src/GlobalAssemblyInfo.cs
index dd464fdcd..011760650 100644
--- a/src/GlobalAssemblyInfo.cs
+++ b/src/GlobalAssemblyInfo.cs
@@ -9,11 +9,11 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProtonVPN")]
-[assembly: AssemblyCopyright("Copyright © 2021 Proton Technologies AG")]
+[assembly: AssemblyCopyright("Copyright © 2021 Proton Technologies AG")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-[assembly: AssemblyVersion("1.24.1.0")]
-[assembly: AssemblyFileVersion("1.24.1.0")]
+[assembly: AssemblyVersion("1.24.2.0")]
+[assembly: AssemblyFileVersion("1.24.2.0")]
[assembly: ComVisible(false)]
[assembly: AssemblyInformationalVersion("$AssemblyVersion")]
\ No newline at end of file
diff --git a/src/ProtonVPN.App/Streaming/StreamingServices.cs b/src/ProtonVPN.App/Streaming/StreamingServices.cs
index 797375b37..0b3e3f8d0 100644
--- a/src/ProtonVPN.App/Streaming/StreamingServices.cs
+++ b/src/ProtonVPN.App/Streaming/StreamingServices.cs
@@ -26,6 +26,7 @@ namespace ProtonVPN.Streaming
{
internal class StreamingServices : IStreamingServices
{
+ private const string COUNTRY_CODE_ANY = "*";
private StreamingServicesResponse _response;
private readonly IAppSettings _appSettings;
@@ -37,18 +38,52 @@ public StreamingServices(StreamingServicesUpdater streamingServicesUpdater, IApp
public IReadOnlyList GetServices(string countryCode, sbyte tier)
{
- if (_response == null ||
- !_response.StreamingServices.ContainsKey(countryCode) ||
- !_response.StreamingServices[countryCode].ContainsKey(tier))
+ if (_response == null)
{
return new List();
}
- IReadOnlyList services = _response.StreamingServices[countryCode][tier];
+ Dictionary streamingServicesByName = new();
+ if (IsStreamingServicesResponseContainingCountryCodeAndTier(countryCode, tier))
+ {
+ UpsertStreamingServicesToDictionary(streamingServicesByName, _response.StreamingServices[countryCode][tier]);
+ }
+ if (IsStreamingServicesResponseContainingCountryCodeAndTier(COUNTRY_CODE_ANY, tier))
+ {
+ UpsertStreamingServicesToDictionary(streamingServicesByName, _response.StreamingServices[COUNTRY_CODE_ANY][tier]);
+ }
+
+ return streamingServicesByName.Values.OrderBy(s => s.Name).ToList();
+ }
+
+ private bool IsStreamingServicesResponseContainingCountryCodeAndTier(string countryCode, sbyte tier)
+ {
+ return countryCode != null &&
+ _response.StreamingServices.ContainsKey(countryCode) &&
+ _response.StreamingServices[countryCode].ContainsKey(tier);
+ }
- return services.Select(s => new StreamingService(s.Name, GetIconUrl(s.Icon)))
- .OrderBy(s => s.Name)
- .ToList();
+ private void UpsertStreamingServicesToDictionary(Dictionary streamingServicesByName,
+ IList streamingServiceResponses)
+ {
+ foreach (StreamingServiceResponse streamingServiceResponse in streamingServiceResponses)
+ {
+ UpsertStreamingServiceToDictionary(streamingServicesByName, streamingServiceResponse);
+ }
+ }
+
+ private void UpsertStreamingServiceToDictionary(Dictionary streamingServicesByName,
+ StreamingServiceResponse streamingServiceResponse)
+ {
+ StreamingService streamingService = MapStreamingService(streamingServiceResponse);
+ streamingServicesByName[streamingService.Name] = streamingService;
+ }
+
+ private StreamingService MapStreamingService(StreamingServiceResponse streamingServicesResponse)
+ {
+ return new StreamingService(
+ name: streamingServicesResponse.Name,
+ iconUrl: GetIconUrl(streamingServicesResponse.Icon));
}
private string GetIconUrl(string icon)
diff --git a/src/ProtonVPN.Common/Configuration/Source/DefaultConfig.cs b/src/ProtonVPN.Common/Configuration/Source/DefaultConfig.cs
index 0aab269ae..bf2948560 100644
--- a/src/ProtonVPN.Common/Configuration/Source/DefaultConfig.cs
+++ b/src/ProtonVPN.Common/Configuration/Source/DefaultConfig.cs
@@ -144,7 +144,7 @@ public Config Value()
ServerLoadUpdateInterval = TimeSpan.FromMinutes(15),
- P2PCheckInterval = TimeSpan.FromSeconds(30),
+ P2PCheckInterval = TimeSpan.FromSeconds(60),
VpnInfoCheckInterval = TimeSpan.FromMinutes(3),
diff --git a/src/ProtonVPN.LocalAgent b/src/ProtonVPN.LocalAgent
index efb859692..bac6105c7 160000
--- a/src/ProtonVPN.LocalAgent
+++ b/src/ProtonVPN.LocalAgent
@@ -1 +1 @@
-Subproject commit efb859692dbc6d070f6b0ed336dc45f5e8841cbf
+Subproject commit bac6105c7c75699d06aa4e375fc0874a721588ed
diff --git a/src/ProtonVPN.Resources/Properties/Strings.Designer.cs b/src/ProtonVPN.Resources/Properties/Strings.Designer.cs
index c9f28da21..a0f69df74 100644
--- a/src/ProtonVPN.Resources/Properties/Strings.Designer.cs
+++ b/src/ProtonVPN.Resources/Properties/Strings.Designer.cs
@@ -132,6 +132,15 @@ internal static string Language_fr {
}
}
+ ///
+ /// Looks up a localized string similar to Hrvatski.
+ ///
+ internal static string Language_hr {
+ get {
+ return ResourceManager.GetString("Language_hr", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Magyar.
///
@@ -142,7 +151,7 @@ internal static string Language_hu {
}
///
- /// Looks up a localized string similar to Bahasa Indonesia.
+ /// Looks up a localized string similar to Bahasa, Indonesia.
///
internal static string Language_id {
get {
diff --git a/src/ProtonVPN.Resources/Properties/Strings.resx b/src/ProtonVPN.Resources/Properties/Strings.resx
index aa357e06b..29551890c 100644
--- a/src/ProtonVPN.Resources/Properties/Strings.resx
+++ b/src/ProtonVPN.Resources/Properties/Strings.resx
@@ -141,11 +141,14 @@
Français
+
+ Hrvatski
+
Magyar
- Bahasa Indonesia
+ Bahasa, Indonesia
Italiano
diff --git a/src/ProtonVPN.Vpn/Connection/LocalAgentWrapper.cs b/src/ProtonVPN.Vpn/Connection/LocalAgentWrapper.cs
index d856b2aee..38707a713 100644
--- a/src/ProtonVPN.Vpn/Connection/LocalAgentWrapper.cs
+++ b/src/ProtonVPN.Vpn/Connection/LocalAgentWrapper.cs
@@ -106,6 +106,7 @@ public void SetFeatures(VpnFeatures vpnFeatures)
public void UpdateAuthCertificate(string certificate)
{
_clientCertPem = certificate;
+ _logger.Info("[LocalAgentWrapper] Client certificate updated. Closing existing TLS channel and reconnecting.");
_eventReceiver.Stop();
CloseTlsChannel();
ConnectToTlsChannel();
diff --git a/src/ProtonVPN.Vpn/ProtonVPN.Vpn.csproj b/src/ProtonVPN.Vpn/ProtonVPN.Vpn.csproj
index 05f660713..88ce36ea4 100644
--- a/src/ProtonVPN.Vpn/ProtonVPN.Vpn.csproj
+++ b/src/ProtonVPN.Vpn/ProtonVPN.Vpn.csproj
@@ -158,6 +158,7 @@
PreserveNewest
+
PreserveNewest
@@ -174,6 +175,7 @@
PreserveNewest
+
@@ -182,6 +184,8 @@
- call "$(ProjectDir)build-local-agent.bat"
+ call "$(ProjectDir)build-local-agent.bat"
+copy $(ProjectDir)Resources\64-bit\tunnel.dll $(ProjectDir)$(OutDir)
+copy $(ProjectDir)Resources\64-bit\wireguard.dll $(ProjectDir)$(OutDir)
\ No newline at end of file
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/libcrypto-1_1.dll b/src/ProtonVPN.Vpn/Resources/32-bit/libcrypto-1_1.dll
index d784b1637..e2b5fa68f 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/libcrypto-1_1.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/libcrypto-1_1.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/liblzo2-2.dll b/src/ProtonVPN.Vpn/Resources/32-bit/liblzo2-2.dll
index 4c9b528bb..07f4e3261 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/liblzo2-2.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/liblzo2-2.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/libpkcs11-helper-1.dll b/src/ProtonVPN.Vpn/Resources/32-bit/libpkcs11-helper-1.dll
index 54dd794f5..f3bae1a45 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/libpkcs11-helper-1.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/libpkcs11-helper-1.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/libssl-1_1.dll b/src/ProtonVPN.Vpn/Resources/32-bit/libssl-1_1.dll
index 23833dab4..d205d52d6 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/libssl-1_1.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/libssl-1_1.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/openvpn.exe b/src/ProtonVPN.Vpn/Resources/32-bit/openvpn.exe
index e09030112..cafaf99fb 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/openvpn.exe and b/src/ProtonVPN.Vpn/Resources/32-bit/openvpn.exe differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll b/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll
index 9dfbe494d..cf20a719a 100644
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll.bak b/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll.bak
deleted file mode 100644
index 954f5c700..000000000
Binary files a/src/ProtonVPN.Vpn/Resources/32-bit/tunnel.dll.bak and /dev/null differ
diff --git a/Setup/wireguard-nt/x86/wireguard.dll b/src/ProtonVPN.Vpn/Resources/32-bit/wireguard.dll
similarity index 84%
rename from Setup/wireguard-nt/x86/wireguard.dll
rename to src/ProtonVPN.Vpn/Resources/32-bit/wireguard.dll
index b07df3f37..ecca024ff 100644
Binary files a/Setup/wireguard-nt/x86/wireguard.dll and b/src/ProtonVPN.Vpn/Resources/32-bit/wireguard.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/libcrypto-1_1-x64.dll b/src/ProtonVPN.Vpn/Resources/64-bit/libcrypto-1_1-x64.dll
index 89ecb378a..c55b618b4 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/libcrypto-1_1-x64.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/libcrypto-1_1-x64.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/liblzo2-2.dll b/src/ProtonVPN.Vpn/Resources/64-bit/liblzo2-2.dll
index 662eab8ec..a57c34af2 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/liblzo2-2.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/liblzo2-2.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/libpkcs11-helper-1.dll b/src/ProtonVPN.Vpn/Resources/64-bit/libpkcs11-helper-1.dll
index 2987473a1..608444d9a 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/libpkcs11-helper-1.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/libpkcs11-helper-1.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/libssl-1_1-x64.dll b/src/ProtonVPN.Vpn/Resources/64-bit/libssl-1_1-x64.dll
index 87acd1d17..d634dd69f 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/libssl-1_1-x64.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/libssl-1_1-x64.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/openvpn.exe b/src/ProtonVPN.Vpn/Resources/64-bit/openvpn.exe
index 49e317076..6037f70ed 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/openvpn.exe and b/src/ProtonVPN.Vpn/Resources/64-bit/openvpn.exe differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll b/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll
index 53a0a25d3..8ca81172e 100644
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll differ
diff --git a/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll.bak b/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll.bak
deleted file mode 100644
index dee657a14..000000000
Binary files a/src/ProtonVPN.Vpn/Resources/64-bit/tunnel.dll.bak and /dev/null differ
diff --git a/Setup/wireguard-nt/amd64/wireguard.dll b/src/ProtonVPN.Vpn/Resources/64-bit/wireguard.dll
similarity index 79%
rename from Setup/wireguard-nt/amd64/wireguard.dll
rename to src/ProtonVPN.Vpn/Resources/64-bit/wireguard.dll
index a4b95dc88..efc03626f 100644
Binary files a/Setup/wireguard-nt/amd64/wireguard.dll and b/src/ProtonVPN.Vpn/Resources/64-bit/wireguard.dll differ
diff --git a/src/ProtonVPN.Vpn/Wireguard/WireguardConnection.cs b/src/ProtonVPN.Vpn/Wireguard/WireguardConnection.cs
index 0ea3c8446..d9cd1d02d 100644
--- a/src/ProtonVPN.Vpn/Wireguard/WireguardConnection.cs
+++ b/src/ProtonVPN.Vpn/Wireguard/WireguardConnection.cs
@@ -21,6 +21,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using System.Timers;
using ProtonVPN.Common;
using ProtonVPN.Common.Extensions;
using ProtonVPN.Common.Logging;
@@ -30,6 +31,7 @@
using ProtonVPN.Common.Vpn;
using ProtonVPN.Crypto;
using ProtonVPN.Vpn.Common;
+using Timer = System.Timers.Timer;
namespace ProtonVPN.Vpn.WireGuard
{
@@ -39,6 +41,7 @@ internal class WireGuardConnection : ISingleVpnConnection
private readonly ILogger _logger;
private readonly ProtonVPN.Common.Configuration.Config _config;
+ private readonly Timer _serviceHealthCheckTimer = new();
private readonly IService _wireGuardService;
private readonly TrafficManager _trafficManager;
private readonly StatusManager _statusManager;
@@ -50,7 +53,7 @@ internal class WireGuardConnection : ISingleVpnConnection
private VpnCredentials _credentials;
private VpnEndpoint _endpoint;
private VpnConfig _vpnConfig;
- private bool _connected;
+ private bool _isConnected;
private bool _isServiceStopPending;
public WireGuardConnection(
@@ -73,6 +76,8 @@ public WireGuardConnection(
_connectAction.Completed += OnConnectActionCompleted;
_disconnectAction = new SingleAction(DisconnectAction);
_disconnectAction.Completed += OnDisconnectActionCompleted;
+ _serviceHealthCheckTimer.Interval = config.ServiceCheckInterval.TotalMilliseconds;
+ _serviceHealthCheckTimer.Elapsed += CheckIfServiceIsRunning;
}
public event EventHandler> StateChanged;
@@ -102,7 +107,7 @@ private async Task ConnectAction(CancellationToken cancellationToken)
_statusManager.Start();
await StartWireGuardService(cancellationToken);
await Task.Delay(CONNECT_TIMEOUT, cancellationToken);
- if (!_connected)
+ if (!_isConnected)
{
_logger.Info("[WireGuardConnection] timeout reached, disconnecting.");
Disconnect(VpnError.TimeoutError);
@@ -139,9 +144,10 @@ private async Task DisconnectAction(CancellationToken cancellationToken)
await _connectAction.Task;
}
+ _serviceHealthCheckTimer.Stop();
StopServiceDependencies();
await EnsureServiceIsStopped(cancellationToken);
- _connected = false;
+ _isConnected = false;
}
private void OnConnectActionCompleted(object sender, TaskCompletedEventArgs e)
@@ -191,20 +197,34 @@ private async Task EnsureServiceIsStopped(CancellationToken cancellationToken)
private void OnStateChanged(object sender, EventArgs state)
{
- if (_connected && state.Data.Status == VpnStatus.Connected)
+ switch (state.Data.Status)
{
- return;
+ case VpnStatus.Connected:
+ OnVpnConnected(state);
+ break;
+ case VpnStatus.Disconnected:
+ OnVpnDisconnected(state);
+ break;
}
+ }
- _connected = state.Data.Status == VpnStatus.Connected;
- _trafficManager.Start();
-
- if (state.Data.Status == VpnStatus.Disconnected)
+ private void OnVpnConnected(EventArgs state)
+ {
+ if (!_isConnected)
{
- StopServiceDependencies();
+ _isConnected = true;
+ _trafficManager.Start();
+ _serviceHealthCheckTimer.Start();
+ InvokeStateChange(VpnStatus.Connected, state.Data.Error);
}
+ }
- InvokeStateChange(state.Data.Status, state.Data.Error);
+ private void OnVpnDisconnected(EventArgs state)
+ {
+ _isConnected = false;
+ _serviceHealthCheckTimer.Stop();
+ StopServiceDependencies();
+ InvokeStateChange(VpnStatus.Disconnected, state.Data.Error);
}
private void StopServiceDependencies()
@@ -252,13 +272,26 @@ private void InvokeStateChange(VpnStatus status, VpnError error = VpnError.None)
{
StateChanged?.Invoke(this,
new EventArgs(
- new VpnState(status, error, _config.WireGuard.DefaultClientAddress, _endpoint?.Server.Ip ?? string.Empty,
+ new VpnState(status, error, _config.WireGuard.DefaultClientAddress,
+ _endpoint?.Server.Ip ?? string.Empty,
VpnProtocol.WireGuard, null, _endpoint?.Server.Label ?? string.Empty)));
}
private string GetDnsServers()
{
- return _vpnConfig.CustomDns.Count > 0 ? string.Join(",", _vpnConfig.CustomDns) : _config.WireGuard.DefaultDnsServer;
+ return _vpnConfig.CustomDns.Count > 0
+ ? string.Join(",", _vpnConfig.CustomDns)
+ : _config.WireGuard.DefaultDnsServer;
+ }
+
+ private void CheckIfServiceIsRunning(object sender, ElapsedEventArgs e)
+ {
+ if (_isConnected && !_wireGuardService.Running() && !_disconnectAction.IsRunning)
+ {
+ _logger.Info($"[WireGuardConnection] The service {_wireGuardService.Name} is not running. " +
+ "Disconnecting with VpnError.Unknown to get reconnected.");
+ Disconnect(VpnError.Unknown);
+ }
}
}
}
\ No newline at end of file
diff --git a/src/ProtonVPN.Vpn/Wireguard/WireguardService.cs b/src/ProtonVPN.Vpn/Wireguard/WireguardService.cs
index 05fb4634f..f1e0b7362 100644
--- a/src/ProtonVPN.Vpn/Wireguard/WireguardService.cs
+++ b/src/ProtonVPN.Vpn/Wireguard/WireguardService.cs
@@ -64,6 +64,11 @@ public Task StartAsync(CancellationToken cancellationToken)
unrestricted: true);
}
+ if (!_origin.Enabled())
+ {
+ _origin.Enable();
+ }
+
return _origin.StartAsync(cancellationToken);
}
diff --git a/test/ProtonVPN.Vpn.Test/WireGuard/WireGuardConnectionTest.cs b/test/ProtonVPN.Vpn.Test/WireGuard/WireGuardConnectionTest.cs
index 755d16b0c..c152f59fa 100644
--- a/test/ProtonVPN.Vpn.Test/WireGuard/WireGuardConnectionTest.cs
+++ b/test/ProtonVPN.Vpn.Test/WireGuard/WireGuardConnectionTest.cs
@@ -17,6 +17,7 @@
* along with ProtonVPN. If not, see .
*/
+using System;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
@@ -64,6 +65,7 @@ public void ConnectShouldFireErrorEventWhenServerPublicKeyIsNullOrEmpty()
private WireGuardConnection GetWireGuardConnection()
{
ProtonVPN.Common.Configuration.Config config = new();
+ config.ServiceCheckInterval = TimeSpan.FromMilliseconds(1000);
ILogger logger = Substitute.For();
IX25519KeyGenerator xIx25519KeyGenerator = Substitute.For();
WireGuardService wireGuardService =