Documentation
¶
Overview ¶
Package sysproxy provides OS system HTTP(S) proxy control and ownership helpers.
Platform backends implement unexported get/enable/disable:
- Windows: WinINET registry (HKCU or console-user hive under LocalSystem)
- macOS: networksetup for web/secure-web proxies
- Linux: GNOME gsettings (best effort)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enable ¶
Enable turns on the system proxy for host:port. Blank host defaults to 127.0.0.1. Port must be in 1..65535.
func IsForeign ¶
IsForeign reports whether observed system proxy is enabled to a non-empty server that is not owned by the given target.
func IsOwned ¶
IsOwned reports whether observed system proxy is enabled and matches target. target is the expected server string (e.g. from NormalizeServer).
func NormalizeServer ¶
NormalizeServer formats host and port as a proxy server string (net.JoinHostPort).
Types ¶
type FakeBackend ¶
type FakeBackend struct {
State State
GetErr error
EnableErr error
DisableErr error
GetCalls int
EnableCalls int
DisableCalls int
LastEnableHost string
LastEnablePort int
}
FakeBackend is an in-memory Backend for tests. It records call counts and last args.
func (*FakeBackend) Disable ¶
func (f *FakeBackend) Disable() error
Disable records the call, clears Enabled, or returns DisableErr.
func (*FakeBackend) Enable ¶
func (f *FakeBackend) Enable(host string, port int) error
Enable records host/port, sets State to enabled, or returns EnableErr.
func (*FakeBackend) Get ¶
func (f *FakeBackend) Get() (State, error)
Get returns the fake state or GetErr.
type PlatformBackend ¶
type PlatformBackend struct{}
PlatformBackend adapts package-level Get/Enable/Disable to Backend.
func (PlatformBackend) Disable ¶
func (PlatformBackend) Disable() error
Disable turns off the system proxy via the platform backend.
func (PlatformBackend) Enable ¶
func (PlatformBackend) Enable(host string, port int) error
Enable turns on the system proxy for host:port.
func (PlatformBackend) Get ¶
func (PlatformBackend) Get() (State, error)
Get returns the current system proxy state from the platform backend.