Skip to content

Commit

Permalink
Merge branch 'release/3.2.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindaugas Veblauskas committed Jan 4, 2024
2 parents 0b72876 + 9813bd7 commit a8792d8
Show file tree
Hide file tree
Showing 39 changed files with 7,145 additions and 227 deletions.
8 changes: 6 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ build-release:

build-bti:
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_BRANCH =~ /^release.*$/'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $BTI_SCHEDULED == "true"
when: always
- when: manual
extends:
Expand Down Expand Up @@ -107,7 +111,7 @@ bti-test:
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $BTI_SCHEDULED == "true"
when: always
- when: manual
tags:
Expand Down
2 changes: 2 additions & 0 deletions Setup/Strings/Norwegian.isl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[CustomMessages]
InstallProtonDriveTitle=Installer Proton Drive - kryptert skylagring (gratis med Proton VPN)
3 changes: 3 additions & 0 deletions Setup/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Source: "..\{#SourcePath}\zh-TW\ProtonVPN.Translations.resources.dll"; DestDir:
Source: "..\{#SourcePath}\sv-SE\ProtonVPN.Translations.resources.dll"; DestDir: "{app}\{#VersionFolder}\sv-SE"; Flags: signonce;
Source: "..\{#SourcePath}\ja-JP\ProtonVPN.Translations.resources.dll"; DestDir: "{app}\{#VersionFolder}\ja-JP"; Flags: signonce;
Source: "..\{#SourcePath}\sk-SK\ProtonVPN.Translations.resources.dll"; DestDir: "{app}\{#VersionFolder}\sk-SK"; Flags: signonce;
Source: "..\{#SourcePath}\nn-NO\ProtonVPN.Translations.resources.dll"; DestDir: "{app}\{#VersionFolder}\nn-NO"; Flags: signonce;
Source: "..\{#SourcePath}\nb-NO\ProtonVPN.Translations.resources.dll"; DestDir: "{app}\{#VersionFolder}\nb-NO"; Flags: signonce;

Source: "..\{#SourcePath}\Resources\*.dll"; DestDir: "{app}\{#VersionFolder}\Resources"; Flags: signonce;
Source: "..\{#SourcePath}\Resources\*.exe"; DestDir: "{app}\{#VersionFolder}\Resources"; Flags: signonce;
Expand Down Expand Up @@ -147,6 +149,7 @@ Name: "fi_FI"; MessagesFile: "compiler:Languages\Finnish.isl,Strings\Finnish.isl
Name: "fr_FR"; MessagesFile: "compiler:Languages\French.isl,Strings\French.isl"
Name: "nl_NL"; MessagesFile: "compiler:Languages\Dutch.isl,Strings\Dutch.isl"
Name: "it_IT"; MessagesFile: "compiler:Languages\Italian.isl,Strings\Italian.isl"
Name: "nb_NO"; MessagesFile: "compiler:Languages\Norwegian.isl,Strings\Norwegian.isl"
Name: "pl_PL"; MessagesFile: "compiler:Languages\Polish.isl,Strings\Polish.isl"
Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl,Strings\BrazilianPortuguese.isl"
Name: "pt_PT"; MessagesFile: "compiler:Languages\Portuguese.isl,Strings\Portuguese.isl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
*/

namespace ProtonVPN.UI.Tests.TestsHelper.BTI
using System;

namespace ProtonVPN.Api.Contracts
{
public class ApiMocks
public interface IOutdatedAppNotifier
{
public const string CERTIFICATE_ERROR_503 = @"POST /vpn/v1/certificate:
- body:
Error: Test scenario
status: 503";
event EventHandler AppOutdated;

void TriggerOutdatedAppEvent();
}
}
}
1 change: 1 addition & 0 deletions src/Api/ProtonVPN.Api.Installers/ApiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override void Load(ContainerBuilder builder)
builder.RegisterType<CertificateValidator>().As<ICertificateValidator>().SingleInstance();
builder.RegisterType<FileDownloadHttpClientFactory>().AsImplementedInterfaces().SingleInstance();
builder.RegisterType<UpdateHttpClientFactory>().AsImplementedInterfaces().SingleInstance();
builder.RegisterType<OutdatedAppNotifier>().AsImplementedInterfaces().SingleInstance();
builder.Register(c =>
new CachingReportClient(
new ReportClient(c.Resolve<IReportClientUriProvider>())))
Expand Down
15 changes: 7 additions & 8 deletions src/Api/ProtonVPN.Api.Tests/Handlers/OutdatedAppHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;
using ProtonVPN.Api.Contracts;
using ProtonVPN.Api.Contracts.Common;
using ProtonVPN.Api.Handlers;
Expand All @@ -36,26 +36,25 @@ public class OutdatedAppHandlerTest
[TestMethod]
[DataRow(ResponseCodes.OutdatedAppResponse)]
[DataRow(ResponseCodes.OutdatedApiResponse)]
public async Task ItShouldInvokeOutdatedAppEvent(int code)
public async Task ItShouldInvokeOutdatedAppEventAsync(int code)
{
// Arrange
int called = 0;

MockOfRetryingHandler mockOfRetryingHandler = new();
IOutdatedAppNotifier outdatedAppNotifier = Substitute.For<IOutdatedAppNotifier>();

MockOfBaseResponseMessageDeserializer mockOfBaseResponseDeserializer = new()
{
ExpectedBaseResponse = new BaseResponse() { Code = code }
ExpectedBaseResponse = new BaseResponse { Code = code }
};
mockOfRetryingHandler.SetResponseAsSuccess(code);
OutdatedAppHandler handler = new(mockOfBaseResponseDeserializer) { InnerHandler = mockOfRetryingHandler };
handler.AppOutdated += (sender, args) => called++;
OutdatedAppHandler handler = new(mockOfBaseResponseDeserializer, outdatedAppNotifier) { InnerHandler = mockOfRetryingHandler };
HttpClient httpClient = new(handler) {BaseAddress = new Uri("http://127.0.0.1")};

// Act
await httpClient.SendAsync(new HttpRequestMessage());

// Assert
called.Should().Be(1);
outdatedAppNotifier.Received(1).TriggerOutdatedAppEvent();
}
}
}
8 changes: 4 additions & 4 deletions src/Api/ProtonVPN.Api/Handlers/OutdatedAppHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -33,11 +32,12 @@ namespace ProtonVPN.Api.Handlers
public class OutdatedAppHandler : DelegatingHandler
{
private readonly IBaseResponseMessageDeserializer _baseResponseDeserializer;
public event EventHandler<BaseResponse> AppOutdated;
private readonly IOutdatedAppNotifier _outdatedAppNotifier;

public OutdatedAppHandler(IBaseResponseMessageDeserializer baseResponseDeserializer)
public OutdatedAppHandler(IBaseResponseMessageDeserializer baseResponseDeserializer, IOutdatedAppNotifier outdatedAppNotifier)
{
_baseResponseDeserializer = baseResponseDeserializer;
_outdatedAppNotifier = outdatedAppNotifier;
}

protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
Expand All @@ -52,7 +52,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage

if (ForceLogoutRequired(baseResponse.Code))
{
AppOutdated?.Invoke(this, baseResponse);
_outdatedAppNotifier.TriggerOutdatedAppEvent();
}

return response;
Expand Down
34 changes: 34 additions & 0 deletions src/Api/ProtonVPN.Api/OutdatedAppNotifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2023 Proton AG
*
* This file is part of ProtonVPN.
*
* ProtonVPN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProtonVPN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using ProtonVPN.Api.Contracts;

namespace ProtonVPN.Api
{
public class OutdatedAppNotifier : IOutdatedAppNotifier
{
public event EventHandler AppOutdated;

public void TriggerOutdatedAppEvent()
{
AppOutdated?.Invoke(this, EventArgs.Empty);
}
}
}
4 changes: 2 additions & 2 deletions src/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("3.2.8.0")]
[assembly: AssemblyFileVersion("3.2.8.0")]
[assembly: AssemblyVersion("3.2.9.0")]
[assembly: AssemblyFileVersion("3.2.9.0")]
[assembly: ComVisible(false)]
[assembly: AssemblyInformationalVersion("$AssemblyVersion")]
[assembly: SupportedOSPlatform("windows")]
2 changes: 1 addition & 1 deletion src/ProtonVPN.App/Core/Bootstraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private void RegisterEvents()
Resolve<ExpiredSessionHandler>().Execute();
};

Resolve<OutdatedAppHandler>().AppOutdated += Resolve<OutdatedAppNotification>().OnAppOutdated;
Resolve<OutdatedAppNotification>();
Resolve<IModals>();
Resolve<InsecureNetworkNotification>();
Resolve<ActionableFailureApiResultEventHandler>();
Expand Down
3 changes: 2 additions & 1 deletion src/ProtonVPN.App/Core/Ioc/AppModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ protected override void Load(ContainerBuilder builder)
c.Resolve<ILogger>(),
new SystemService(
c.Resolve<IConfiguration>().ServiceName, // REMOVE THIS CUSTOM REGISTRATION
c.Resolve<IOsProcesses>())))),
c.Resolve<IOsProcesses>())),
c.Resolve<ILogger>())),
c.Resolve<ILogger>(),
c.Resolve<IServiceEnabler>()))
.SingleInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void RegisterNetShieldStatisticChangeCallback(Action<NetShieldStatistic>

private async Task InvokeAction(Func<Task<Result>> action)
{
if (!_baseFilteringEngineService.Running())
if (_baseFilteringEngineService.Exists() && !_baseFilteringEngineService.Running())
{
await _modals.ShowAsync<BfeWarningModalViewModel>();
return;
Expand Down
26 changes: 15 additions & 11 deletions src/ProtonVPN.App/Notifications/OutdatedAppNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using System.Threading.Tasks;
using ProtonVPN.Api.Contracts.Common;
using ProtonVPN.Api.Contracts;
using ProtonVPN.Common.Threading;
using ProtonVPN.Common.Vpn;
using ProtonVPN.Core.Auth;
Expand Down Expand Up @@ -46,16 +47,26 @@ public OutdatedAppNotification(
IUserAuthenticator userAuthenticator,
LoginWindow loginWindow,
IScheduler scheduler,
IVpnServiceManager vpnServiceManager)
IVpnServiceManager vpnServiceManager,
IOutdatedAppNotifier outdatedAppNotifier)
{
_modals = modals;
_userAuthenticator = userAuthenticator;
_loginWindow = loginWindow;
_scheduler = scheduler;
_vpnServiceManager = vpnServiceManager;

outdatedAppNotifier.AppOutdated += OnAppOutdatedAsync;
}

public Task OnVpnStateChanged(VpnStateChangedEventArgs e)
{
_vpnStatus = e.State.Status;

return Task.CompletedTask;
}

public async void OnAppOutdated(object sender, BaseResponse e)
private async void OnAppOutdatedAsync(object sender, EventArgs e)
{
if (_notified)
{
Expand All @@ -75,12 +86,5 @@ await _scheduler.Schedule(async () =>
await _modals.ShowAsync<OutdatedAppModalViewModel>();
});
}

public Task OnVpnStateChanged(VpnStateChangedEventArgs e)
{
_vpnStatus = e.State.Status;

return Task.CompletedTask;
}
}
}
}
28 changes: 19 additions & 9 deletions src/ProtonVPN.Common/OS/Services/SafeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,20 @@
using System.Threading;
using System.Threading.Tasks;
using ProtonVPN.Common.Abstract;
using ProtonVPN.Logging.Contracts;
using ProtonVPN.Logging.Contracts.Events.AppServiceLogs;

namespace ProtonVPN.Common.OS.Services
{
public class SafeService : IService
{
private readonly IService _origin;
private readonly ILogger _logger;

public SafeService(IService origin)
public SafeService(IService origin, ILogger logger)
{
_origin = origin;
_logger = logger;
}

public string Name => _origin.Name;
Expand All @@ -42,8 +46,9 @@ public bool Exists()
{
return _origin.Exists();
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to check whether the service {Name} exists.", e);
return false;
}
}
Expand All @@ -54,8 +59,9 @@ public void Create(string pathAndArgs, bool unrestricted)
{
_origin.Create(pathAndArgs, unrestricted);
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to create {Name} service.", e);
}
}

Expand All @@ -65,8 +71,9 @@ public void UpdatePathAndArgs(string cmd)
{
_origin.UpdatePathAndArgs(cmd);
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to update path and args for {Name} service.", e);
}
}

Expand All @@ -76,8 +83,9 @@ public bool Running()
{
return _origin.Running();
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to check whether the service {Name} is running.", e);
return false;
}
}
Expand All @@ -88,8 +96,9 @@ public bool IsStopped()
{
return _origin.IsStopped();
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to check whether the service {Name} is stopped.", e);
return false;
}
}
Expand All @@ -100,8 +109,9 @@ public bool Enabled()
{
return _origin.Enabled();
}
catch (Win32Exception)
catch (Win32Exception e)
{
_logger.Error<AppServiceLog>($"Failed to check whether the service {Name} is enabled.", e);
return false;
}
}
Expand All @@ -112,9 +122,9 @@ public void Enable()
{
_origin.Enable();
}
catch (Exception)
catch (Exception e)
{
// ignored
_logger.Error<AppServiceLog>($"Failed to enable {Name} service.", e);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/ProtonVPN.Resources/Properties/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,10 @@
<data name="Language_sk-SK" xml:space="preserve">
<value>Slovenčina</value>
</data>
<data name="Language_nn-NO" xml:space="preserve">
<value>Norsk</value>
</data>
<data name="Language_nb-NO" xml:space="preserve">
<value>Norsk bokmål</value>
</data>
</root>
Loading

0 comments on commit a8792d8

Please sign in to comment.