Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Mar 21, 2022
2 parents 1f687b3 + 6649dcb commit e14a578
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 63 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.4.297
### Server
* Fix: Reporting Negative usage

# v2.4.296
### Client
* Fix: Windows: WebView2 could not be installed on some devices
Expand Down Expand Up @@ -369,3 +373,4 @@




4 changes: 2 additions & 2 deletions Pub/Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Major": 2,
"Minor": 4,
"Build": 296,
"BumpTime": "2022-03-20T07:55:34.1056241Z"
"Build": 297,
"BumpTime": "2022-03-21T19:24:22.0133214Z"
}
10 changes: 5 additions & 5 deletions VpnHood.App.Launcher/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Updater(string? appFolder = null, UpdaterOptions? options = null)
AppFolder = appFolder
?? Path.GetDirectoryName(Path.GetDirectoryName(typeof(Updater).Assembly.Location))
?? throw new ArgumentException("Could not set AppFolder", nameof(appFolder));
CheckIntervalMinutes = options.CheckIntervalMinutes;
CheckInterval = options.CheckInterval;

var publishInfoFilePath = Path.Combine(AppFolder, "publish.json");
Console.WriteLine(publishInfoFilePath);
Expand All @@ -52,7 +52,7 @@ public Updater(string? appFolder = null, UpdaterOptions? options = null)

public string AppFolder { get; }
public Uri? UpdateUri { get; }
public int CheckIntervalMinutes { get; }
public TimeSpan CheckInterval { get; }
public string UpdatesFolder => Path.Combine(AppFolder, "updates");
public string NewPublishInfoFilePath => Path.Combine(UpdatesFolder, "publish.json");
private string LastCheckFilePath => Path.Combine(UpdatesFolder, "lastcheck.json");
Expand Down Expand Up @@ -108,8 +108,8 @@ public int Start()
CheckUpdateOffline();

// Create Update Interval
if (UpdateUri != null && CheckIntervalMinutes != 0)
_timer = new Timer(_ => CheckUpdateOnlineInterval(), null, 0, CheckIntervalMinutes * 60 * 1000);
if (UpdateUri != null && CheckInterval != TimeSpan.Zero)
_timer = new Timer(_ => CheckUpdateOnlineInterval(), null, TimeSpan.Zero, CheckInterval);

// launch main app
if (!CancellationToken.IsCancellationRequested)
Expand All @@ -124,7 +124,7 @@ private void CheckUpdateOnlineInterval()
{
// read last check
var lastOnlineCheckTime = LastOnlineCheckTime ?? DateTime.MinValue;
if ((DateTime.Now - lastOnlineCheckTime).TotalMinutes >= CheckIntervalMinutes)
if ((DateTime.Now - lastOnlineCheckTime) >= CheckInterval)
CheckUpdateOnline().GetAwaiter();
}
catch (Exception ex)
Expand Down
5 changes: 3 additions & 2 deletions VpnHood.App.Launcher/UpdaterOptions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Microsoft.Extensions.Logging;
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

namespace VpnHood.App.Launcher
{
public class UpdaterOptions
{
public int CheckIntervalMinutes { get; set; } = 1 * 24 * 60;
public TimeSpan CheckInterval { get; set; } = TimeSpan.FromHours(12);
public ILogger Logger { get; set; } = NullLogger.Instance;
}
}
6 changes: 3 additions & 3 deletions VpnHood.App.Launcher/VpnHood.App.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<PackageIcon>VpnHood.png</PackageIcon>
<Product>VpnHood.App.Launcher</Product>
<ApplicationIcon>Resources\VpnHood.ico</ApplicationIcon>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client.App.UI/VpnHood.Client.App.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageIcon>VpnHood.png</PackageIcon>
<Description>Tiny internal webserver to server your single-page application (SPA). You need this only if you want to create a UI for your VpnHood client by single-page application (SPA).</Description>
<PackageId>VpnHood.Client.App.UI</PackageId>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client.App/VpnHood.Client.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<Description>Readymade Vpn App skeleton for VpnHood clients. You just need to create a UI on it.</Description>
<PackageId>VpnHood.Client.App</PackageId>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<PackageIcon>VpnHood.png</PackageIcon>
<Description>VpnHood client device provider for Windows using WinDivert.</Description>
<Version>2.4.296</Version>
<Version>2.4.297</Version>
<PackageId>VpnHood.Client.Device.WinDivert</PackageId>
<Version>1.1.226</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client.Device/VpnHood.Client.Device.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<RepositoryType></RepositoryType>
<PackageId>VpnHood.Client.Device</PackageId>
<RootNamespace>VpnHood.Client.Device</RootNamespace>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Client/VpnHood.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<Copyright>2020 VpnHood</Copyright>
<PackageId>VpnHood.Client</PackageId>
<PackageTags>VPN VpnClient Proxy</PackageTags>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Common/VpnHood.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageId>VpnHood.Common</PackageId>
<PackageIcon>VpnHood.png</PackageIcon>
<Description>VpnHood Common Library is shared among all other VpnHood modules.</Description>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Server.Access/VpnHood.Server.Access.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<PackageId>VpnHood.Server.Access</PackageId>
<PackageIcon>VpnHood.png</PackageIcon>
<Description>Stores, and retrieves end users' access and usage. Provides required interfaces and classes to use or create an access server and accounting.</Description>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Server.App.Net/Install/install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ExecStart=/bin/sh -c \"dotnet '$destinationPath/launcher/run.dll' -launcher:noLa
ExecStop=/bin/sh -c \"dotnet '$destinationPath/launcher/run.dll' stop\"
TimeoutStartSec=0
Restart=always
RestartSec=2
RestartSec=20
[Install]
WantedBy=default.target
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Server.App.Net/VpnHood.Server.App.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<PackageLicenseExpression>LGPL-2.1-only</PackageLicenseExpression>
<PackageIcon>VpnHood.png</PackageIcon>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Server/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal Session(IAccessServer accessServer, SessionResponse sessionResponse, So
SessionResponse = new ResponseBase(sessionResponse);
SessionId = sessionResponse.SessionId;
SessionKey = sessionResponse.SessionKey ?? throw new InvalidOperationException($"{nameof(sessionResponse)} does not have {nameof(sessionResponse.SessionKey)}!");

var tunnelOptions = new TunnelOptions();
if (options.MaxDatagramChannelCount > 0) tunnelOptions.MaxDatagramChannelCount = options.MaxDatagramChannelCount;
Tunnel = new Tunnel(tunnelOptions);
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Server/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal async Task<Session> GetSession(RequestBase sessionRequest, IPEndPoint h
isNew = true;
return new TimeoutItem<SemaphoreSlim>(new SemaphoreSlim(0));
}).Value;

if (!isNew)
{
await semaphore.WaitAsync(TimeSpan.FromMinutes(2));
Expand All @@ -128,7 +128,7 @@ internal async Task<Session> GetSession(RequestBase sessionRequest, IPEndPoint h
var sessionResponse = await _accessServer.Session_Get(sessionRequest.SessionId, hostEndPoint, clientIp);
if (!sessionRequest.SessionKey.SequenceEqual(sessionResponse.SessionKey))
throw new UnauthorizedAccessException("Invalid SessionKey");

session = CreateSession(sessionResponse, hostEndPoint);
VhLogger.Instance.LogTrace(GeneralEventId.Session, "Session has been recovered.");
}
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Server/VpnHood.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<PackageIcon>VpnHood.png</PackageIcon>
<Description>The core of VpnHood server. It can listen and accept connections from VpnHood clients.</Description>
<PackageId>VpnHood.Server</PackageId>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
27 changes: 10 additions & 17 deletions VpnHood.Tunneling/Tunnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Tunnel : IDisposable

public Tunnel(TunnelOptions? options = null)
{
options ??= new();
options ??= new TunnelOptions();
_tcpTimeout = options.TcpTimeout;
_maxDatagramChannelCount = options.MaxDatagramChannelCount;
_speedMonitorTimer = new Timer(SpeedMonitor, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
Expand Down Expand Up @@ -351,10 +351,9 @@ private async Task SendPacketTask(IDatagramChannel channel)
}

// just send this packet if it is bigger than _mtuNoFragment and there is no more packet in the buffer
// packets should be empty to decrease the chance of looosing the other packets by this packet
// packets should be empty to decrease the chance of loosing the other packets by this packet
if (packetSize > _mtuNoFragment && !packets.Any() && _packetQueue.TryDequeue(out ipPacket))
{
size += packetSize;
packets.Add(ipPacket);
break;
}
Expand Down Expand Up @@ -400,30 +399,24 @@ private async Task SendPacketTask(IDatagramChannel channel)

// lets the other do the rest of the job (if any)
// should not throw error if object has been disposed
try { _packetSenderSemaphore.Release(); } catch (ObjectDisposedException) { };
try { _packetSentEvent.Release(); } catch (ObjectDisposedException) { };
try { _packetSenderSemaphore.Release(); } catch (ObjectDisposedException) { }

try { _packetSentEvent.Release(); } catch (ObjectDisposedException) { }
}

public void Dispose()
{
if (_disposed) return;
_disposed = true;

// make sure to call RemoveChannel to perform proper clean up such as setting _sentByteCount and _receivedByteCount
lock (_channelListLock)
{
foreach (var channel in _streamChannels)
{
channel.Dispose();
channel.OnFinished -= Channel_OnFinished;
}
_streamChannels.Clear(); //cleanup main consuming memory objects faster
foreach (var channel in _streamChannels.ToArray())
RemoveChannel(channel);

foreach (var channel in DatagramChannels)
{
channel.Dispose();
channel.OnFinished -= Channel_OnFinished;
}
DatagramChannels = Array.Empty<IDatagramChannel>(); //cleanup main consuming memory objects faster
foreach (var channel in DatagramChannels.ToArray())
RemoveChannel(channel);
}

lock (_packetQueue)
Expand Down
6 changes: 3 additions & 3 deletions VpnHood.Tunneling/VpnHood.Tunneling.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<PackageIcon>VpnHood.png</PackageIcon>
<Product>VpnHood.Tunneling</Product>
<Description>Provides tunnelling classes and protocols shared between VpnHood.Client and VpnHood.Server.</Description>
<Version>2.4.296</Version>
<AssemblyVersion>2.4.296</AssemblyVersion>
<FileVersion>2.4.296</FileVersion>
<Version>2.4.297</Version>
<AssemblyVersion>2.4.297</AssemblyVersion>
<FileVersion>2.4.297</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down

0 comments on commit e14a578

Please sign in to comment.