Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindaugas Veblauskas committed Dec 12, 2022
2 parents b62859a + e90073f commit 5d4e97e
Show file tree
Hide file tree
Showing 140 changed files with 2,109 additions and 567 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ dotnet_naming_rule.members_are_pascal_case.style=member_style
# Constant Fields Should Be PascalCase
dotnet_naming_rule.constant_fields_should_be_upper_case.severity=warning
dotnet_naming_rule.constant_fields_should_be_upper_case.symbols=constant_fields
dotnet_naming_rule.constant_fields_should_be_upper_case.style=pascal_case_style
dotnet_naming_rule.constant_fields_should_be_upper_case.style=upper_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds=field
dotnet_naming_symbols.constant_fields.required_modifiers=const
dotnet_naming_style.pascal_case_style.capitalization=pascal_case
Expand Down
2 changes: 2 additions & 0 deletions src/Api/ProtonVPN.Api.Contracts/IApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using ProtonVPN.Api.Contracts.Common;
using ProtonVPN.Api.Contracts.Events;
using ProtonVPN.Api.Contracts.Geographical;
using ProtonVPN.Api.Contracts.Partners;
using ProtonVPN.Api.Contracts.Profiles;
using ProtonVPN.Api.Contracts.ReportAnIssue;
using ProtonVPN.Api.Contracts.Servers;
Expand Down Expand Up @@ -55,6 +56,7 @@ public interface IApiClient : IClientBase
Task<ApiResponseResult<VpnConfig.VpnConfigResponse>> GetVpnConfig();
Task<ApiResponseResult<AnnouncementsResponse>> GetAnnouncementsAsync(AnnouncementsRequest request);
Task<ApiResponseResult<StreamingServicesResponse>> GetStreamingServicesAsync();
Task<ApiResponseResult<PartnersResponse>> GetPartnersAsync();
Task<ApiResponseResult<BaseResponse>> CheckAuthenticationServerStatusAsync();
Task<ApiResponseResult<CertificateResponse>> RequestAuthCertificateAsync(CertificateRequest request);
Task<ApiResponseResult<BaseResponse>> ApplyPromoCodeAsync(PromoCodeRequest promoCodeRequest);
Expand Down
39 changes: 39 additions & 0 deletions src/Api/ProtonVPN.Api.Contracts/Partners/PartnerResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 Proton Technologies 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.Collections.Generic;
using Newtonsoft.Json;

namespace ProtonVPN.Api.Contracts.Partners
{
public class PartnerResponse
{
public string Name { get; set; }

public string Description { get; set; }

[JsonProperty("WebsiteURL")]
public string WebsiteUrl { get; set; }

[JsonProperty("IconURL")]
public string IconUrl { get; set; }

public List<string> LogicalIDs { get; set; }
}
}
36 changes: 36 additions & 0 deletions src/Api/ProtonVPN.Api.Contracts/Partners/PartnerTypeResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2022 Proton Technologies 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.Collections.Generic;
using Newtonsoft.Json;

namespace ProtonVPN.Api.Contracts.Partners
{
public class PartnerTypeResponse
{
public string Type { get; set; }

public string Description { get; set; }

[JsonProperty("IconURL")]
public string IconUrl { get; set; }

public List<PartnerResponse> Partners { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/Api/ProtonVPN.Api.Contracts/Partners/PartnersResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2022 Proton Technologies 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.Collections.Generic;
using ProtonVPN.Api.Contracts.Common;

namespace ProtonVPN.Api.Contracts.Partners
{
public class PartnersResponse : BaseResponse
{
public List<PartnerTypeResponse> PartnerTypes { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<Compile Include="ExpandedHttpStatusCodes.cs" />
<Compile Include="IApiHostProvider.cs" />
<Compile Include="IFileDownloadHttpClientFactory.cs" />
<Compile Include="Partners\PartnerResponse.cs" />
<Compile Include="Partners\PartnersResponse.cs" />
<Compile Include="Partners\PartnerTypeResponse.cs" />
<Compile Include="Profiles\BaseProfileResponse.cs" />
<Compile Include="Common\BaseResponse.cs" />
<Compile Include="Common\BaseResponseDetail.cs" />
Expand Down
9 changes: 8 additions & 1 deletion src/Api/ProtonVPN.Api/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using ProtonVPN.Api.Contracts.Common;
using ProtonVPN.Api.Contracts.Events;
using ProtonVPN.Api.Contracts.Geographical;
using ProtonVPN.Api.Contracts.Partners;
using ProtonVPN.Api.Contracts.Profiles;
using ProtonVPN.Api.Contracts.ReportAnIssue;
using ProtonVPN.Api.Contracts.Servers;
Expand Down Expand Up @@ -105,7 +106,7 @@ public async Task<ApiResponseResult<EventResponse>> GetEventResponse(string last
public async Task<ApiResponseResult<ServersResponse>> GetServersAsync(string ip)
{
HttpRequestMessage request = GetAuthorizedRequest(HttpMethod.Get,
"vpn/logicals?SignServer=Server.EntryIP,Server.Label", ip);
"vpn/logicals?SignServer=Server.EntryIP,Server.Label&WithPartnerLogicals=1", ip);
request.SetRetryCount(SERVERS_RETRY_COUNT);
request.SetCustomTimeout(TimeSpan.FromSeconds(SERVERS_TIMEOUT_IN_SECONDS));
return await SendRequest<ServersResponse>(request, "Get servers");
Expand Down Expand Up @@ -215,6 +216,12 @@ public async Task<ApiResponseResult<StreamingServicesResponse>> GetStreamingServ
return await SendRequest<StreamingServicesResponse>(request, "Get streaming services");
}

public async Task<ApiResponseResult<PartnersResponse>> GetPartnersAsync()
{
HttpRequestMessage request = GetAuthorizedRequest(HttpMethod.Get, "vpn/v1/partners");
return await SendRequest<PartnersResponse>(request, "Get partners");
}

public async Task<ApiResponseResult<BaseResponse>> CheckAuthenticationServerStatusAsync()
{
HttpRequestMessage request = GetRequest(HttpMethod.Get, "domains/available?Type=login");
Expand Down
4 changes: 2 additions & 2 deletions src/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("2.2.1.0")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: AssemblyVersion("2.3.1.0")]
[assembly: AssemblyFileVersion("2.3.1.0")]
[assembly: ComVisible(false)]
[assembly: AssemblyInformationalVersion("$AssemblyVersion")]
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace ProtonVPN.HumanVerification.Gui
{
public class WebViewViewModel : ViewModelBase, IWebViewViewModel
{
private readonly IConfiguration _config;
private readonly ILogger _logger;
private readonly ICaptchaUrlProvider _captchaUrlProvider;

Expand All @@ -55,7 +54,6 @@ public int Height

public WebViewViewModel(IConfiguration config, ILogger logger, ICaptchaUrlProvider captchaUrlProvider)
{
_config = config;
_logger = logger;
_captchaUrlProvider = captchaUrlProvider;

Expand Down
16 changes: 1 addition & 15 deletions src/ProtonVPN.App/ConnectionInfo/ConnectionInfoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,18 @@ public int LoadNumber


public bool Maintenance { get; }
public object Ip { get; }
public bool SecureCore { get; }
public bool PlusServer { get; }
public bool P2PServer { get; }
public bool TorServer { get; }

private bool _showTooltip;
public bool ShowTooltip
{
get => _showTooltip;
set => Set(ref _showTooltip, value);
}

public ConnectionInfoViewModel(Server server)
{
Ensure.NotNull(server, nameof(server));

LoadNumber = server.Load;
Load = $"{server.Load}%";
Maintenance = server.Status == 0;
Ip = new Ip {Address = server.ExitIp};
PlusServer = server.Tier.Equals(ServerTiers.Plus);
P2PServer = server.SupportsP2P();
TorServer = server.SupportsTor();
Expand All @@ -87,11 +78,6 @@ public ConnectionInfoViewModel(Server server)
ExitCountry = Countries.GetName(server.ExitCountry)
};
}

if (server.IsSecureCore() || server.IsFree())
{
Ip = new AutoAssignedIp();
}
}
}
}
}
25 changes: 18 additions & 7 deletions src/ProtonVPN.App/Core/Bootstraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
using ProtonVPN.Notifications;
using ProtonVPN.Onboarding;
using ProtonVPN.P2PDetection;
using ProtonVPN.Partners;
using ProtonVPN.PlanDowngrading;
using ProtonVPN.QuickLaunch;
using ProtonVPN.Settings;
Expand Down Expand Up @@ -168,7 +169,7 @@ protected override async void OnStartup(object sender, StartupEventArgs e)
return;
}

await Resolve<UserAuth>().InvokeAutoLoginEventAsync();
await Resolve<IUserAuthenticator>().InvokeAutoLoginEventAsync();
}

public void OnExit()
Expand All @@ -187,7 +188,7 @@ private async Task<bool> SessionExpired()

try
{
ApiResponseResult<VpnInfoWrapperResponse> result = await Resolve<UserAuth>().RefreshVpnInfoAsync();
ApiResponseResult<VpnInfoWrapperResponse> result = await Resolve<IUserAuthenticator>().RefreshVpnInfoAsync();
return result.Failure;
}
catch
Expand Down Expand Up @@ -258,7 +259,7 @@ private void ShowInitialWindow()
private void RegisterEvents()
{
IVpnServiceManager vpnServiceManager = Resolve<IVpnServiceManager>();
UserAuth userAuth = Resolve<UserAuth>();
IUserAuthenticator userAuthenticator = Resolve<IUserAuthenticator>();
AppWindow appWindow = Resolve<AppWindow>();
IAppSettings appSettings = Resolve<IAppSettings>();
_notificationUserActionHandler = Resolve<INotificationUserActionHandler>();
Expand Down Expand Up @@ -291,14 +292,15 @@ private void RegisterEvents()
}
};

userAuth.UserLoggingIn += (sender, e) => OnUserLoggingIn();
userAuthenticator.UserLoggingIn += (sender, e) => OnUserLoggingIn();

userAuth.UserLoggedIn += async (sender, e) =>
userAuthenticator.UserLoggedIn += async (sender, e) =>
{
await Resolve<IUserLocationService>().Update();
await Resolve<IServerUpdater>().Update();
await Resolve<IClientConfig>().Update();
await Resolve<StreamingServicesUpdater>().Update();
await Resolve<IPartnersUpdater>().Update();
GuestHoleState guestHoleState = Resolve<GuestHoleState>();
if (guestHoleState.Active)
Expand All @@ -316,7 +318,7 @@ private void RegisterEvents()
await SwitchToAppWindow(e.IsAutoLogin);
};

userAuth.UserLoggedOut += (sender, e) =>
userAuthenticator.UserLoggedOut += (sender, e) =>
{
Resolve<IModals>().CloseAll();
Expand Down Expand Up @@ -393,6 +395,15 @@ private void RegisterEvents()
}
});

vpnServiceManager.RegisterConnectionDetailsChangeCallback(ipAddressInfo =>
{
IEnumerable<IConnectionDetailsAware> instances = Resolve<IEnumerable<IConnectionDetailsAware>>();
foreach (IConnectionDetailsAware instance in instances)
{
instance.OnConnectionDetailsChanged(ipAddressInfo);
}
});

Resolve<IVpnManager>().VpnStateChanged += (sender, e) =>
{
IEnumerable<IVpnStateAware> instances = Resolve<IEnumerable<IVpnStateAware>>();
Expand Down Expand Up @@ -505,7 +516,7 @@ private void CheckAuthenticationServerStatus()

private async Task SwitchToAppWindow(bool autoLogin)
{
if (!Resolve<UserAuth>().LoggedIn)
if (!Resolve<IUserAuthenticator>().IsLoggedIn)
{
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/ProtonVPN.App/Core/ExpiredSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ internal class ExpiredSessionHandler : IVpnStateAware
private readonly IScheduler _scheduler;
private readonly IVpnServiceManager _vpnServiceManager;
private readonly LoginViewModel _loginViewModel;
private readonly UserAuth _userAuth;
private readonly IUserAuthenticator _userAuthenticator;

public ExpiredSessionHandler(
IScheduler scheduler,
IVpnServiceManager vpnServiceManager,
LoginViewModel loginViewModel,
UserAuth userAuth)
IUserAuthenticator userAuthenticator)
{
_userAuth = userAuth;
_userAuthenticator = userAuthenticator;
_loginViewModel = loginViewModel;
_vpnServiceManager = vpnServiceManager;
_scheduler = scheduler;
Expand All @@ -56,7 +56,7 @@ await _scheduler.Schedule(async () =>
}
_loginViewModel.OnSessionExpired();
await _userAuth.LogoutAsync();
await _userAuthenticator.LogoutAsync();
});
}

Expand Down
Loading

0 comments on commit 5d4e97e

Please sign in to comment.