jakub holý

building the right thing, building it right, fast

OS X: Using scutils to discover whether/what a web proxy is in use

2015-05-07 11:10:54General

When looking for ways to discover whether a proxy is being used by OS X, you will be typically pointed to

networksetup -getwebproxy

However that does not always work - for example when using "Auto Proxy Discovery" and/or "Automatic Proxy Configuration" with a proxy.pac file. scutils --proxy seems to detect all these cases (though it cannot give you the proxy when using auto config, I suppose):


# With "Automatic Proxy Configuration"
$ scutil --proxy
<dictionary> {
  ExceptionsList : <array> {
    0 : *.local
    1 : 169.254/16
  }
  FTPPassive : 1
  ProxyAutoConfigEnable : 1
  ProxyAutoConfigURLString : http://proxconf.example.com/proxy.pac
}

# With "Auto Proxy Discovery" $ scutil --proxy <dictionary> { ExceptionsList : <array> { 0 : *.local 1 : 169.254/16 } FTPPassive : 1 ProxyAutoConfigEnable : 1 ProxyAutoConfigURLString : http://112.43.172.105/proxy.pac ProxyAutoDiscoveryEnable : 1 }

# With manual HTTP proxy configuration $ scutil --proxy <dictionary> { ExceptionsList : <array> { 0 : *.local 1 : 169.254/16 } FTPPassive : 1 HTTPEnable : 1 HTTPPort : 8888 HTTPProxy : http://example.com }

# No proxy $ scutil --proxy <dictionary> { ExceptionsList : <array> { 0 : *.local 1 : 169.254/16 } FTPPassive : 1 }


See Alex Argo's proxysetup.sh Gist for proxy detection and proxy env variable configuration.