Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed May 29, 2024
2 parents fa008ad + 7a16249 commit 6094e0e
Show file tree
Hide file tree
Showing 123 changed files with 2,219 additions and 1,867 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# v4.5.520
### Client
* Feature: Allow to select servers by country if the server supports it
* Feature: Auto pause and resume when the server is not reachable
* Update: User IncludeIpRanges and ExcludeIpRanges in settings instead of CustomIpRanges
* Update: Try to fix accesskey when it is not valid by missing the padding characters
* Update: Countries IP ranges
* Fix: Some wrong message in disconnect

### Server
* Improve: Optimize server reconfiguration at runtime
* Feature: Support selecting server location when controlled by HttpAccessManager
* Feature: Enable hot restart for FileAccessManager
* Deprecate: ServerProtocol Version 2 (451) is deprecated and no longer supported

# v4.4.506
### Client
* Update: Android: Show Notification & QuickLaunch Request after connect
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": "4.4.506",
"BumpTime": "2024-05-11T09:07:36.0577031Z",
"Version": "4.5.520",
"BumpTime": "2024-05-29T06:25:48.3640756Z",
"Prerelease": false,
"DeprecatedVersion": "4.0.00"
}
10 changes: 8 additions & 2 deletions Pub/PublishApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ param(
[Parameter(Mandatory=$true)][object]$nugets,
[Parameter(Mandatory=$true)][object]$winClient,
[Parameter(Mandatory=$true)][object]$android,
[Parameter(Mandatory=$true)][object]$maui,
[Parameter(Mandatory=$true)][object]$server,
[Parameter(Mandatory=$true)][object]$distribute,
[Parameter(Mandatory=$true)][object]$samples
Expand All @@ -15,6 +16,7 @@ $distribute = $distribute -eq "1";
$winClient = $winClient -eq "1";
$server = $server -eq "1";
$samples = $samples -eq "1";
$maui = $maui -eq "1";

. "$PSScriptRoot/Core/Common.ps1" -bump $bump

Expand All @@ -41,11 +43,15 @@ Remove-Item "$packagesRootDir/ReleaseNote.txt" -ErrorAction Ignore;
& "$solutionDir/VpnHood.Client.App.Android.GooglePlay/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.GooglePlay.Core/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Win.Common/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Maui.Common/_publish.ps1";

& "$solutionDir/VpnHood.Server/_publish.ps1";
& "$solutionDir/VpnHood.Server.Access/_publish.ps1";

# publish client
if ($maui)
{
& "$solutionDir/VpnHood.Client.App.Maui.Common/_publish.ps1";
}

# publish client
if ($winClient)
{
Expand Down
47 changes: 36 additions & 11 deletions Tests/VpnHood.Test/TestAccessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ public class TestAccessManager : IAccessManager
private readonly object _lockeObject = new();
private readonly HttpAccessManager _httpAccessManager;
public int SessionGetCounter { get; private set; }
public DateTime? LastConfigureTime { get; private set; }
public ServerInfo? LastServerInfo { get; private set; }
public ServerStatus? LastServerStatus { get; private set; }

public TestEmbedIoAccessManager EmbedIoAccessManager { get; }
public IAccessManager BaseAccessManager { get; }

public bool IsMaintenanceMode => _httpAccessManager.IsMaintenanceMode;
public IPEndPoint? RedirectHostEndPoint { get; set; }
public Dictionary<string, IPEndPoint?> ServerLocations { get; set; } = new();


public TestAccessManager(IAccessManager baseAccessManager)
{
Expand All @@ -27,15 +38,6 @@ public TestAccessManager(IAccessManager baseAccessManager)
};
}

public DateTime? LastConfigureTime { get; private set; }
public ServerInfo? LastServerInfo { get; private set; }
public ServerStatus? LastServerStatus { get; private set; }

public TestEmbedIoAccessManager EmbedIoAccessManager { get; }
public IAccessManager BaseAccessManager { get; }

public bool IsMaintenanceMode => _httpAccessManager.IsMaintenanceMode;

public async Task<ServerCommand> Server_UpdateStatus(ServerStatus serverStatus)
{
var ret = await _httpAccessManager.Server_UpdateStatus(serverStatus);
Expand All @@ -59,9 +61,32 @@ public Task<SessionResponseEx> Session_Get(ulong sessionId, IPEndPoint hostEndPo
return _httpAccessManager.Session_Get(sessionId, hostEndPoint, clientIp);
}

public Task<SessionResponseEx> Session_Create(SessionRequestEx sessionRequestEx)
public async Task<SessionResponseEx> Session_Create(SessionRequestEx sessionRequestEx)
{
return _httpAccessManager.Session_Create(sessionRequestEx);
var ret = await _httpAccessManager.Session_Create(sessionRequestEx);

if (!sessionRequestEx.AllowRedirect)
return ret;

if (RedirectHostEndPoint != null &&
!sessionRequestEx.HostEndPoint.Equals(RedirectHostEndPoint))
{
ret.RedirectHostEndPoint = RedirectHostEndPoint;
ret.ErrorCode = SessionErrorCode.RedirectHost;
}

// manage region
if (sessionRequestEx.ServerLocation != null)
{
var redirectEndPoint = ServerLocations[sessionRequestEx.ServerLocation];
if (!sessionRequestEx.HostEndPoint.Equals(redirectEndPoint))
{
ret.RedirectHostEndPoint = ServerLocations[sessionRequestEx.ServerLocation];
ret.ErrorCode = SessionErrorCode.RedirectHost;
}
}

return ret;
}

public Task<SessionResponse> Session_AddUsage(ulong sessionId, Traffic traffic, string? adData)
Expand Down
4 changes: 2 additions & 2 deletions Tests/VpnHood.Test/TestConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace VpnHood.Test;
internal class TestConstants
{
public const int DefaultTimeout = 30000;
public static Uri HttpsUri1 => new("https://www.quad9.net/");
public static Uri HttpsUri2 => new("https://www.google.com/");
public static Uri HttpsUri1 => new("https://ipv4.jamieweb.net/"); //make sure always return same ips
public static Uri HttpsUri2 => new("https://ip4.me/"); //make sure always return same ips
public static IPEndPoint NsEndPoint1 => IPEndPoint.Parse("1.1.1.1:53");
public static IPEndPoint NsEndPoint2 => IPEndPoint.Parse("1.0.0.1:53");
public static IPEndPoint TcpEndPoint1 => IPEndPoint.Parse("198.18.0.1:80");
Expand Down
32 changes: 8 additions & 24 deletions Tests/VpnHood.Test/TestEmbedIoAccessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
using EmbedIO;
using EmbedIO.Routing;
using EmbedIO.WebApi;
using Microsoft.Extensions.Logging;
using Swan.Logging;
using VpnHood.Common.Logging;
using VpnHood.Common.Messaging;
using VpnHood.Common.Utils;
using VpnHood.Server.Access;
using VpnHood.Server.Access.Configurations;
using VpnHood.Server.Access.Managers;
using VpnHood.Server.Access.Messaging;
using VpnHood.Tunneling;

// ReSharper disable UnusedMember.Local

Expand All @@ -31,16 +34,18 @@ public TestEmbedIoAccessManager(IAccessManager fileFileAccessManager, bool autoS
BaseUri = new Uri($"http://{VhUtil.GetFreeTcpEndPoint(IPAddress.Loopback)}");
_webServer = CreateServer(BaseUri);
if (autoStart)
{
_webServer.Start();
VhLogger.Instance.LogInformation(GeneralEventId.Test, $"{VhLogger.FormatType(this)} is listening to {BaseUri}");
}
}

public Uri BaseUri { get; }
public IPEndPoint? RedirectHostEndPoint { get; set; }
public HttpException? HttpException { get; set; }
public Dictionary<string, IPEndPoint?> Regions { get; set; } = new();

public void Dispose()
{
Stop();
_webServer.Dispose();
GC.SuppressFinalize(this);
}
Expand All @@ -60,6 +65,7 @@ private WebServer CreateServer(Uri url)

public void Stop()
{
VhLogger.Instance.LogInformation(GeneralEventId.Test, $"{VhLogger.FormatType(this)} has stopped listening to {BaseUri}");
_webServer.Dispose();
}

Expand Down Expand Up @@ -111,28 +117,6 @@ public async Task<SessionResponseEx> Session_Create([QueryField] Guid serverId)
_ = serverId;
var sessionRequestEx = await GetRequestDataAsync<SessionRequestEx>();
var res = await AccessManager.Session_Create(sessionRequestEx);

if (!sessionRequestEx.AllowRedirect)
return res;

if (embedIoAccessManager.RedirectHostEndPoint != null &&
!sessionRequestEx.HostEndPoint.Equals(embedIoAccessManager.RedirectHostEndPoint))
{
res.RedirectHostEndPoint = embedIoAccessManager.RedirectHostEndPoint;
res.ErrorCode = SessionErrorCode.RedirectHost;
}

// manage region
if (sessionRequestEx.RegionId != null)
{
var redirectEndPoint = embedIoAccessManager.Regions[sessionRequestEx.RegionId];
if (!sessionRequestEx.HostEndPoint.Equals(redirectEndPoint))
{
res.RedirectHostEndPoint = embedIoAccessManager.Regions[sessionRequestEx.RegionId];
res.ErrorCode = SessionErrorCode.RedirectHost;
}
}

return res;
}

Expand Down
Loading

0 comments on commit 6094e0e

Please sign in to comment.