Update windows_task.ps1

This commit is contained in:
Alexandr Bogomyakov
2024-09-28 20:44:08 +03:00
committed by GitHub
parent e41febe061
commit dceb07137a

View File

@ -1,5 +1,5 @@
if ($args.Count -lt 2) { if ($args.Count -lt 2) {
Log-Message "Usage: windows_task.ps1 <url> <sslocal_path> <comment>" Write-Host "Usage: windows_task.ps1 <url> <sslocal_path> <comment>"
exit 1 exit 1
} }
@ -29,7 +29,7 @@ function Start-SSLocal {
Get-Process sslocal -ErrorAction SilentlyContinue | Stop-Process -Force Get-Process sslocal -ErrorAction SilentlyContinue | Stop-Process -Force
# Log the sslocal restart # Log the sslocal restart
Log-Message "Starting sslocal with method: $method, server: $server, port: $serverPort" Write-Host "Starting sslocal with method: $method, server: $server, port: $serverPort"
# Start sslocal with the provided arguments # Start sslocal with the provided arguments
Start-Process -NoNewWindow -FilePath $sslocalPath -ArgumentList "--local-addr ${localAddr}:${localPort} --server-url $ssUrl" Start-Process -NoNewWindow -FilePath $sslocalPath -ArgumentList "--local-addr ${localAddr}:${localPort} --server-url $ssUrl"
@ -49,20 +49,20 @@ while ($true) {
$serverPort = $json.server_port $serverPort = $json.server_port
# Log current password and server information # Log current password and server information
Log-Message "Checking server: $server, port: $serverPort" Write-Host "Checking server: $server, port: $serverPort"
# Check if the password has changed # Check if the password has changed
if ($password -ne $previousPassword) { if ($password -ne $previousPassword) {
# Start/restart sslocal # Start/restart sslocal
Start-SSLocal -method $method -password $password -server $server -serverPort $serverPort Start-SSLocal -method $method -password $password -server $server -serverPort $serverPort
$previousPassword = $password $previousPassword = $password
Log-Message "Password changed, restarting sslocal." Write-Host "Password changed, restarting sslocal."
} else { } else {
Log-Message "Password has not changed." Write-Host "Password has not changed."
} }
} catch { } catch {
Log-Message "Error occurred: $_" Write-Host "Error occurred: $_"
} }
# Wait for the next check # Wait for the next check