Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Feb 16, 2024
2 parents 0e17fc7 + a909f82 commit f5a8831
Show file tree
Hide file tree
Showing 132 changed files with 1,279 additions and 846 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# v3.3.470
### Client
* Feature: Update UI when the server does not support UDP tunnel
* Fix: Crash when pressing "Disconnect" while connecting
* Fix: Remove "No data has been received" message before connection is established
* Update: Protocol Changed: Server sends UdpPort instead of UdpEndPoints

### Server
* Fix: Crash when pressing "Disconnect" while connecting
* Update: Protocol Changed: Server sends UdpPort instead of UdpEndPoints
* Feature: Support HTTP-01 DNS challenge to auto-verify domains

# v3.3.463
### Client
* Fix: The "Connect" button for free public server does not work under certain circumstances
* Fix: The "Connect" button for free public servers does not work under certain circumstances

# v3.3.462
### Client
Expand Down
2 changes: 1 addition & 1 deletion Pub/Android.GooglePlay/_publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $json = @{
GooglePlayUrl = "https://play.google.com/store/apps/details?id=com.vpnhood.client.android";
ReleaseDate = "$releaseDate";
DeprecatedVersion = "$deprecatedVersion";
NotificationDelay = "14.00:00:00";
NotificationDelay = "7.00:00:00";
};
$json | ConvertTo-Json | Out-File "$module_infoFile" -Encoding ASCII;

Expand Down
4 changes: 2 additions & 2 deletions Pub/PubVersion.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Version": "3.3.463",
"BumpTime": "2024-02-07T22:49:13.5670292Z",
"Version": "3.3.470",
"BumpTime": "2024-02-16T20:19:54.5087389Z",
"Prerelease": false,
"DeprecatedVersion": "3.0.416"
}
3 changes: 1 addition & 2 deletions Samples/VpnHood.Samples.SimpleClient.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using VpnHood.Client.Device.Droid;
using VpnHood.Client.Device.Droid;
using VpnHood.Client.Device.Droid.Utils;
using VpnHood.Common;

Expand Down
6 changes: 3 additions & 3 deletions Tests/VpnHood.Test/TestAccessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public TestAccessManager(IAccessManager baseAccessManager)
_httpAccessManager = new HttpAccessManager(new HttpAccessManagerOptions(EmbedIoAccessManager.BaseUri, "Bearer"))
{
Logger = VhLogger.Instance,
LoggerEventId = GeneralEventId.AccessManager,
LoggerEventId = GeneralEventId.AccessManager
};
}

Expand Down Expand Up @@ -63,12 +63,12 @@ public Task<SessionResponseEx> Session_Create(SessionRequestEx sessionRequestEx)
return _httpAccessManager.Session_Create(sessionRequestEx);
}

public Task<SessionResponseBase> Session_AddUsage(ulong sessionId, Traffic traffic)
public Task<SessionResponse> Session_AddUsage(ulong sessionId, Traffic traffic)
{
return _httpAccessManager.Session_AddUsage(sessionId, traffic);
}

public Task<SessionResponseBase> Session_Close(ulong sessionId, Traffic traffic)
public Task<SessionResponse> Session_Close(ulong sessionId, Traffic traffic)
{
return _httpAccessManager.Session_Close(sessionId, traffic);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/VpnHood.Test/TestEmbedIoAccessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task<SessionResponseEx> Session_Create([QueryField] Guid serverId)
}

[Route(HttpVerbs.Post, "/sessions/{sessionId}/usage")]
public async Task<SessionResponseBase> Session_AddUsage([QueryField] Guid serverId, ulong sessionId, [QueryField] bool closeSession)
public async Task<SessionResponse> Session_AddUsage([QueryField] Guid serverId, ulong sessionId, [QueryField] bool closeSession)
{
_ = serverId;
var traffic = await GetRequestDataAsync<Traffic>();
Expand Down
21 changes: 12 additions & 9 deletions Tests/VpnHood.Test/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static FileAccessManagerOptions CreateFileAccessManagerOptions()
SyncCacheSize = 50,
SyncInterval = TimeSpan.FromMilliseconds(100)
},
LogAnonymizer = false,
LogAnonymizer = false
};
return options;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ private static VpnHoodServer CreateServer(IAccessManager? accessManager, FileAcc
AutoDisposeAccessManager = autoDisposeAccessManager,
StoragePath = WorkingPath,
NetFilter = NetFilter,
PublicIpDiscovery = false, //it slows down our tests
PublicIpDiscovery = false //it slows down our tests
};

// Create server
Expand Down Expand Up @@ -367,7 +367,7 @@ public static AppOptions CreateClientAppOptions()
{
AppDataFolderPath = Path.Combine(WorkingPath, "AppData_" + Guid.NewGuid()),
SessionTimeout = TimeSpan.FromSeconds(2),
LoadCountryIpGroups = false,
LoadCountryIpGroups = false
};
return appOptions;
}
Expand All @@ -392,12 +392,15 @@ public static VpnHoodApp CreateClientApp(TestDeviceOptions? deviceOptions = defa
public static SessionRequestEx CreateSessionRequestEx(Token token, Guid? clientId = null)
{
clientId ??= Guid.NewGuid();

return new SessionRequestEx("access:" + Guid.NewGuid(),
token.TokenId,
new ClientInfo { ClientId = clientId.Value },
hostEndPoint: token.ServerToken.HostEndPoints!.First(),
encryptedClientId: VhUtil.EncryptClientId(clientId.Value, token.Secret));
return new SessionRequestEx
{
TokenId = token.TokenId,
ClientInfo = new ClientInfo { ClientId = clientId.Value },
HostEndPoint = token.ServerToken.HostEndPoints!.First(),
EncryptedClientId = VhUtil.EncryptClientId(clientId.Value, token.Secret),
ClientIp = null,
ExtraData = null
};
}

private static bool _isInit;
Expand Down
2 changes: 1 addition & 1 deletion Tests/VpnHood.Test/TestNetFilter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Concurrent;
using PacketDotNet;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PacketDotNet;
using VpnHood.Server;
using VpnHood.Tunneling;

Expand Down
3 changes: 2 additions & 1 deletion Tests/VpnHood.Test/TestSocketProtector.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net.Sockets;
using PacketDotNet;
using VpnHood.Tunneling;
using ProtocolType = PacketDotNet.ProtocolType;

namespace VpnHood.Test;

Expand All @@ -16,7 +17,7 @@ public static void ProtectSocket(Socket socket)

public static bool IsProtectedPacket(IPPacket ipPacket)
{
if (ipPacket.Protocol == PacketDotNet.ProtocolType.Tcp)
if (ipPacket.Protocol == ProtocolType.Tcp)
{
lock (TcpProtected)
{
Expand Down
16 changes: 3 additions & 13 deletions Tests/VpnHood.Test/Tests/AccessTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VpnHood.Client;
using VpnHood.Common.Exceptions;
using VpnHood.Common.Logging;
using VpnHood.Common.Messaging;
using VpnHood.Common.Utils;
Expand Down Expand Up @@ -61,19 +62,8 @@ public async Task Server_reject_expired_access_hello()

// create client and connect
await using var client1 = TestHelper.CreateClient(token, autoConnect: false);
try
{
await client1.Connect();
Assert.Fail("Exception expected! access has been expired");
}
catch (AssertFailedException)
{
throw;
}
catch
{
Assert.AreEqual(SessionErrorCode.AccessExpired, client1.SessionStatus.ErrorCode);
}
await Assert.ThrowsExceptionAsync<SessionException>(() => client1.Connect());
Assert.AreEqual(SessionErrorCode.AccessExpired, client1.SessionStatus.ErrorCode);
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions Tests/VpnHood.Test/Tests/CheckNewVersionTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Text.Json;
using System.Text.Json;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VpnHood.Client.App;
using VpnHood.Common.Utils;

Expand Down
7 changes: 4 additions & 3 deletions Tests/VpnHood.Test/Tests/ClientAppTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using VpnHood.Common.Logging;
using VpnHood.Common.Net;
using VpnHood.Common.Utils;

// ReSharper disable DisposeOnUsingVariable

namespace VpnHood.Test.Tests;
Expand All @@ -37,7 +38,7 @@ private Token CreateToken()
HostPort = 443,
Secret = randomId.ToByteArray(),
CreatedTime = DateTime.UtcNow,
IsValidHostName = false,
IsValidHostName = false
}
};

Expand Down Expand Up @@ -101,7 +102,7 @@ public async Task Add_remove_clientProfiles()
{
Token = CreateToken(),
ClientProfileName = "Hi",
ClientProfileId = Guid.NewGuid(),
ClientProfileId = Guid.NewGuid()
});
});
Expand Down Expand Up @@ -268,7 +269,7 @@ public async Task IpFilters(bool usePassthru, bool isDnsServerSupported)
new IpRange(TestConstants.PingV4Address1),
new IpRange(TestConstants.NsEndPoint1.Address),
new IpRange(TestConstants.UdpV4EndPoint1.Address),
new IpRange(TestConstants.UdpV6EndPoint1.Address),
new IpRange(TestConstants.UdpV6EndPoint1.Address)
});

// ************
Expand Down
49 changes: 20 additions & 29 deletions Tests/VpnHood.Test/Tests/ClientServerTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using EmbedIO;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VpnHood.Client;
Expand All @@ -11,7 +12,7 @@
using VpnHood.Server;
using VpnHood.Server.Access.Managers.File;
using VpnHood.Tunneling;
using EmbedIO;

// ReSharper disable DisposeOnUsingVariable

namespace VpnHood.Test.Tests;
Expand Down Expand Up @@ -197,7 +198,7 @@ public async Task DatagramChannel_Udp()
// Create Client
await using var client = TestHelper.CreateClient(token, options: new ClientOptions
{
UseUdpChannel = true,
UseUdpChannel = true
});

var tasks = new List<Task>();
Expand Down Expand Up @@ -502,15 +503,7 @@ public async Task Configure_Maintenance_Server()
// ----------
var token = TestHelper.CreateAccessToken(fileAccessManager);
await using var client = TestHelper.CreateClient(token, autoConnect: false);
try
{
await client.Connect();
Assert.Fail("Exception expected!");
}
catch (MaintenanceException)
{
// ignored
}
await Assert.ThrowsExceptionAsync<MaintenanceException>(() => client.Connect());

Assert.AreEqual(SessionErrorCode.Maintenance, client.SessionStatus.ErrorCode);
Assert.AreEqual(ClientState.Disposed, client.State);
Expand All @@ -527,15 +520,7 @@ public async Task Configure_Maintenance_Server()
// ----------
testAccessManager.EmbedIoAccessManager.Stop();
await using var client3 = TestHelper.CreateClient(token, autoConnect: false);
try
{
await client3.Connect();
Assert.Fail("Exception expected!");
}
catch (MaintenanceException)
{
// ignored
}
await Assert.ThrowsExceptionAsync<MaintenanceException>(() => client3.Connect());

await TestHelper.WaitForClientStateAsync(client3, ClientState.Disposed);
Assert.AreEqual(SessionErrorCode.Maintenance, client3.SessionStatus.ErrorCode);
Expand All @@ -552,15 +537,7 @@ public async Task Configure_Maintenance_Server()
// ----------
testAccessManager.EmbedIoAccessManager.HttpException = HttpException.Forbidden();
await using var client5 = TestHelper.CreateClient(token, autoConnect: false);
try
{
await client5.Connect();
Assert.Fail("Exception expected!");
}
catch (MaintenanceException)
{
// ignored
}
await Assert.ThrowsExceptionAsync<MaintenanceException>(() => client5.Connect());

await TestHelper.WaitForClientStateAsync(client5, ClientState.Disposed);
Assert.AreEqual(SessionErrorCode.Maintenance, client5.SessionStatus.ErrorCode);
Expand Down Expand Up @@ -766,4 +743,18 @@ public async Task Reusing_ChunkStream()
// wait for free the used connections
await VhTestUtil.AssertEqualsWait(3, () => client.Stat.ConnectorStat.FreeConnectionCount);
}

[TestMethod]
public async Task IsUdpChannelSupported_must_be_false_when_server_return_udp_port_zero()
{
// Create Server
var fileAccessManagerOptions = TestHelper.CreateFileAccessManagerOptions();
fileAccessManagerOptions.UdpEndPoints = [];
await using var server = TestHelper.CreateServer(options: fileAccessManagerOptions);
var token = TestHelper.CreateAccessToken(server);

// Create Client
await using var client = TestHelper.CreateClient(token, options: TestHelper.CreateClientOptions(useUdp: true));
Assert.IsFalse(client.Stat.IsUdpChannelSupported);
}
}
6 changes: 3 additions & 3 deletions Tests/VpnHood.Test/Tests/IpNetworkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Invert_Unify_Convert()
IpRange.Parse("128.0.0.0 - 192.167.255.255"),
IpRange.Parse("192.169.0.0 - 255.255.255.255"),
IpRange.Parse(":: - 99:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"),
IpRange.Parse("AA::01:0000 - FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"),
IpRange.Parse("AA::01:0000 - FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF")
};

CollectionAssert.AreEqual(expected, inverted.ToArray());
Expand Down Expand Up @@ -109,7 +109,7 @@ public void IpRange_Intersect(bool swap)
IpRange.Parse("190.190.10.0 - 190.190.11.0"), //ignore
IpRange.Parse("30.30.10.50 - 30.30.10.100"),
IpRange.Parse("20.20.10.50 - 20.20.10.55"),
IpRange.Parse("20.20.10.60 - 20.20.10.100"),
IpRange.Parse("20.20.10.60 - 20.20.10.100")
};

var ipRanges2 = new[]
Expand All @@ -118,7 +118,7 @@ public void IpRange_Intersect(bool swap)
IpRange.Parse("192.168.10.0 - 192.168.255.255"),
IpRange.Parse("190.190.11.1 - 190.190.11.50"), //ignore
IpRange.Parse("30.30.10.70 - 30.30.10.110"),
IpRange.Parse("20.20.10.0 - 20.20.10.90"),
IpRange.Parse("20.20.10.0 - 20.20.10.90")
};

// Expected
Expand Down
4 changes: 2 additions & 2 deletions Tests/VpnHood.Test/Tests/NetScanTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using VpnHood.Common.Utils;
using VpnHood.Server;

Expand Down
Loading

0 comments on commit f5a8831

Please sign in to comment.