Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Sep 28, 2023
2 parents b4e2ef1 + d8ec7af commit 4c75651
Show file tree
Hide file tree
Showing 358 changed files with 9,082 additions and 3,990 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v3.0.423
### Client
* Feature: Android: Support opening Cinderella file (CDY) as VpnHood Key file
* Feature: Android: Changing file signature for no-google-store APK
* Update: Remove the legacy Protocol Version 3
* Update: Improve performance, and battery usage
*
### Server
* Update: Remove the legacy Protocol Version 3
* Fix: Collection was modified error, which caused connection freeze temporary
*
# v3.0.416
### Client
* Feature: Offer Premium if VpnHood Public server selected
Expand Down
54 changes: 54 additions & 0 deletions Pub/Android.GooglePlay/_publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
. "$PSScriptRoot/../Common.ps1"

Write-Host "";
Write-Host "*** Publishing Android of GooglePlay ..." -BackgroundColor Blue -ForegroundColor White;

$projectDir = $PSScriptRoot


#find the apk in current folder
$apkFileData = Get-ChildItem -Path $projectDir -Filter *.apk | Select-Object -First 1;
if ($apkFileData -eq $null)
{
Write-Host "No apk file found in $projectDir" -ForegroundColor Red;
exit;
}
$apkFile = $apkFileData.FullName;
$apkVersionCode = (Get-Item $apkFile).Basename;
$version = [version]::new($version.Major, $version.Minor, $apkVersionCode);
$versionParam = $version.ToString(3);
$versionTag="v$versionParam";

# prepare module folders
$moduleDir = "$projectDir/apk/$versionTag";
$moduleDirLatest = "$projectDir/apk/latest";
$module_infoFile = "$moduleDir/VpnHoodClient-android.json";
$module_packageFile = "$moduleDir/VpnHoodClient-android.apk";
PrepareModuleFolder $moduleDir $moduleDirLatest;

# Calcualted Path
$module_infoFileName = $(Split-Path "$module_infoFile" -leaf);
$module_packageFileName = $(Split-Path "$module_packageFile" -leaf);

# publish info
$json = @{
Version = $versionParam;
UpdateInfoUrl = "https://github.com/vpnhood/VpnHood/releases/latest/download/$module_infoFileName";
PackageUrl = "https://github.com/vpnhood/VpnHood/releases/download/$versionTag/$module_packageFileName";
InstallationPageUrl = "https://github.com/vpnhood/VpnHood/wiki/Install-VpnHood-Client";
ReleaseDate = "$releaseDate";
DeprecatedVersion = "$deprecatedVersion";
NotificationDelay = "14.00:00:00";
};
$json | ConvertTo-Json | Out-File "$module_infoFile" -Encoding ASCII;

# move the apk
Move-Item -Path $apkFile -Destination $module_packageFile -Force;
Copy-Item -path "$moduleDir/*" -Destination "$moduleDirLatest/" -Force -Recurse;

# apk
# Write-Host;
# Write-Host "*** Updating Android apk of GooglePlay to $versionTag ..." -BackgroundColor Blue -ForegroundColor White;
$latestVersion = (gh release list -R "vpnhood/vpnhood" --limit 1 --exclude-drafts --exclude-pre-releases | ForEach-Object { $_.Split()[0] });
gh release upload $versionTag $module_infoFile $module_packageFile --clobber

2 changes: 1 addition & 1 deletion Pub/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ param(
$ErrorActionPreference = "Stop";

$solutionDir = Split-Path -parent $PSScriptRoot;
$msbuild = Join-Path ${Env:Programfiles} "Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
$msbuild = Join-Path ${Env:Programfiles} "Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe";
$credentials = (Get-Content "$solutionDir/../.user/credentials.json" | Out-String | ConvertFrom-Json);
$nugetApiKey = $credentials.NugetApiKey;
$nuget = Join-Path $PSScriptRoot "nuget.exe";
Expand Down
12 changes: 6 additions & 6 deletions Pub/PublishApps.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
param(
[Parameter(Mandatory=$true)][object]$bump,
[Parameter(Mandatory=$true)][object]$nugets,
[Parameter(Mandatory=$true)][object]$client,
[Parameter(Mandatory=$true)][object]$winClient,
[Parameter(Mandatory=$true)][object]$android,
[Parameter(Mandatory=$true)][object]$server,
[Parameter(Mandatory=$true)][object]$distribute
Expand All @@ -10,7 +10,7 @@ param(
$nugets = $nugets -eq "1";
$android = $android -eq "1";
$distribute = $distribute -eq "1";
$client = $client -eq "1";
$winClient = $winClient -eq "1";
$server = $server -eq "1";

. "$PSScriptRoot/Common.ps1" -bump $bump
Expand All @@ -27,17 +27,17 @@ Remove-Item "$packagesRootDir/ReleaseNote.txt" -ErrorAction Ignore;
& "$solutionDir/VpnHood.Tunneling/_publish.ps1";

& "$solutionDir/VpnHood.Client/_publish.ps1";
& "$solutionDir/VpnHood.Client.Device.Android/_publish.ps1";
& "$solutionDir/VpnHood.Client.Device.Android.Xamarin/_publish.ps1";
& "$solutionDir/VpnHood.Client.Device/_publish.ps1";
& "$solutionDir/VpnHood.Client.Device.WinDivert/_publish.ps1";
& "$solutionDir/VpnHood.Client.App/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.UI/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.WebServer/_publish.ps1";

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

# publish client
if ($client)
if ($winClient)
{
& "$solutionDir/VpnHood.Client.App.Win/_publish.ps1";
}
Expand All @@ -54,7 +54,7 @@ if ($server)
# publish android
if ($android)
{
& "$solutionDir/VpnHood.Client.App.Android/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.Xamarin/_publish.ps1";
}

# distribute
Expand Down
6 changes: 4 additions & 2 deletions Pub/PublishNuget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ param([Parameter(Mandatory=$true)] [String]$projectDir)
# paths
$projectFile = (Get-ChildItem -path $projectDir -file -Filter "*.csproj").FullName;
$assemblyName = ([Xml] (Get-Content $projectFile)).Project.PropertyGroup.AssemblyName;
if (!$assemblyName) {$assemblyName = (Get-Item $projectFile).BaseName};
$packageId = ([Xml] (Get-Content $projectFile)).Project.PropertyGroup.PackageId;
if (!$packageId) {$packageId = $assemblyName};
$packageId = "$packageId".Trim();
$publishDir = Join-Path $projectDir "bin\release\publish";

Expand All @@ -13,7 +15,7 @@ UpdateProjectVersion $projectFile;

# packing
Write-Host
Write-Host "*** Packing..." -BackgroundColor Blue
Write-Host "*** $packageId > Packing..." -BackgroundColor Blue
rm "$publishDir" -ErrorAction Ignore -Recurse
$nugetVersion="$versionParam" + (&{if($prerelease) {"-prerelease"} else {""}});
dotnet pack "$projectDir" -c "Release" -o "$publishDir" --runtime any -p:Version=$nugetVersion -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
Expand All @@ -23,7 +25,7 @@ if ($LASTEXITCODE -gt 0) { Throw "The pack exited with error code: " + $lastexit
if (!$noPushNuget)
{
Write-Host
Write-Host "*** Publishing..." -BackgroundColor Blue
Write-Host "*** $packageId > Publishing..." -BackgroundColor Blue
$packageFile = (Join-Path $publishDir "$packageId.$nugetVersion.nupkg")
dotnet nuget push $packageFile --api-key $nugetApiKey --source https://api.nuget.org/v3/index.json
if ($LASTEXITCODE -gt 0) { Write-Host ("The publish exited with error code: " + $lastexitcode) -ForegroundColor Red; }
Expand Down
2 changes: 2 additions & 0 deletions Pub/PublishToGitHub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ $releaseRootDir = (&{if($isLatest) {$packagesRootDirLatest} else {$packagesRootD
$releaseClientDir = (&{if($isLatest) {$packagesClientDirLatest} else {$packagesClientDir}})
$releaseServerDir = (&{if($isLatest) {$packagesServerDirLatest} else {$packagesServerDir}})

# $releaseClientDir/android/VpnHoodClient-android-web.apk `
# $releaseClientDir/android/VpnHoodClient-android-web.json `
gh release create "$versionTag" `
--title "$versionTag" `
(&{if($prerelease) {"--prerelease"} else {"--latest"}}) `
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": "3.0.416",
"BumpTime": "2023-08-19T22:56:27.8892522Z",
"Version": "3.0.423",
"BumpTime": "2023-09-28T00:25:33.5679063Z",
"Prerelease": false,
"DeprecatedVersion": "3.0.400"
}
1 change: 0 additions & 1 deletion Samples/VpnHood.Samples.SimpleClient.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public override void OnRequestPermissionsResult(int requestCode, string[] permis
[GeneratedEnum] Permission[] grantResults)
{
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.vpnhood.samples.simpleclient.droid" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="33" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"></application>
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true"></application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
</manifest>

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

Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="VpnHood.Client">
<Version>3.0.414</Version>
<Version>3.0.416</Version>
</PackageReference>
<PackageReference Include="VpnHood.Client.Device.Android">
<Version>3.0.414</Version>
<Version>3.0.416</Version>
</PackageReference>
<PackageReference Include="Xamarin.Essentials" Version="1.8.0" />
</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="3.0.414" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="3.0.414" />
<PackageReference Include="VpnHood.Client" Version="3.0.416" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="3.0.416" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions Tests/VpnHood.Test/TestAppProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using VpnHood.Client.App;
using VpnHood.Client.Device;

namespace VpnHood.Test;

internal class TestAppProvider : IAppProvider
{
public TestAppProvider(TestDeviceOptions? testDeviceOptions, Uri? updateInfoUrl = null)
{
UpdateInfoUrl = updateInfoUrl;
Device = TestHelper.CreateDevice(testDeviceOptions);
UpdateInfoUrl = updateInfoUrl;
}

public IDevice Device { get; }
public bool IsLogToConsoleSupported => true;
public Uri? AdditionalUiUrl => null;
public Uri? UpdateInfoUrl { get; }
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

// ReSharper disable UnusedMember.Local

#nullable enable
namespace VpnHood.Test;

public class TestEmbedIoAccessManager : IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,20 +402,21 @@ public static AppOptions CreateClientAppOptions()
{
var appOptions = new AppOptions
{
AppDataPath = Path.Combine(WorkingPath, "AppData_" + Guid.NewGuid()),
AppDataFolderPath = Path.Combine(WorkingPath, "AppData_" + Guid.NewGuid()),
SessionTimeout = TimeSpan.FromSeconds(2),
IsLogToConsoleSupported = true,
LoadCountryIpGroups = false,
};
return appOptions;
}

public static VpnHoodApp CreateClientApp(TestDeviceOptions? deviceOptions = default, AppOptions? appOptions = default)
public static VpnHoodApp CreateClientApp(TestDeviceOptions? deviceOptions = default, AppOptions? appOptions = default,
Uri? updateInfoUrl = default)
{
//create app
appOptions ??= CreateClientAppOptions();

var clientApp = VpnHoodApp.Init(new TestAppProvider(deviceOptions), appOptions);
var testAppProvider = new TestAppProvider(deviceOptions, updateInfoUrl);
var clientApp = VpnHoodApp.Init(testAppProvider, appOptions);
clientApp.Diagnoser.HttpTimeout = 2000;
clientApp.Diagnoser.NsTimeout = 2000;
clientApp.UserSettings.PacketCaptureIncludeIpRanges = TestIpAddresses.Select(x => new IpRange(x)).ToArray();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ private static void SetNewRelease(Version version, DateTime releaseDate, TimeSpa
public async Task Remote_is_unknown_if_remote_is_unreachable()
{
var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = new Uri("https://localhost:39999");
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: new Uri("https://localhost:39999"));

await Task.Delay(1000);
await VhTestUtil.AssertEqualsWait(VersionStatus.Unknown, () => app.VersionStatus);
Expand All @@ -46,8 +45,7 @@ public async Task Current_is_latest()
SetNewRelease(CurrentAppVersion, DateTime.UtcNow, TimeSpan.Zero);

var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);

await VhTestUtil.AssertEqualsWait(VersionStatus.Latest, () => app.VersionStatus);
}
Expand All @@ -59,8 +57,7 @@ public async Task Current_is_deprecated()
TimeSpan.Zero, CurrentAppVersion);

var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);

await VhTestUtil.AssertEqualsWait(VersionStatus.Deprecated, () => app.VersionStatus);
}
Expand All @@ -72,9 +69,8 @@ public async Task Current_is_old_by_job()

// create client
var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
appOptions.UpdateCheckerInterval = TimeSpan.FromMilliseconds(500);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);

// version should be latest
await VhTestUtil.AssertEqualsWait(VersionStatus.Latest, () => app.VersionStatus);
Expand All @@ -92,9 +88,8 @@ public async Task Current_is_old_but_wait_for_notification_delay()
DateTime.UtcNow, TimeSpan.FromSeconds(2));

var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
appOptions.UpdateCheckerInterval= TimeSpan.FromMilliseconds(500);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);

await VhTestUtil.AssertEqualsWait(VersionStatus.Latest, () => app.VersionStatus);
await VhTestUtil.AssertEqualsWait(VersionStatus.Old, () => app.VersionStatus);
Expand All @@ -108,8 +103,7 @@ public async Task Current_is_old_before_connect_to_vpn()
DateTime.UtcNow, TimeSpan.Zero);

var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);

await VhTestUtil.AssertEqualsWait(VersionStatus.Old, () => app.VersionStatus);
}
Expand All @@ -126,8 +120,7 @@ public async Task Current_is_old_after_connect_to_vpn()

// create client app
var appOptions = TestHelper.CreateClientAppOptions();
appOptions.UpdateInfoUrl = TestHelper.WebServer.FileHttpUrl1;
await using var app = TestHelper.CreateClientApp(appOptions: appOptions);
await using var app = TestHelper.CreateClientApp(appOptions: appOptions, updateInfoUrl: TestHelper.WebServer.FileHttpUrl1);
var clientProfile = app.ClientProfileStore.AddAccessKey(token.ToAccessKey());

await Task.Delay(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public async Task Save_load_clientProfiles()
await app.DisposeAsync();

var appOptions = TestHelper.CreateClientAppOptions();
appOptions.AppDataPath = app.AppDataFolderPath;
appOptions.AppDataFolderPath = app.AppDataFolderPath;
await using var app2 = TestHelper.CreateClientApp(appOptions: appOptions);
Assert.AreEqual(clientProfiles.Length, app2.ClientProfileStore.ClientProfiles.Length,
"ClientProfiles count are not same!");
Expand Down Expand Up @@ -497,7 +497,7 @@ public async Task State_Connected_Disconnected_successfully()
await using var app = TestHelper.CreateClientApp();
var clientProfile = app.ClientProfileStore.AddAccessKey(token.ToAccessKey());

var _ = app.Connect(clientProfile.ClientProfileId);
_ = app.Connect(clientProfile.ClientProfileId);
await TestHelper.WaitForClientStateAsync(app, AppConnectionState.Connected);

// get data through tunnel
Expand Down Expand Up @@ -543,7 +543,7 @@ public async Task Get_token_from_tokenLink()
await using var app = TestHelper.CreateClientApp();
var clientProfile = app.ClientProfileStore.AddAccessKey(token1.ToAccessKey());
app.ClientProfileStore.UpdateTokenFromUrl(token1).Wait();
var _ = app.Connect(clientProfile.ClientProfileId);
_ = app.Connect(clientProfile.ClientProfileId);
await TestHelper.WaitForClientStateAsync(app, AppConnectionState.Connected);
Assert.AreEqual(AppConnectionState.Connected, app.State.ConnectionState);
Assert.IsTrue(isTokenRetrieved);
Expand Down
Loading

0 comments on commit 4c75651

Please sign in to comment.