net/interfaces: add State.PAC field, populate it on Windows

Not used for anything yet (except logging), but populate the current
proxy autoconfig PAC URL in Interfaces.State.

A future change will do things based on it.
This commit is contained in:
Brad Fitzpatrick
2020-10-01 15:33:37 -07:00
parent b5a3850d29
commit 8051ecff55
2 changed files with 42 additions and 0 deletions

View File

@@ -177,6 +177,9 @@ type State struct {
// HTTPProxy is the HTTP proxy to use.
HTTPProxy string
// PAC is the URL to the Proxy Autoconfig URL, if applicable.
PAC string
}
func (s *State) Equal(s2 *State) bool {
@@ -197,6 +200,9 @@ func (s *State) RemoveTailscaleInterfaces() {
}
}
// getPAC, if non-nil, returns the current PAC file URL.
var getPAC func() string
// GetState returns the state of all the current machine's network interfaces.
//
// It does not set the returned State.IsExpensive. The caller can populate that.
@@ -222,6 +228,9 @@ func GetState() (*State, error) {
if u, err := tshttpproxy.ProxyFromEnvironment(req); err == nil && u != nil {
s.HTTPProxy = u.String()
}
if getPAC != nil {
s.PAC = getPAC()
}
return s, nil
}