Skip to content

Commit 5fc8111

Browse files
Merge branch 'release/1.20.4'
2 parents fb40c4c + 5171e81 commit 5fc8111

File tree

14 files changed

+77
-86
lines changed

14 files changed

+77
-86
lines changed

Setup/ProtonVPN.aip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
<ROW Property="Manufacturer" Value="Proton Technologies AG"/>
2626
<ROW Property="MsiLogging" MultiBuildValue="DefaultBuild:vp"/>
2727
<ROW Property="PENDING_REBOOT" Value="0"/>
28-
<ROW Property="ProductCode" Value="1031:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1033:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1036:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1040:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1043:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1045:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1046:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1049:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 1065:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 2070:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} 3082:{F9E5055B-A5F1-4E15-821C-EE35DD62A676} " Type="16"/>
28+
<ROW Property="ProductCode" Value="1031:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1033:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1036:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1040:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1043:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1045:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1046:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1049:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 1065:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 2070:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} 3082:{31E6E510-4199-4F1A-94EB-C4A242DCFFFA} " Type="16"/>
2929
<ROW Property="ProductLanguage" Value="1033"/>
3030
<ROW Property="ProductName" Value="ProtonVPN"/>
31-
<ROW Property="ProductVersion" Value="1.20.3" Type="32"/>
31+
<ROW Property="ProductVersion" Value="1.20.4" Type="32"/>
3232
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
3333
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND;AI_SETUPEXEPATH;SETUPEXEDIR"/>
3434
<ROW Property="SelectedLanguage" Value="This will be set by custom action"/>
@@ -74,7 +74,7 @@
7474
</COMPONENT>
7575
<COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent">
7676
<ROW Component="A7C0318B44EF690B391D753065B05" ComponentId="{8DFC0212-F989-444F-81FB-9D221A745FE8}" Directory_="APPDIR" Attributes="0" Options="2"/>
77-
<ROW Component="AI_CustomARPName" ComponentId="{F9B406DA-18A1-412C-889B-24995C55CDD6}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/>
77+
<ROW Component="AI_CustomARPName" ComponentId="{A3A945A6-2C69-4094-B833-738010BA0264}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/>
7878
<ROW Component="AI_ExePath" ComponentId="{47427A21-60A2-43B4-A150-6CBA74CF4A07}" Directory_="APPDIR" Attributes="4" KeyPath="AI_ExePath"/>
7979
<ROW Component="APPDIR" ComponentId="{75DDD993-CDFE-4D39-8C1A-07484ADD1A4E}" Directory_="APPDIR" Attributes="0"/>
8080
<ROW Component="ARSoft.Tools.Net.dll" ComponentId="{05CE9A73-14A8-494D-B2D3-8438A2A16DDB}" Directory_="APPDIR" Attributes="0" KeyPath="ARSoft.Tools.Net.dll"/>

src/GlobalAssemblyInfo.cs

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

16-
[assembly: AssemblyVersion("1.20.3.0")]
17-
[assembly: AssemblyFileVersion("1.20.3.0")]
16+
[assembly: AssemblyVersion("1.20.4.0")]
17+
[assembly: AssemblyFileVersion("1.20.4.0")]
1818
[assembly: ComVisible(false)]
1919
[assembly: AssemblyInformationalVersion("$AssemblyVersion")]

src/ProtonVPN.App/Core/Service/Vpn/VpnManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void OnVpnStateChanged(VpnStateChangedEventArgs e)
141141

142142
if (!string.IsNullOrEmpty(state.EntryIp))
143143
{
144-
_lastServer = _lastServerCandidates.ServerByEntryIp(state.EntryIp);
144+
_lastServer = _lastServerCandidates.ServerByEntryIpAndLabel(state.EntryIp, e.State.Label);
145145
}
146146

147147
_state = new VpnState(state.Status, _lastServer);

src/ProtonVPN.App/Core/Service/Vpn/VpnServiceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static VpnStateChangedEventArgs Map(VpnStateContract contract)
144144
VpnError error = Map(contract.Error);
145145
VpnProtocol protocol = Map(contract.Protocol);
146146

147-
return new VpnStateChangedEventArgs(status, error, contract.EndpointIp, contract.NetworkBlocked, protocol);
147+
return new VpnStateChangedEventArgs(status, error, contract.EndpointIp, contract.NetworkBlocked, protocol, contract.Label);
148148
}
149149

150150
private static InOutBytes Map(InOutBytesContract bytes)
Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Proton Technologies AG
2+
* Copyright (c) 2021 Proton Technologies AG
33
*
44
* This file is part of ProtonVPN.
55
*
@@ -18,61 +18,48 @@
1818
*/
1919

2020
using System.Collections.Generic;
21-
using System.Linq;
2221
using ProtonVPN.Core.Servers.Models;
2322
using ProtonVPN.Core.Servers.Specs;
24-
using ProtonVPN.Core.Settings;
2523

2624
namespace ProtonVPN.Core.Servers
2725
{
2826
public class ServerCandidates
2927
{
3028
private readonly ServerManager _serverManager;
31-
private readonly IUserStorage _userStorage;
3229

33-
public ServerCandidates(ServerManager serverManager, IUserStorage userStorage, IReadOnlyCollection<Server> items)
30+
public ServerCandidates(ServerManager serverManager, IReadOnlyCollection<Server> items)
3431
{
3532
_serverManager = serverManager;
36-
_userStorage = userStorage;
3733
Items = items;
3834
}
3935

4036
public IReadOnlyCollection<Server> Items { get; }
4137

42-
public Server ServerByEntryIp(string ip)
38+
public Server ServerByEntryIpAndLabel(string entryIp, string label)
4339
{
44-
if (string.IsNullOrEmpty(ip))
40+
if (string.IsNullOrEmpty(entryIp))
41+
{
4542
return Server.Empty();
43+
}
4644

47-
var maxTier = _userStorage.User().MaxTier;
48-
var servers = Items.Where(l => l.Servers.Any(p => p.EntryIp == ip));
49-
var server = FirstByUserTier(servers, maxTier);
50-
if (server != null)
51-
return WithExitIp(server, ip);
52-
53-
servers = _serverManager.GetServers(new ServerByEntryIp(ip));
54-
server = FirstByUserTier(servers, maxTier);
55-
return WithExitIp(server ?? Server.Empty(), ip);
56-
}
57-
58-
private Server FirstByUserTier(IEnumerable<Server> servers, sbyte maxTier)
59-
{
60-
return servers
61-
.OrderByDescending(s => s.Tier <= maxTier ? s.Tier : -1)
62-
.FirstOrDefault();
63-
}
64-
65-
private Server WithExitIp(Server server, string entryIp)
66-
{
67-
var result = server.Clone();
45+
IReadOnlyCollection<Server> servers = Items == null || Items.Count == 0
46+
? _serverManager.GetServers(new ServerByEntryIp(entryIp))
47+
: Items;
6848

69-
var physical = server.Servers.FirstOrDefault(p => p.EntryIp == entryIp);
70-
if (physical != null)
49+
foreach (Server server in servers)
7150
{
72-
result.ExitIp = physical.ExitIp;
51+
foreach (PhysicalServer physicalServer in server.Servers)
52+
{
53+
if (entryIp == physicalServer.EntryIp && (string.IsNullOrEmpty(label) || label == physicalServer.Label))
54+
{
55+
Server clone = server.Clone();
56+
clone.ExitIp = physicalServer.ExitIp;
57+
return clone;
58+
}
59+
}
7360
}
7461

75-
return result;
62+
return Server.Empty();
7663
}
7764
}
78-
}
65+
}

src/ProtonVPN.Core/Servers/ServerCandidatesFactory.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Proton Technologies AG
2+
* Copyright (c) 2021 Proton Technologies AG
33
*
44
* This file is part of ProtonVPN.
55
*
@@ -19,24 +19,21 @@
1919

2020
using System.Collections.Generic;
2121
using ProtonVPN.Core.Servers.Models;
22-
using ProtonVPN.Core.Settings;
2322

2423
namespace ProtonVPN.Core.Servers
2524
{
2625
public class ServerCandidatesFactory
2726
{
2827
private readonly ServerManager _serverManager;
29-
private readonly IUserStorage _userStorage;
3028

31-
public ServerCandidatesFactory(ServerManager serverManager, IUserStorage userStorage)
29+
public ServerCandidatesFactory(ServerManager serverManager)
3230
{
3331
_serverManager = serverManager;
34-
_userStorage = userStorage;
3532
}
3633

3734
public ServerCandidates ServerCandidates(IReadOnlyCollection<Server> servers)
3835
{
39-
return new ServerCandidates(_serverManager, _userStorage, servers);
36+
return new(_serverManager, servers);
4037
}
4138
}
42-
}
39+
}

src/ProtonVPN.Core/Vpn/VpnState.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ public class VpnState
2828
public string EntryIp { get; }
2929
public Server Server { get; }
3030
public VpnProtocol Protocol { get; }
31+
public string Label { get; }
3132

32-
public VpnState(VpnStatus status, string entryIp, VpnProtocol protocol)
33+
public VpnState(VpnStatus status, string entryIp, VpnProtocol protocol, string label = "")
3334
{
3435
Status = status;
3536
EntryIp = entryIp;
3637
Protocol = protocol;
38+
Label = label;
3739
}
3840

3941
public VpnState(VpnStatus status, Server server = null)

src/ProtonVPN.Core/Vpn/VpnStateChangedEventArgs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class VpnStateChangedEventArgs
3030
public bool NetworkBlocked { get; }
3131
public VpnProtocol Protocol { get; }
3232

33-
public VpnStateChangedEventArgs(VpnStatus status, VpnError error, string endpointIp, bool networkBlocked, VpnProtocol protocol)
34-
: this(new VpnState(status, endpointIp, protocol), error, networkBlocked, protocol)
33+
public VpnStateChangedEventArgs(VpnStatus status, VpnError error, string endpointIp, bool networkBlocked, VpnProtocol protocol, string label = "")
34+
: this(new VpnState(status, endpointIp, protocol, label), error, networkBlocked, protocol)
3535
{
3636
}
3737

src/ProtonVPN.Service.Contract/Vpn/VpnStateContract.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,27 @@ public VpnStateContract(
2929
VpnErrorTypeContract error,
3030
string endpointIp,
3131
bool networkBlocked,
32-
VpnProtocolContract protocol)
32+
VpnProtocolContract protocol,
33+
string label)
3334
{
3435
Status = status;
3536
Error = error;
3637
EndpointIp = endpointIp;
3738
NetworkBlocked = networkBlocked;
3839
Protocol = protocol;
40+
Label = label;
3941
}
4042

41-
[DataMember]
42-
public VpnStatusContract Status { get; private set; }
43+
[DataMember] public VpnStatusContract Status { get; private set; }
4344

44-
[DataMember]
45-
public VpnErrorTypeContract Error { get; private set; }
45+
[DataMember] public VpnErrorTypeContract Error { get; private set; }
4646

47-
[DataMember]
48-
public bool NetworkBlocked { get; private set; }
47+
[DataMember] public bool NetworkBlocked { get; private set; }
4948

50-
[DataMember]
51-
public string EndpointIp { get; private set; }
49+
[DataMember] public string EndpointIp { get; private set; }
5250

53-
[DataMember]
54-
public VpnProtocolContract Protocol { get; private set; }
51+
[DataMember] public VpnProtocolContract Protocol { get; private set; }
52+
53+
[DataMember] public string Label { get; private set; }
5554
}
56-
}
55+
}

src/ProtonVPN.Service/VpnConnectionHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ private VpnStateContract Map(VpnState state)
231231
Map(state.Error),
232232
state.RemoteIp,
233233
killSwitchEnabled,
234-
Map(state.Protocol));
234+
Map(state.Protocol),
235+
state.Label);
235236
}
236237

237238
private static VpnStatusContract Map(VpnStatus vpnStatus)

0 commit comments

Comments
 (0)