Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Dec 19, 2022
2 parents 54a69c4 + 6dae228 commit a2f558f
Show file tree
Hide file tree
Showing 47 changed files with 2,374 additions and 252 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v2.6.327
### Server
* Fix: Error on centos
* Feature: Report CPU usage to access server
* Feature: Add TcpConnectWait control
* Feature: Add TcpChannelCount control

# v2.6.326
### Client
* Feature: Windows: Compile as Win-x64. NET runtime is not required anymore.
Expand Down
1 change: 0 additions & 1 deletion Pub/PublishApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ param(
[Parameter(Mandatory=$true)][object]$distribute
);

$bump = $bump -eq "1";
$nugets = $nugets -eq "1";
$android = $android -eq "1";
$distribute = $distribute -eq "1";
Expand Down
2 changes: 1 addition & 1 deletion Pub/PublishToGitHub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ gh release create "$versionTag" `
-F $releaseRootDir/ReleaseNote.txt `
$releaseClientDir/android/VpnHoodClient-Android.apk `
$releaseClientDir/windows/VpnHoodClient-win-x64.exe `
$releaseClientDir/windows/VpnHoodClient-win.txt `
$packagesRootDir/../Latest/Client/windows/VpnHoodClient-win.txt `
$releaseClientDir/windows/VpnHoodClient-win-x64.txt `
$releaseServerDir/linux-x64/VpnHoodServer-linux-x64.json `
$releaseServerDir/linux-x64/VpnHoodServer-linux-x64.sh `
Expand Down
4 changes: 2 additions & 2 deletions Pub/Version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Major": 2,
"Minor": 6,
"Build": 326,
"BumpTime": "2022-12-15T04:41:17.2014844Z",
"Build": 328,
"BumpTime": "2022-12-19T10:20:18.3580504Z",
"Prerelease": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="VpnHood.Client">
<Version>2.5.324</Version>
<Version>2.6.327</Version>
</PackageReference>
<PackageReference Include="VpnHood.Client.Device.Android">
<Version>2.5.324</Version>
<Version>2.6.327</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VpnHood.Client" Version="2.5.324" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="2.5.324" />
<PackageReference Include="VpnHood.Client" Version="2.6.327" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="2.6.327" />
</ItemGroup>

</Project>
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="326" package="com.vpnhood.client.android" android:installLocation="auto" android:versionName="2.6.326">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="327" package="com.vpnhood.client.android" android:installLocation="auto" android:versionName="2.6.327">
<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
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.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
1,860 changes: 1,860 additions & 0 deletions VpnHood.Client.App.Win.Setup/VpnHood.Client.App.Win.Setup.back (1).aip

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions VpnHood.Client.App.Win/VpnHood.Client.App.Win.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<PackageIcon>VpnHood.png</PackageIcon>
<PackageId>VpnHood.Client.App.Win</PackageId>
<StartupObject></StartupObject>
<Version>2.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<LangVersion>11</LangVersion>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<UseWPF>False</UseWPF>
Expand Down
8 changes: 7 additions & 1 deletion VpnHood.Client.App.Win/WebViewWindow.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.WinForms;
Expand Down Expand Up @@ -69,6 +70,11 @@ private void InitWebView(Uri url, string dataFolderPath)
((System.ComponentModel.ISupportInitialize)(_webView)).EndInit();
}

public Task EnsureCoreWebView2Async()
{
return _webView.EnsureCoreWebView2Async();
}

private void UpdatePosition()
{
// body
Expand Down Expand Up @@ -102,7 +108,7 @@ private void WebView_CoreWebView2InitializationCompleted(object? sender, EventAr
{
if (sender is WebView2 webView)
{
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = true;
webView.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
}
}
Expand Down
24 changes: 17 additions & 7 deletions VpnHood.Client.App.Win/WinApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ namespace VpnHood.Client.App;
public class WinApp : AppBaseNet<WinApp>
{
private const string FileNameAppCommand = "appcommand";
private readonly System.Windows.Forms.Timer _uiTimer;
private readonly Timer _uiTimer;
private DateTime _lastUpdateTime = DateTime.MinValue;
private System.Windows.Forms.NotifyIcon? _notifyIcon;
private NotifyIcon? _notifyIcon;
private readonly CommandListener _commandListener;
private WebViewWindow? _webViewWindow;
private string AppLocalDataPath { get; }

public WinApp() : base("VpnHood")
{
//init timer
_uiTimer = new System.Windows.Forms.Timer
_uiTimer = new Timer
{
Interval = 1000
};
Expand Down Expand Up @@ -133,11 +133,21 @@ public void InitWevView()
{
if (!WebViewWindow.IsInstalled) return;
_webViewWindow = new WebViewWindow(new Uri(VhAppUi.Url), Path.Combine(VhApp.AppDataFolderPath, "Temp"));
_webViewWindow.EnsureCoreWebView2Async()
.ContinueWith(x =>
{
if (x.IsFaulted)
{
_webViewWindow?.Close();
_webViewWindow = null;
}
});

//_webViewWindow.Init("https://www.google.com", @"C:\Users\Developer\AppData\Local\VpnHood\Temp\dd").Wait();
}
catch (Exception ex)
{
_webViewWindow = null;
VhLogger.Instance.LogWarning($"Could not use WebView. Using the default browser. {ex.Message}");
}
}
Expand Down Expand Up @@ -207,17 +217,17 @@ public void OpenMainWindow()

private void InitNotifyIcon()
{
_notifyIcon = new System.Windows.Forms.NotifyIcon
_notifyIcon = new NotifyIcon
{
Icon = Resource.VpnHoodIcon
};
_notifyIcon.MouseClick += (_, e) =>
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
if (e.Button == MouseButtons.Left)
OpenMainWindow();
};

var menu = new System.Windows.Forms.ContextMenuStrip();
var menu = new ContextMenuStrip();
menu.Items.Add(AppUiResource.Open, null, (_, _) => OpenMainWindow());

menu.Items.Add("-");
Expand Down Expand Up @@ -256,7 +266,7 @@ private void ConnectMenuItem_Click(object? sender, EventArgs e)

private void Menu_Opening(object? sender, CancelEventArgs e)
{
var menu = (System.Windows.Forms.ContextMenuStrip)sender!;
var menu = (ContextMenuStrip)sender!;
menu.Items["connect"].Enabled = VhApp.IsIdle;
menu.Items["disconnect"].Enabled =
!VhApp.IsIdle && VhApp.State.ConnectionState != AppConnectionState.Disconnecting;
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.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</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.6.326</Version>
<Version>2.6.328</Version>
<PackageId>VpnHood.Client.Device.WinDivert</PackageId>
<Version>1.1.226</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</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.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</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>2022 VpnHood</Copyright>
<PackageId>VpnHood.Client</PackageId>
<PackageTags>VPN VpnClient Proxy</PackageTags>
<Version>2.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
44 changes: 44 additions & 0 deletions VpnHood.Common/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,48 @@ public static string RedactIpAddress(IPAddress ipAddress)

return ipAddress.ToString();
}

public static string FormatBytes(long size)
{
// Get absolute value
if (size >= 0x10000000000) // Terabyte
return ((double)(size >> 30) / 1024).ToString("0.## ") + "TB";

if (size >= 0x40000000) // Gigabyte
return ((double)(size >> 20) / 1024).ToString("0.# ") + "GB";

if (size >= 0x100000) // Megabyte
return ((double)(size >> 10) / 1024).ToString("0 ") + "MB";

if (size >= 1024) // Kilobyte
return ((double)size / 1024).ToString("0 ") + "KB";

if (size > 0) // Kilobyte
return size.ToString("0 ") + "B";

// Byte
return size.ToString("0");
}

[SuppressMessage("ReSharper", "PossibleLossOfFraction")]
public static string FormatBits(long bytes)
{
bytes *= 8; //convertTo bit

// Get absolute value
if (bytes >= 0x40000000) // Gigabyte
return ((double)(bytes / 0x40000000)).ToString("0.# ") + "Gbps";

if (bytes >= 0x100000) // Megabyte
return ((double)(bytes / 0x100000)).ToString("0 ") + "Mbps";

if (bytes >= 1024) // Kilobyte
return ((double)(bytes / 1024)).ToString("0 ") + "Kbps";

if (bytes > 0) // Kilobyte
return ((double)bytes).ToString("0 ") + "bps";

// Byte
return bytes.ToString("0");
}
}
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.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion VpnHood.Server.Access/ServerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public ServerInfo(Version version,
public ServerStatus Status { get; set; }
public string? OsInfo { get; set; }
public string? OsVersion { get; set; }
public long TotalMemory { get; set; }
public long? TotalMemory { get; set; }
public string? MachineName { get; set; }
public string? LastError { get; set; }
public int LogicalCoreCount { get; set; }
}
3 changes: 2 additions & 1 deletion VpnHood.Server.Access/ServerStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public class ServerStatus
public int SessionCount { get; set; }
public int TcpConnectionCount { get; set; }
public int UdpConnectionCount { get; set; }
public long FreeMemory { get; set; }
public long? AvailableMemory { get; set; }
public int? CpuUsage { get; set; }
public long UsedMemory { get; set; }
public int ThreadCount { get; set; }
public long TunnelSendSpeed { get; set; }
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.6.326</Version>
<AssemblyVersion>2.6.326</AssemblyVersion>
<FileVersion>2.6.326</FileVersion>
<Version>2.6.328</Version>
<AssemblyVersion>2.6.328</AssemblyVersion>
<FileVersion>2.6.328</FileVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions VpnHood.Server.App.Net/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public class AppSettings
public FileAccessServerOptions? FileAccessServer { get; set; } = new();
public bool IsAnonymousTrackerEnabled { get; set; } = true;
public bool IsDiagnoseMode { get; set; }
public int MaxTcpConnectWaitCount { get; set; } = new ServerOptions().MaxTcpConnectWaitCount;
public int MaxTcpChannelCount { get; set; } = new ServerOptions().MaxTcpChannelCount;
public TimeSpan TcpConnectTimeout { get; set; } = new ServerOptions().TcpConnectTimeout;
}
2 changes: 1 addition & 1 deletion VpnHood.Server.App.Net/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private static void Main(string[] args)
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex);
}
}
}
3 changes: 1 addition & 2 deletions VpnHood.Server.App.Net/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"profiles": {
"VpnHood.Server.App.Net": {
"commandName": "Project",
"commandLineArgs": "gen -domain"
"commandName": "Project"
},
"WSL 2": {
"commandName": "WSL2",
Expand Down
Loading

0 comments on commit a2f558f

Please sign in to comment.