Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
windows-vm
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pem
windows-vm
Commits
b9955b1a
Commit
b9955b1a
authored
Apr 28, 2025
by
César Galvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: web server for PAC working
parent
6d6c1969
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
0 deletions
+41
-0
Vagrantfile
Vagrantfile
+2
-0
proxy.pac
src/config/proxy.pac
+9
-0
PacScheduledTask.ps1
src/scripts/ps/PacScheduledTask.ps1
+12
-0
PacSetup.ps1
src/scripts/ps/PacSetup.ps1
+18
-0
No files found.
Vagrantfile
View file @
b9955b1a
...
@@ -32,5 +32,7 @@ Vagrant.configure("2") do |config|
...
@@ -32,5 +32,7 @@ Vagrant.configure("2") do |config|
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/ChocolateyInstall.ps1"
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/ChocolateyInstall.ps1"
## Install Chocolatey packages
## Install Chocolatey packages
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/ChocolateyInstallPackages.ps1"
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/ChocolateyInstallPackages.ps1"
## Set up PAC
config
.
vm
.
provision
"shell"
,
path:
"src/scripts/ps/PacScheduledTask.ps1"
end
end
src/config/proxy.pac
0 → 100644
View file @
b9955b1a
function FindProxyForURL(url, host) {
// Only use proxy if the destination IP is 192.168.11.0/24
if (isInNet(host, "192.168.11.0", "255.255.255.0")) {
return "PROXY 192.168.56.10:3128";
}
// For everything else, connect directly
return "DIRECT";
}
\ No newline at end of file
src/scripts/ps/PacScheduledTask.ps1
0 → 100644
View file @
b9955b1a
# 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
src/scripts/ps/PacSetup.ps1
0 → 100644
View file @
b9955b1a
# PAC (Proxy Auto-Config) setup
# Create small web server
$listener
=
[
System.Net.HttpListener]::new
()
$listener
.Prefixes.Add
(
"http://*:8080/"
)
$listener
.Start
()
Write-Host
"Serving proxy.pac on http://localhost:8080/proxy.pac"
while
(
$listener
.IsListening
)
{
$context
=
$listener
.GetContext
()
$response
=
$context
.Response
$buffer
=
[
System.IO.File]::ReadAllBytes
(
"C:\vagrant\src\config\proxy.pac"
)
$response
.ContentLength64
=
$buffer
.Length
$response
.OutputStream.Write
(
$buffer
, 0,
$buffer
.Length
)
$response
.OutputStream.Close
()
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment