Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Feb 4, 2024
2 parents eb95dc8 + f281df7 commit 4f8432d
Show file tree
Hide file tree
Showing 213 changed files with 2,549 additions and 1,497 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v3.3.462
### Client
* Fix: Updating ServerTokenUrl from the server

* ### Server
* Fix: Updating ServerTokenUrl & ServerSecret from the server


# v3.3.454
### Client
* Update: New Access Token format
Expand All @@ -7,7 +15,7 @@
* Feature: Update server token URL from the server
* Feature: Android: Prompt for the update by Google Play if possible
* Feature: Android: Support opening (KEY) as VpnHood Key file
* Fix: Windows: Freeze network after auto-reconnect with muti-server
* Fix: Windows: Freeze network after auto-reconnect redirects to a new server
* Deprecate: Server ProtocolVersion 3 is deprecated and no longer supported

### Server
Expand Down
78 changes: 37 additions & 41 deletions Pub/Core/PublishAndroidApp.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
param(
[Parameter(Mandatory=$true)] [String]$projectDir,
[Parameter(Mandatory=$true)] [String]$packageFileTitle,
[switch]$apk)
[Parameter(Mandatory=$true)] [String]$packageId,
[Parameter(Mandatory=$true)] [String]$distribution,
[Parameter(Mandatory=$true)] [String]$background,
[switch]$apk, [switch]$aab)

. "$PSScriptRoot/Common.ps1"

Expand All @@ -14,12 +17,13 @@ Write-Host "*** Publishing $projectFile ..." -BackgroundColor Blue -ForegroundCo
UpdateProjectVersion $projectFile;

# prepare module folders
$moduleDir = "$packagesRootDir/$packageFileTitle/android";
$moduleDirLatest = "$packagesRootDirLatest/$packageFileTitle/android";
$moduleDir = "$packagesRootDir/$packageFileTitle/android-$distribution";
$moduleDirLatest = "$packagesRootDirLatest/$packageFileTitle/android-$distribution";
PrepareModuleFolder $moduleDir $moduleDirLatest;

$module_infoFile = "$moduleDir/$packageFileTitle-android-web.json";
$module_packageFile = "$moduleDir/$packageFileTitle-android-web.apk";
$packageExt = if ($apk) { "apk" } else { "aab" };
$module_infoFile = "$moduleDir/$packageFileTitle-android-$distribution.json";
$module_packageFile = "$moduleDir/$packageFileTitle-android-$distribution.$packageExt";

# Calcualted Path
$module_infoFileName = $(Split-Path "$module_infoFile" -leaf);
Expand All @@ -34,23 +38,22 @@ $manifestFile = Join-Path $projectDir "Properties/AndroidManifest.xml";
$appIconXml = Join-Path $projectDir "Resources/mipmap-anydpi-v26/appicon.xml";
$appIconXmlDoc = [xml](Get-Content $appIconXml);
$appIconXmlNode = $appIconXmlDoc.selectSingleNode("adaptive-icon/background");
$packageId = ([xml](Get-Content $projectFile)).SelectSingleNode("Project/PropertyGroup/ApplicationId").InnerText;

Write-Host;
Write-Host "*** Creating $module_packageFileName ..." -BackgroundColor Blue -ForegroundColor White;

# set app icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background_dev");
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/$background");
$appIconXmlDoc.save($appIconXml);

# apk
# ------------- aab
if ($apk)
{
Write-Host;
Write-Host "*** Creating Android APK ..." -BackgroundColor Blue -ForegroundColor White;

$outputPath = Join-Path $projectDir "bin/ReleaseApk/";
$outputPath = Join-Path $projectDir "bin/Release-$distribution/";
$signedPacakgeFile = Join-Path $outputPath "$packageId-Signed.apk"

if (-not $noclean) { & $msbuild $projectFile /p:Configuration=Release /t:Clean /p:OutputPath=$outputPath /verbosity:$msverbosity; }
& $msbuild $projectFile /p:Configuration=Release /t:SignAndroidPackage /p:Version=$versionParam /p:OutputPath=$outputPath /p:AndroidPackageFormat="apk" /verbosity:$msverbosity `
if (-not $noclean) { & $msbuild $projectFile /p:Configuration=Release /t:Clean /p:OutputPath=$outputPath /verbosity:$msverbosity; }
dotnet build $projectFile -c Release /t:SignAndroidPackage /p:Version=$versionParam /p:OutputPath=$outputPath /p:AndroidPackageFormat="apk" /verbosity:$msverbosity `
/p:AndroidSigningKeyStore=$keystore /p:AndroidSigningKeyAlias=$keystoreAlias /p:AndroidSigningStorePass=$keystorePass `
/p:ApplicationId=$packageId `
/p:JarsignerTimestampAuthorityUrl="https://freetsa.org/tsr";
Expand All @@ -67,47 +70,40 @@ if ($apk)
NotificationDelay = "03.00:00:00";
};
$json | ConvertTo-Json | Out-File "$module_infoFile" -Encoding ASCII;

Copy-Item -path $signedPacakgeFile -Destination "$moduleDir/$module_packageFileName" -Force
if ($isLatest)
{
Copy-Item -path "$moduleDir/*" -Destination "$moduleDirLatest/" -Force -Recurse;
}
}

# ------------- aab
Write-Host;
Write-Host "*** Creating Android AAB ..." -BackgroundColor Blue -ForegroundColor White;
else
{
# set app icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background");
$appIconXmlDoc.save($appIconXml);

# set app icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background");
$appIconXmlDoc.save($appIconXml);
# update variables
$outputPath = Join-Path $projectDir "bin/ReleaseAab/";
$signedPacakgeFile = Join-Path "$outputPath" "$packageId-Signed.aab"
$module_packageFile = "$moduleDir/$packageFileTitle-android.aab";
$module_packageFileName = $(Split-Path "$module_packageFile" -leaf);

# update variables
$packageId = $packageId.replace(".web", "");
$outputPath = Join-Path $projectDir "bin/ReleaseAab/";
$signedPacakgeFile = Join-Path "$outputPath" "$packageId-Signed.aab"
$module_packageFile = "$moduleDir/$packageFileTitle-android.aab";
$module_packageFileName = $(Split-Path "$module_packageFile" -leaf);
if (-not $noclean) { & $msbuild $projectFile /p:Configuration=Release /t:Clean /p:OutputPath=$outputPath /verbosity:$msverbosity; }
dotnet build $projectFile /p:Configuration=Release /p:Version=$versionParam /p:OutputPath=$outputPath /t:SignAndroidPackage /p:ArchiveOnBuild=true /verbosity:$msverbosity `
/p:AndroidSigningKeyStore=$keystore /p:AndroidSigningKeyAlias=$keystoreAlias /p:AndroidSigningStorePass=$keystorePass `
/p:ApplicationId=$packageId `
/p:DefineConstants=GOOGLE_PLAY `
/p:AndroidSigningKeyPass=$keystorePass /p:AndroidKeyStore=True;

if (-not $noclean) { & $msbuild $projectFile /p:Configuration=Release /t:Clean /p:OutputPath=$outputPath /verbosity:$msverbosity; }
& $msbuild $projectFile /p:Configuration=Release /p:Version=$versionParam /p:OutputPath=$outputPath /t:SignAndroidPackage /p:ArchiveOnBuild=true /verbosity:$msverbosity `
/p:AndroidSigningKeyStore=$keystore /p:AndroidSigningKeyAlias=$keystoreAlias /p:AndroidSigningStorePass=$keystorePass `
/p:ApplicationId=$packageId `
/p:DefineConstants=ANDROID_AAB `
/p:AndroidSigningKeyPass=$keystorePass /p:AndroidKeyStore=True;

# set app icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background_dev");
}

# restore standard icon
$appIconXmlNode.SetAttribute("android:drawable", "@mipmap/appicon_background_web");
$appIconXmlDoc.save($appIconXml);

#####
# copy to solution ouput
Copy-Item -path $signedPacakgeFile -Destination "$moduleDir/$module_packageFileName" -Force
if ($isLatest)
{
Copy-Item -path $signedPacakgeFile -Destination "$moduleDirLatest/$module_packageFileName" -Force -Recurse;
Copy-Item -path "$moduleGooglePlayLastestDir/*" -Destination "$moduleDirLatest/" -Force -Recurse;
}

# report version
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": "3.3.454",
"BumpTime": "2024-01-18T10:59:43.8825171Z",
"Version": "3.3.462",
"BumpTime": "2024-02-04T11:13:50.9100381Z",
"Prerelease": false,
"DeprecatedVersion": "3.0.416"
}
9 changes: 7 additions & 2 deletions Pub/PublishApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Remove-Item "$packagesRootDir/ReleaseNote.txt" -ErrorAction Ignore;
& "$solutionDir/VpnHood.Client.Device.WinDivert/_publish.ps1";
& "$solutionDir/VpnHood.Client.App/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.WebServer/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Store/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.Common/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.GooglePlay/_publish.ps1";
& "$solutionDir/VpnHood.Client.App.Android.GooglePlay.Core/_publish.ps1";

& "$solutionDir/VpnHood.Server/_publish.ps1";
& "$solutionDir/VpnHood.Server.Access/_publish.ps1";
Expand All @@ -55,13 +59,14 @@ if ($server)
# publish android
if ($android)
{
& "$solutionDir/VpnHood.Client.App.Android/_publish.ps1" -apk;
& "$solutionDir/VpnHood.Client.App.Android/_publish_aab.ps1";
& "$solutionDir/VpnHood.Client.App.Android/_publish_apk.ps1";
}

# publish android
if ($androidConnect)
{
& "$solutionDir/VpnHood.Client.App.Android.connect/_publish.ps1" -apk;
& "$solutionDir/VpnHood.Client.App.Android.connect/_publish_aab.ps1";
}


Expand Down
4 changes: 2 additions & 2 deletions Pub/PublishToGitHub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ gh release create "$versionTag" `
--title "$versionTag" `
(&{if($prerelease) {"--prerelease"} else {"--latest"}}) `
-F $releaseRootDir/ReleaseNote.txt `
$releaseRootDir/$packageClientDirName/android/VpnHoodClient-android$androidStore.apk `
$releaseRootDir/$packageClientDirName/android/VpnHoodClient-android$androidStore.json `
$releaseRootDir/$packageClientDirName/android-web/VpnHoodClient-android-web.apk `
$releaseRootDir/$packageClientDirName/android-web/VpnHoodClient-android-web.json `
$releaseRootDir/$packageClientDirName/windows/VpnHoodClient-win-x64.msi `
$releaseRootDir/$packageClientDirName/windows/VpnHoodClient-win-x64.txt `
$releaseRootDir/$packageClientDirName/windows/VpnHoodClient-win-x64.json `
Expand Down
47 changes: 4 additions & 43 deletions Samples/VpnHood.Samples.SimpleClient.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using Android.Content;
using Android.Content.PM;
using Android.Net;
using Android.Runtime;

using VpnHood.Client.Device.Droid;
using VpnHood.Client.Device.Droid.Utils;
using VpnHood.Common;

// ReSharper disable StringLiteralTypo
namespace VpnHood.Client.App.Droid;

[Activity(Label = "@string/app_name", MainLauncher = true)]
// ReSharper disable once UnusedMember.Global
public class MainActivity : Activity
public class MainActivity : ActivityEvent
{
private const int RequestVpnPermission = 10;
private static readonly AndroidDevice Device = new();
private VpnHoodClient? _vpnHoodClient;
private Button _connectButton = default!;
Expand All @@ -24,9 +21,7 @@ public class MainActivity : Activity
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);

// manage VpnPermission
Device.OnRequestVpnPermission += Device_OnRequestVpnPermission;
Device.Prepare(this);

// Set our simple view
var linearLayout = new LinearLayout(this);
Expand Down Expand Up @@ -81,7 +76,6 @@ private async Task Disconnect()
_vpnHoodClient = null;
}


private void UpdateUi()
{
RunOnUiThread(() =>
Expand All @@ -104,37 +98,4 @@ private void UpdateUi()
}
});
}

private void Device_OnRequestVpnPermission(object? sender, EventArgs e)
{
var intent = VpnService.Prepare(this);
if (intent == null)
{
Device.VpnPermissionGranted();
}
else
{
StartActivityForResult(intent, RequestVpnPermission);
}
}

protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent? data)
{
if (requestCode == RequestVpnPermission && resultCode == Result.Ok)
Device.VpnPermissionGranted();
else
Device.VpnPermissionRejected();
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions,
[GeneratedEnum] Permission[] grantResults)
{
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

protected override void OnDestroy()
{
Device.OnRequestVpnPermission -= Device_OnRequestVpnPermission;
base.OnDestroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VpnHood.Client" Version="3.2.448" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="3.2.448" />
<PackageReference Include="VpnHood.Client" Version="3.3.456" />
<PackageReference Include="VpnHood.Client.Device.WinDivert" Version="3.3.456" />
</ItemGroup>

</Project>
15 changes: 0 additions & 15 deletions Tests/VpnHood.Test/TestAppProvider.cs

This file was deleted.

27 changes: 27 additions & 0 deletions Tests/VpnHood.Test/TestConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Net;
using VpnHood.Common.Converters;

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 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");
public static IPEndPoint TcpEndPoint2 => IPEndPoint.Parse("198.18.0.2:80");
public static IPEndPoint HttpsEndPoint1 => IPEndPoint.Parse("198.18.0.1:3030");
public static IPEndPoint HttpsEndPoint2 => IPEndPoint.Parse("198.18.0.2:3030");
public static IPEndPoint UdpV4EndPoint1 => IPEndPoint.Parse("198.18.10.1:63100");
public static IPEndPoint UdpV4EndPoint2 => IPEndPoint.Parse("198.18.10.2:63101");
public static IPEndPoint UdpV6EndPoint1 => IPEndPoint.Parse("[2001:4860:4866::2223]:63100");
public static IPEndPoint UdpV6EndPoint2 => IPEndPoint.Parse("[2001:4860:4866::2223]:63101");
public static IPAddress PingV4Address1 => IPAddress.Parse("198.18.20.1");
public static IPAddress PingV4Address2 => IPAddress.Parse("198.18.20.2");
public static IPAddress PingV6Address1 => IPAddress.Parse("2001:4860:4866::2200");
public static Uri InvalidUri => new("https://DBBC5764-D452-468F-8301-4B315507318F.zz");
public static IPAddress InvalidIp => IPAddress.Parse("198.18.255.1");
public static IPEndPoint InvalidEp => IPEndPointConverter.Parse("198.18.255.2:9999");
}
11 changes: 4 additions & 7 deletions Tests/VpnHood.Test/TestDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@

namespace VpnHood.Test;

internal class TestDevice : IDevice
internal class TestDevice(TestDeviceOptions? options = default) : IDevice
{
private readonly TestDeviceOptions _options;
public TestDevice(TestDeviceOptions? options = default)
{
_options = options ?? new TestDeviceOptions();
}
private readonly TestDeviceOptions _options = options ?? new TestDeviceOptions();

#pragma warning disable 0067
public event EventHandler? OnStartAsService;
#pragma warning restore 0067

public string OperatingSystemInfo =>
public string OsInfo =>
Environment.OSVersion + ", " + (Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit");

public bool IsExcludeAppsSupported => false;

public bool IsIncludeAppsSupported => false;
public bool IsLogToConsoleSupported => true;

public DeviceAppInfo[] InstalledApps => throw new NotSupportedException();

Expand Down
Loading

0 comments on commit 4f8432d

Please sign in to comment.