mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-07-07 01:24:06 +00:00
Update windows_task.ps1
This commit is contained in:
committed by
GitHub
parent
8a5e1d2d69
commit
315be97354
@ -1,5 +1,17 @@
|
|||||||
|
# Path to log file
|
||||||
|
$logFile = "$HOME\shadowsocks-rust\sslocal_log.txt"
|
||||||
|
|
||||||
|
# Function to log messages
|
||||||
|
function Log-Message {
|
||||||
|
param (
|
||||||
|
[string]$message
|
||||||
|
)
|
||||||
|
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||||
|
"$timestamp - $message" | Out-File -Append -FilePath $logFile
|
||||||
|
}
|
||||||
|
|
||||||
if ($args.Count -lt 2) {
|
if ($args.Count -lt 2) {
|
||||||
Write-Host "Usage: script.ps1 <url> <sslocal_path>"
|
Log-Message "Usage: script.ps1 <url> <sslocal_path>"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +40,9 @@ function Start-SSLocal {
|
|||||||
# Kill any existing sslocal process
|
# Kill any existing sslocal process
|
||||||
Get-Process sslocal -ErrorAction SilentlyContinue | Stop-Process -Force
|
Get-Process sslocal -ErrorAction SilentlyContinue | Stop-Process -Force
|
||||||
|
|
||||||
|
# Log the sslocal restart
|
||||||
|
Log-Message "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"
|
||||||
}
|
}
|
||||||
@ -45,16 +60,21 @@ while ($true) {
|
|||||||
$server = $json.server
|
$server = $json.server
|
||||||
$serverPort = $json.server_port
|
$serverPort = $json.server_port
|
||||||
|
|
||||||
|
# Log current password and server information
|
||||||
|
Log-Message "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
|
||||||
Write-Host "Password changed, restarting sslocal."
|
Log-Message "Password changed, restarting sslocal."
|
||||||
|
} else {
|
||||||
|
Log-Message "Password has not changed."
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Error occurred: $_"
|
Log-Message "Error occurred: $_"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wait for the next check
|
# Wait for the next check
|
||||||
|
Reference in New Issue
Block a user