feat: add windows helper scripts
This commit is contained in:
26
scripts/windows/helper.ps1
Normal file
26
scripts/windows/helper.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
Import-Module (Join-Path $ScriptDir "VpnProxy.Windows.psm1") -Force
|
||||
|
||||
try {
|
||||
$raw = [Console]::In.ReadToEnd()
|
||||
if ([string]::IsNullOrWhiteSpace($raw)) {
|
||||
throw "Missing JSON input"
|
||||
}
|
||||
|
||||
$request = $raw | ConvertFrom-Json
|
||||
$payload = if ($request.PSObject.Properties.Name -contains "payload") { $request.payload } else { @{} }
|
||||
$result = Invoke-VpnProxyAction -Action ([string]$request.action) -Payload $payload
|
||||
$result | ConvertTo-Json -Depth 30 -Compress
|
||||
exit 0
|
||||
} catch {
|
||||
$errorResult = [ordered]@{
|
||||
success = $false
|
||||
action = "error"
|
||||
error = $_.Exception.Message
|
||||
}
|
||||
$errorResult | ConvertTo-Json -Depth 10 -Compress
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user