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 12, 2023
2 parents 9432964 + c55babe commit fc4d803
Show file tree
Hide file tree
Showing 58 changed files with 399 additions and 313 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.8.360
### Client
* Fix: Used traffic was not displayed correctly

### Server
* Fix: Used traffic was not reported correctly

# v2.7.357
### Client
* Fix: Windows: Too long filter expression error
Expand Down
4 changes: 2 additions & 2 deletions Pub/Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Version": "2.7.357",
"BumpTime": "2023-03-10T02:50:07.6445704Z",
"Version": "2.8.360",
"BumpTime": "2023-03-12T01:19:57.7771871Z",
"Prerelease": false,
"DeprecatedVersion": "2.0.0"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified VpnHood.Client.App.Android/Assets/SPA.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion VpnHood.Client.App.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="356" package="com.vpnhood.client.android" android:installLocation="auto" android:versionName="2.7.356">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="360" package="com.vpnhood.client.android" android:installLocation="auto" android:versionName="2.8.360">
<uses-sdk android:minSdkVersion="22" android:targetSdkVersion="33" />
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client.App.UI/VpnHood.Client.App.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<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.7.357</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<Version>2.8.360</Version>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client.App.UI/VpnHoodAppUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static VpnHoodAppUi Init(Stream zipStream, int defaultPort = 9090, Uri? u

private void Start()
{
_url1 = new Uri($"http://{Util.GetFreeTcpEndPoint(IPAddress.Loopback, DefaultPort)}");
_url1 = new Uri($"http://{VhUtil.GetFreeTcpEndPoint(IPAddress.Loopback, DefaultPort)}");
_server = CreateWebServer(Url1, Url2, GetSpaPath());
try
{
Expand Down Expand Up @@ -117,7 +117,7 @@ private WebServer CreateWebServer(Uri url1, Uri? url2, string spaPath)
{
// read index.html for fallback
_indexHtml = File.ReadAllText(Path.Combine(spaPath, "index.html"));
var urlPrefixes = new string[] { url1.AbsoluteUri };
var urlPrefixes = new[] { url1.AbsoluteUri };
if (url2 != null) urlPrefixes = urlPrefixes.Concat(new[] { url2.AbsoluteUri }).ToArray();

// create the server
Expand Down
Binary file modified VpnHood.Client.App.Win/Resources/SPA.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions VpnHood.Client.App.Win/VpnHood.Client.App.Win.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageId>VpnHood.Client.App.Win</PackageId>
<StartupObject></StartupObject>
<Version>2.7.357</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<Version>2.8.360</Version>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
Expand Down
12 changes: 7 additions & 5 deletions VpnHood.Client.App.Win/WinApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class WinApp : IDisposable
private bool _disposed;
private bool _showWindowAfterStart;
private string AppLocalDataPath { get; }
public Uri LocalHostUrl = new($"http://myvpnhood");
public Uri LocalHostUrl = new("http://myvpnhood");

public WinApp()
{
Expand Down Expand Up @@ -94,6 +94,7 @@ public void Start(string[] args)
}
catch
{
// ignored
}

// configuring Windows Firewall
Expand Down Expand Up @@ -242,7 +243,7 @@ private void CheckForUpdate()

public void OpenMainWindow()
{
if (_webViewWindow != null && _webViewWindow.IsInitCompleted)
if (_webViewWindow is { IsInitCompleted: true })
_webViewWindow.Show();
else
OpenMainWindowInBrowser();
Expand Down Expand Up @@ -321,7 +322,7 @@ private void Menu_Opening(object? sender, CancelEventArgs e)
var menu = (ContextMenuStrip)sender!;
menu.Items["connect"].Enabled = VhApp.IsIdle;
menu.Items["disconnect"].Enabled = !VhApp.IsIdle && VhApp.State.ConnectionState != AppConnectionState.Disconnecting;
menu.Items["open"].Visible = _webViewWindow != null && _webViewWindow.IsInitCompleted;
menu.Items["open"].Visible = _webViewWindow is { IsInitCompleted: true };
menu.Items["openInBrowser"].Visible = true;
}

Expand Down Expand Up @@ -400,11 +401,12 @@ public void Dispose()
private void RegisterLocalDomain()
{
var hostsFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "drivers", "etc", "hosts");
var hosts = File.ReadLines(hostsFilePath);
var hosts = File.ReadLines(hostsFilePath).ToList();
var hostItem = $"{LocalHostIpAddress} {LocalHostUrl.Host}";

if (!hosts.Contains(hostItem))
{
hosts = hosts.Concat(new[] { hostItem });
hosts.Add(hostItem);
File.WriteAllLines(hostsFilePath, hosts.ToArray());
}
}
Expand Down
8 changes: 4 additions & 4 deletions VpnHood.Client.App/AppState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using VpnHood.Common.Messaging;

namespace VpnHood.Client.App;

Expand All @@ -15,10 +16,9 @@ public class AppState
public bool HasDisconnectedByUser { get; internal set; }
public bool HasProblemDetected { get; internal set; }
public SessionStatus? SessionStatus { get; internal set; }
public long SendSpeed { get; internal set; }
public long SentTraffic { get; internal set; }
public long ReceiveSpeed { get; internal set; }
public long ReceivedTraffic { get; internal set; }
public Traffic Speed { get; internal set; } = new ();
public Traffic SessionTraffic { get; internal set; } = new ();
public Traffic AccountTraffic { get; internal set; } = new ();
public IpGroup? ClientIpGroup { get; internal set; }
public bool IsWaitingForAd { get; internal set; }
public VersionStatus VersionStatus { get; internal set; }
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client.App/ClientProfileStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<Token> UpdateTokenFromUrl(Token token)
try
{
using var client = new HttpClient();
var accessKey = await Util.RunTask(client.GetStringAsync(token.Url), TimeSpan.FromSeconds(20));
var accessKey = await VhUtil.RunTask(client.GetStringAsync(token.Url), TimeSpan.FromSeconds(20));
var newToken = Token.FromAccessKey(accessKey);
if (newToken.TokenId != token.TokenId)
throw new InvalidOperationException($"Could not updated Token because {nameof(token.TokenId)} has been changed! TokenId: {VhLogger.FormatId(token.TokenId)}");
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client.App/VpnHood.Client.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<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.7.357</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<Version>2.8.360</Version>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
18 changes: 9 additions & 9 deletions VpnHood.Client.App/VpnHoodApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using VpnHood.Common;
using VpnHood.Common.JobController;
using VpnHood.Common.Logging;
using VpnHood.Common.Messaging;
using VpnHood.Common.Net;
using VpnHood.Common.Utils;
using VpnHood.Tunneling;
Expand Down Expand Up @@ -128,10 +129,9 @@ private VpnHoodApp(IAppProvider clientAppProvider, AppOptions? options = default
HasDisconnectedByUser = _hasDisconnectedByUser,
HasProblemDetected = _hasConnectRequested && IsIdle && (_hasDiagnoseStarted || LastError != null),
SessionStatus = LastSessionStatus,
ReceiveSpeed = Client?.ReceiveSpeed ?? 0,
ReceivedTraffic = Client?.ReceivedByteCount ?? 0,
SendSpeed = Client?.SendSpeed ?? 0,
SentTraffic = Client?.SentByteCount ?? 0,
Speed = Client?.Speed ?? new Traffic(),
AccountTraffic = Client?.AccountTraffic ?? new Traffic(),
SessionTraffic = Client?.SessionTraffic ?? new Traffic(),
ClientIpGroup = _lastClientIpGroup,
IsWaitingForAd = IsWaitingForAd,
VersionStatus = VersionStatus,
Expand Down Expand Up @@ -389,9 +389,9 @@ private async Task ConnectInternal(IPacketCapture packetCapture, Guid tokenId, s

// calculate packetCaptureIpRanges
var packetCaptureIpRanges = IpNetwork.All.ToIpRanges();
if (!Util.IsNullOrEmpty(UserSettings.PacketCaptureIncludeIpRanges))
if (!VhUtil.IsNullOrEmpty(UserSettings.PacketCaptureIncludeIpRanges))
packetCaptureIpRanges = packetCaptureIpRanges.Intersect(UserSettings.PacketCaptureIncludeIpRanges);
if (!Util.IsNullOrEmpty(UserSettings.PacketCaptureExcludeIpRanges))
if (!VhUtil.IsNullOrEmpty(UserSettings.PacketCaptureExcludeIpRanges))
packetCaptureIpRanges = packetCaptureIpRanges.Exclude(UserSettings.PacketCaptureExcludeIpRanges);

// create clientOptions
Expand Down Expand Up @@ -446,7 +446,7 @@ private void ClientConnect_StateChanged(object sender, EventArgs e)

private async Task<IpRange[]?> GetIncludeIpRanges(FilterMode filterMode, string[]? ipGroupIds)
{
if (filterMode == FilterMode.All || Util.IsNullOrEmpty(ipGroupIds))
if (filterMode == FilterMode.All || VhUtil.IsNullOrEmpty(ipGroupIds))
return null;

if (filterMode == FilterMode.Include)
Expand Down Expand Up @@ -501,7 +501,7 @@ public async Task Disconnect(bool byUser = false)
// check for any success
if (Client != null)
{
_hasAnyDataArrived = Client.ReceivedByteCount > 1000;
_hasAnyDataArrived = Client.SessionTraffic.Received > 1000;
if (LastError == null && !_hasAnyDataArrived && UserSettings is { IpGroupFiltersMode: FilterMode.All, TunnelClientCountry: true })
_lastException = new Exception("No data has arrived!");
}
Expand Down Expand Up @@ -591,7 +591,7 @@ public async Task CheckNewVersion()

using var httpClient = new HttpClient();
var publishInfoJson = await httpClient.GetStringAsync(Features.UpdateInfoUrl);
LatestPublishInfo = Util.JsonDeserialize<PublishInfo>(publishInfoJson);
LatestPublishInfo = VhUtil.JsonDeserialize<PublishInfo>(publishInfoJson);

// Check version
if (LatestPublishInfo.Version == null)
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client.Device.Android/AndroidPacketCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private Task ReadingPacketTask()
}
catch (Exception ex)
{
if (!Util.IsSocketClosedException(ex))
if (!VhUtil.IsSocketClosedException(ex))
VhLogger.Instance.LogError($"ReadingPacketTask: {ex}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<RepositoryUrl>https://github.com/vpnhood/vpnhood</RepositoryUrl>
<PackageIcon>VpnHood.png</PackageIcon>
<Description>VpnHood client device provider for Windows using WinDivert.</Description>
<Version>2.7.357</Version>
<Version>2.8.360</Version>
<PackageId>VpnHood.Client.Device.WinDivert</PackageId>
<Version>1.1.226</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client.Device/VpnHood.Client.Device.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<RepositoryType></RepositoryType>
<PackageId>VpnHood.Client.Device</PackageId>
<RootNamespace>VpnHood.Client.Device</RootNamespace>
<Version>2.7.357</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<Version>2.8.360</Version>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion VpnHood.Client/Diagnosing/DiagnoseUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static async Task<IPHostEntry> GetHostEntry(string host, IPEndPoint dnsEn
udpClient.Client.SendTimeout = timeout;
udpClient.Client.ReceiveTimeout = timeout;
await udpClient.SendAsync(buffer, buffer.Length, dnsEndPoint);
var receiveTask = await Util.RunTask(udpClient.ReceiveAsync(), TimeSpan.FromMilliseconds(timeout));
var receiveTask = await VhUtil.RunTask(udpClient.ReceiveAsync(), TimeSpan.FromMilliseconds(timeout));
buffer = receiveTask.Buffer;

//The response message has the same header and question structure, so we move index to the answer part directly.
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client/TcpProxyHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private async Task AcceptTcpClientLoop(TcpListener tcpListener)
{
while (!cancellationToken.IsCancellationRequested)
{
var tcpClient = await Util.RunTask(tcpListener.AcceptTcpClientAsync(), default, cancellationToken);
var tcpClient = await VhUtil.RunTask(tcpListener.AcceptTcpClientAsync(), default, cancellationToken);
_ = ProcessClient(tcpClient, cancellationToken);
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ await Client.AddPassthruTcpStream(
Client.SessionId,
Client.SessionKey,
new IPEndPoint(natItem.DestinationAddress, natItem.DestinationPort),
Util.GenerateSessionKey(),
VhUtil.GenerateSessionKey(),
natItem.DestinationPort == 443 ? TunnelUtil.TlsHandshakeLength : -1);

tcpProxyClientStream = await Client.GetTlsConnectionToServer(GeneralEventId.TcpProxyChannel, cancellationToken);
Expand Down
4 changes: 2 additions & 2 deletions VpnHood.Client/VpnHood.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Copyright>2022 VpnHood</Copyright>
<PackageId>VpnHood.Client</PackageId>
<PackageTags>VPN VpnClient Proxy</PackageTags>
<Version>2.7.357</Version>
<AssemblyVersion>2.7.357</AssemblyVersion>
<Version>2.8.360</Version>
<AssemblyVersion>2.8.360</AssemblyVersion>
<FileVersion>$([System.DateTime]::Now.ToString("yyyy.M.d.HHmm"))</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
Loading

0 comments on commit fc4d803

Please sign in to comment.