Skip to content

Commit 0137c33

Browse files
author
Mindaugas Veblauskas
committed
Merge branch 'release/3.3.2'
2 parents 3afe246 + 48cd9e7 commit 0137c33

File tree

39 files changed

+165
-442
lines changed

39 files changed

+165
-442
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,6 @@ artifactlift-release-artifacts:
298298
rules:
299299
- when: never
300300

301-
artifactlift-release-metadata:
302-
rules:
303-
- when: never
304-
305301
release-binary-to-nexus:
306302
extends: artifactlift-release-candidate-artifacts
307303
rules:
@@ -313,18 +309,6 @@ release-binary-to-nexus:
313309

314310
release-binary-to-prod:
315311
extends: artifactlift-release-artifacts
316-
rules:
317-
- if: '$CI_COMMIT_BRANCH == "release/9.9.9"'
318-
when: never
319-
- if: '$CI_COMMIT_BRANCH =~ /^release\/\d+\.\d+\.\d+/'
320-
when: manual
321-
- when: never
322-
323-
release-json-to-prod:
324-
extends: artifactlift-release-metadata
325-
needs:
326-
- job: release-binary-to-prod
327-
artifacts: true
328312
rules:
329313
- if: '$CI_COMMIT_BRANCH == "release/9.9.9"'
330314
when: never

ci/build-scripts/guest_hole_server_loader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ def load():
3737
if server['EntryIP'] in unique_entries:
3838
continue
3939

40-
server_json_object = "".join(['{"host":"', server['Domain'], '","ip":"', server['EntryIP'], '","signature":"', server['Signature'], '","label":"', server['Label'], '"}'])
40+
server_json_object = "".join([
41+
'{"host":"', server['Domain'],
42+
'","ip":"', server['EntryIP'],
43+
'","signature":"', server['Signature'],
44+
'","label":"', server['Label'],
45+
'","publicKey":"', server['X25519PublicKey'], '"}'])
4146
servers_str = ",".join([servers_str, server_json_object])
4247
unique_entries.append(server['EntryIP'])
4348

src/Api/ProtonVPN.Api.Contracts/IApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public interface IApiClient : IClientBase
5151
Task<ApiResponseResult<UserLocationResponse>> GetLocationDataAsync();
5252
Task<ApiResponseResult<BaseResponse>> ReportBugAsync(IEnumerable<KeyValuePair<string, string>> fields, IEnumerable<File> files);
5353
Task<ApiResponseResult<SessionsResponse>> GetSessions();
54-
Task<ApiResponseResult<VpnConfigResponse>> GetVpnConfig();
54+
Task<ApiResponseResult<VpnConfigResponse>> GetVpnConfig(string country, string ip);
5555
Task<ApiResponseResult<AnnouncementsResponse>> GetAnnouncementsAsync(AnnouncementsRequest request);
5656
Task<ApiResponseResult<StreamingServicesResponse>> GetStreamingServicesAsync();
5757
Task<ApiResponseResult<BaseResponse>> CheckAuthenticationServerStatusAsync();

src/Api/ProtonVPN.Api/ApiClient.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using ProtonVPN.Api.Contracts.VpnConfig;
3636
using ProtonVPN.Api.Contracts.VpnSessions;
3737
using ProtonVPN.Common.Configuration;
38+
using ProtonVPN.Common.Extensions;
3839
using ProtonVPN.Common.OS.Net.Http;
3940
using ProtonVPN.Common.StatisticalEvents;
4041
using ProtonVPN.Core.Settings;
@@ -162,9 +163,13 @@ public async Task<ApiResponseResult<SessionsResponse>> GetSessions()
162163
return await SendRequest<SessionsResponse>(request, "Get sessions");
163164
}
164165

165-
public async Task<ApiResponseResult<VpnConfigResponse>> GetVpnConfig()
166+
public async Task<ApiResponseResult<VpnConfigResponse>> GetVpnConfig(string country, string ip)
166167
{
167-
HttpRequestMessage request = GetAuthorizedRequest(HttpMethod.Get, "vpn/v2/clientconfig");
168+
HttpRequestMessage request = GetAuthorizedRequest(HttpMethod.Get, "vpn/v2/clientconfig", ip);
169+
if (!country.IsNullOrEmpty())
170+
{
171+
request.Headers.Add("x-pm-country", country);
172+
}
168173
return await SendRequest<VpnConfigResponse>(request, "Get VPN config");
169174
}
170175

src/GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

17-
[assembly: AssemblyVersion("3.3.0.0")]
18-
[assembly: AssemblyFileVersion("3.3.0.0")]
17+
[assembly: AssemblyVersion("3.3.2.0")]
18+
[assembly: AssemblyFileVersion("3.3.2.0")]
1919
[assembly: ComVisible(false)]
2020
[assembly: AssemblyInformationalVersion("$AssemblyVersion")]
2121
[assembly: SupportedOSPlatform("windows")]

src/ProcessCommunication/ProtonVPN.ProcessCommunication.EntityMapping.Tests/Vpn/ConnectionRequestMapperTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using ProtonVPN.Common.Networking;
2323
using ProtonVPN.Common.Vpn;
2424
using ProtonVPN.Core.Vpn;
25+
using ProtonVPN.Crypto;
2526
using ProtonVPN.EntityMapping.Contracts;
2627
using ProtonVPN.ProcessCommunication.Contracts.Entities.Vpn;
2728
using ProtonVPN.ProcessCommunication.EntityMapping.Vpn;
@@ -115,7 +116,8 @@ public void TestMapLeftToRight()
115116
new List<VpnHost>(),
116117
VpnProtocol.OpenVpnUdp,
117118
new VpnConfig(new VpnConfigParameters()),
118-
new VpnCredentials(DateTime.UtcNow.Ticks.ToString(), DateTime.UtcNow.Millisecond.ToString()));
119+
new VpnCredentials(string.Empty, new AsymmetricKeyPair(
120+
new SecretKey("PVPN", KeyAlgorithm.Unknown), new PublicKey("PVPN", KeyAlgorithm.Unknown))));
119121

120122
ConnectionRequestIpcEntity result = _mapper.Map(entityToTest);
121123

src/ProcessCommunication/ProtonVPN.ProcessCommunication.EntityMapping.Tests/Vpn/VpnCredentialsMapperTest.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ public void Cleanup()
6363
_expectedAsymmetricKeyPair = null;
6464
}
6565

66-
[TestMethod]
67-
public void TestMapLeftToRight_WithUsernameAndPassword()
68-
{
69-
VpnCredentials entityToTest = new(DateTime.UtcNow.Ticks.ToString(), DateTime.UtcNow.Millisecond.ToString());
70-
71-
VpnCredentialsIpcEntity result = _mapper.Map(entityToTest);
72-
73-
Assert.IsNotNull(result);
74-
Assert.AreEqual(entityToTest.Username, result.Username);
75-
Assert.AreEqual(entityToTest.Password, result.Password);
76-
Assert.IsNull(result.ClientCertPem);
77-
}
78-
7966
[TestMethod]
8067
public void TestMapLeftToRight_WithCertificate()
8168
{
@@ -85,8 +72,6 @@ public void TestMapLeftToRight_WithCertificate()
8572
VpnCredentialsIpcEntity result = _mapper.Map(entityToTest);
8673

8774
Assert.IsNotNull(result);
88-
Assert.IsNull(result.Username);
89-
Assert.IsNull(result.Password);
9075
Assert.AreEqual(entityToTest.ClientCertPem, result.ClientCertPem);
9176
Assert.AreEqual(_expectedAsymmetricKeyPairIpcEntity, result.ClientKeyPair);
9277
}
@@ -100,23 +85,6 @@ public void TestMapRightToLeft_ThrowsWhenNull()
10085
_mapper.Map(entityToTest);
10186
}
10287

103-
[TestMethod]
104-
public void TestMapRightToLeft_WithUsernameAndPassword()
105-
{
106-
VpnCredentialsIpcEntity entityToTest = new()
107-
{
108-
Username = DateTime.UtcNow.Ticks.ToString(),
109-
Password = DateTime.UtcNow.Millisecond.ToString()
110-
};
111-
112-
VpnCredentials result = _mapper.Map(entityToTest);
113-
114-
Assert.IsNotNull(result);
115-
Assert.AreEqual(entityToTest.Username, result.Username);
116-
Assert.AreEqual(entityToTest.Password, result.Password);
117-
Assert.IsNull(result.ClientCertPem);
118-
}
119-
12088
[TestMethod]
12189
public void TestMapRightToLeft_WithCertificate()
12290
{
@@ -129,8 +97,6 @@ public void TestMapRightToLeft_WithCertificate()
12997
VpnCredentials result = _mapper.Map(entityToTest);
13098

13199
Assert.IsNotNull(result);
132-
Assert.IsNull(result.Username);
133-
Assert.IsNull(result.Password);
134100
Assert.AreEqual(entityToTest.ClientCertPem, result.ClientCertPem);
135101
Assert.AreEqual(_expectedAsymmetricKeyPair, result.ClientKeyPair);
136102
}

src/ProcessCommunication/ProtonVPN.ProcessCommunication.EntityMapping/Vpn/VpnCredentialsMapper.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* along with ProtonVPN. If not, see <https://www.gnu.org/licenses/>.
1818
*/
1919

20-
using ProtonVPN.Common.Extensions;
2120
using ProtonVPN.Common.Vpn;
2221
using ProtonVPN.Crypto;
2322
using ProtonVPN.EntityMapping.Contracts;
@@ -39,8 +38,6 @@ public VpnCredentialsIpcEntity Map(VpnCredentials leftEntity)
3938
{
4039
return new()
4140
{
42-
Username = leftEntity.Username,
43-
Password = leftEntity.Password,
4441
ClientCertPem = leftEntity.ClientCertPem,
4542
ClientKeyPair = _entityMapper.Map<AsymmetricKeyPair, AsymmetricKeyPairIpcEntity>(leftEntity.ClientKeyPair)
4643
};
@@ -50,9 +47,7 @@ public VpnCredentials Map(VpnCredentialsIpcEntity rightEntity)
5047
{
5148
return rightEntity is null
5249
? throw new ArgumentNullException($"The {nameof(VpnCredentialsIpcEntity)} to be mapped is null.")
53-
: rightEntity.ClientCertPem.IsNullOrEmpty() || rightEntity.ClientKeyPair == null
54-
? new(rightEntity.Username, rightEntity.Password)
55-
: new(rightEntity.ClientCertPem, _entityMapper.Map<AsymmetricKeyPairIpcEntity, AsymmetricKeyPair>(rightEntity.ClientKeyPair));
50+
: new(rightEntity.ClientCertPem, _entityMapper.Map<AsymmetricKeyPairIpcEntity, AsymmetricKeyPair>(rightEntity.ClientKeyPair));
5651
}
5752
}
5853
}

src/ProtonVPN.App/Core/Ioc/AppModule.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ protected override void Load(ContainerBuilder builder)
115115
.AsSelf()
116116
.SingleInstance();
117117
builder.RegisterType<UserStorage>().As<IUserStorage>().SingleInstance();
118-
builder.RegisterType<TruncatedLocation>().SingleInstance();
119118

120119
builder.RegisterType<PinFactory>()
121120
.AsImplementedInterfaces()

src/ProtonVPN.App/Core/UserLocationService.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace ProtonVPN.Core
3535
{
36-
internal class UserLocationService : IVpnStateAware, IUserLocationService, IConnectionDetailsAware
36+
public class UserLocationService : IVpnStateAware, IUserLocationService, IConnectionDetailsAware
3737
{
3838
private static readonly TimeSpan UpdateLocationDelay = TimeSpan.FromSeconds(6);
3939

@@ -70,6 +70,29 @@ public Task Update()
7070
return _updateAction.Run();
7171
}
7272

73+
public async Task<string> GetTruncatedIpAddressAsync()
74+
{
75+
string ip = _userStorage.GetLocation().Ip;
76+
if (ip.IsNullOrEmpty())
77+
{
78+
await Update();
79+
}
80+
81+
ip = _userStorage.GetLocation().Ip;
82+
if (string.IsNullOrEmpty(ip))
83+
{
84+
return string.Empty;
85+
}
86+
87+
string[] parts = ip.Split('.');
88+
if (parts.Length >= 3)
89+
{
90+
return string.Join(".", parts[0], parts[1], parts[2], 0);
91+
}
92+
93+
return string.Empty;
94+
}
95+
7396
public async Task OnVpnStateChanged(VpnStateChangedEventArgs e)
7497
{
7598
VpnStatus status = e.State.Status;

0 commit comments

Comments
 (0)