Currently, the PAC URL is read from the system settings before downloading the PAC file. This is done by calling out to a subprocess (gsettings or networksetup on Linux and macOS - but for Windows this is not yet implemented) and reading stdout. It takes around 50-60ms on my M1 MacBook Pro, which is too slow to do on every outgoing request. But if we don't check this value frequently, the configured PAC URL can change and Alpaca won't notice.
We can make the findPACURL() function faster by calling the native system libraries from Cgo. This will then allow us to check the PAC URL before Alpaca forwards each outgoing request.
Currently, the PAC URL is read from the system settings before downloading the PAC file. This is done by calling out to a subprocess (
gsettings
ornetworksetup
on Linux and macOS - but for Windows this is not yet implemented) and reading stdout. It takes around 50-60ms on my M1 MacBook Pro, which is too slow to do on every outgoing request. But if we don't check this value frequently, the configured PAC URL can change and Alpaca won't notice.We can make the
findPACURL()
function faster by calling the native system libraries from Cgo. This will then allow us to check the PAC URL before Alpaca forwards each outgoing request.Linux (GNOME)
https://wiki.gnome.org/DevGnomeOrg/Gnome3PortingGuide/ProxyConfiguration https://docs.gtk.org/gio/class.Settings.html
macOS
https://developer.apple.com/documentation/systemconfiguration/1517088-scdynamicstorecopyproxies
Windows
https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpgetieproxyconfigforcurrentuser