Commit ef9f48c1 by César Galvis

feat: pac working

parent 617c5b9b
......@@ -35,7 +35,7 @@ Vagrant.configure("2") do |config|
## Set up proxy
config.vm.provision "file", source: "./src/config/squid-proxy.conf", destination: "C:/Squid/etc/squid/squid.conf"
## Set up PAC
config.vm.provision "shell", path: "src/scripts/ps/PacScheduledTask.ps1"
config.vm.provision "shell", path: "src/scripts/ps/PacSetup.ps1"
## Restart machine
config.vm.provision :shell do |shell|
shell.privileged = true
......
# PAC (Proxy Auto-Config) scheduled task setup
# Set Execution Policy
Set-ExecutionPolicy Bypass -Force
# Variables
$taskName = "StartPACServer"
$proxyScriptPath = "C:\\vagrant\src\scripts\ps\PacServer.ps1"
# Check if the scheduled task already exists
if (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue) {
Write-Host "Scheduled Task '$taskName' already exists. Skipping creation."
}
else {
Write-Host "Scheduled Task '$taskName' does not exist. Creating..."
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File $proxyScriptPath"
$Trigger = New-ScheduledTaskTrigger -AtStartup
$Principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName $taskName -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings
}
# Open port 8080 in Windows Firewall if not already open
if (-not (Get-NetFirewallRule -DisplayName "Allow Proxy PAC Server" -ErrorAction SilentlyContinue)) {
New-NetFirewallRule -DisplayName "Allow Proxy PAC Server" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow
Write-Host "Firewall rule created to allow inbound connections on port 8080."
}
else {
Write-Host "Firewall rule 'Allow Proxy PAC Server' already exists. Skipping creation."
}
\ No newline at end of file
# PAC (Proxy Auto-Config) scheduled task setup
# Bypass policy
Set-ExecutionPolicy Bypass -Force
# Create scheduled task
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File C:\\vagrant\src\scripts\ps\PacSetup.ps1"
$Trigger = New-ScheduledTaskTrigger -AtStartup
$Principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "StartPACServer" -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment