Skip to content

v0.3.0: GetConfig, validation improvements, CLI tests#3

Merged
github-actions[bot] merged 3 commits intomainfrom
dev
May 5, 2026
Merged

v0.3.0: GetConfig, validation improvements, CLI tests#3
github-actions[bot] merged 3 commits intomainfrom
dev

Conversation

@mar0ls
Copy link
Copy Markdown
Owner

@mar0ls mar0ls commented May 5, 2026

Changes

  • Added GetConfig() / GetConfigContext() — returns full per-protocol ProxyConfig
  • Implemented GetGlobalConfig on all platforms (macOS, Linux, Windows, stub)
  • Improved validation error messages with context
  • Added CLI smoke tests (cmd/sysproxy/main_test.go)
  • Added TestGetConfig_* and TestParseNSProxyOutput unit tests
  • Fixed CI: removed unused nolint directive on Linux
  • Fixed CI: coverprofile incompatible with Windows PowerShell
  • Fixed CI: .exe extension for test binary on Windows

mar0ls added 3 commits May 5, 2026 16:19
- backend.go: globalBackend interface + activeBackend; platform adapters
  register via init(), tests swap via useMockBackend
- mock_test.go: mockBackend test double for all backend methods
- GetConfig / GetConfigContext: per-protocol proxy read (HTTP/HTTPS/SOCKS/NoProxy)
  implemented on macOS (networksetup), Linux (gsettings), Windows (registry)
- validate.go: specific error messages (missing scheme/host, port out of range)
- cmd/sysproxy: CLI with set/get/unset/pac/check/version, --scope, --json,
  --timeout, exit codes 0/1/2
- internal/buildinfo: version/commit/date injected via ldflags
Copilot AI review requested due to automatic review settings May 5, 2026 14:32
@github-actions github-actions Bot merged commit 4b0f4f4 into main May 5, 2026
25 checks passed
@codecov-commenter
Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares the v0.3.0 release by extending the core proxy-management library with GetConfig/GetConfigContext, refactoring platform-specific global operations behind a backend interface, and adding a new cmd/sysproxy CLI plus supporting tests/docs/build updates.

Changes:

  • Added backend-based global proxy operations and exposed GetConfig / GetConfigContext for per-protocol reads.
  • Introduced a standalone sysproxy CLI, build metadata support, Makefile targets, and CI artifact/coverage updates.
  • Expanded tests and documentation around validation, CLI behavior, per-platform parsing, and new APIs.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
validate.go Refines proxy/PAC validation errors.
sysproxy.go Adds ProxyScope.String, GetConfig, and backend dispatch.
sysproxy_windows.go Implements Windows GetGlobalConfig and backend registration.
sysproxy_test.go Adds mock-backend coverage for new public API paths.
sysproxy_other.go Adds unsupported-platform backend stub.
sysproxy_linux.go Implements Linux GetGlobalConfig and backend registration.
sysproxy_darwin.go Implements macOS GetGlobalConfig, parsing helper, and backend registration.
sysproxy_darwin_test.go Adds macOS parser unit tests.
README.md Documents GetConfig, CLI usage, badges, and support matrix updates.
rcfile_unix_test.go Adds Unix ScopeUser/rcfile tests.
mock_test.go Introduces backend mock helper for tests.
Makefile Adds CLI/build/test/lint/dist targets and build metadata flags.
logger.go Clarifies logger concurrency note.
internal/buildinfo/buildinfo.go Adds build metadata summary helper for CLI output.
cmd/sysproxy/main.go Adds the new CLI entrypoint and command handling.
cmd/sysproxy/main_test.go Adds CLI smoke/integration-style tests.
check_test.go Loosens validation-error assertion for updated messages.
backend.go Defines the global backend interface and active backend handle.
appconfig.go Expands cancellation behavior documentation.
.golangci.yml Adjusts lint configuration and gosec exclusions.
.gitignore Ignores new generated output paths.
.github/workflows/test.yml Expands matrix testing, coverage upload, and CLI artifact builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/sysproxy/main.go
Comment on lines +135 to +141
if err != nil {
if jsonOut {
printJSON(map[string]any{"error": "proxy not set"})
} else {
fmt.Fprintln(os.Stderr, "proxy not set")
}
os.Exit(2)
Comment thread cmd/sysproxy/main.go
Comment on lines +61 to +79
for i := 0; i < len(args); i++ {
switch args[i] {
case "--scope":
i++
if i >= len(args) {
die("--scope requires a value: shell|user|global")
}
scopeStr = args[i]
case "--json":
jsonOut = true
case "--timeout":
i++
if i >= len(args) {
die("--timeout requires a duration value, e.g. 5s")
}
timeoutStr = args[i]
default:
positional = append(positional, args[i])
}
Comment thread sysproxy_darwin.go
Comment on lines +92 to +103
flag string
dest *string
}{
{"-getwebproxy", &cfg.HTTP},
{"-getsecurewebproxy", &cfg.HTTPS},
{"-getsocksfirewallproxy", &cfg.SOCKS},
} {
out, err := exec.CommandContext(ctx, "networksetup", q.flag, svc).Output() //nolint:gosec
if err == nil {
h, p, ok := parseNSProxyOutput(string(out))
if ok && h != "" && p != "0" {
*q.dest = "http://" + h + ":" + p
Comment thread sysproxy_windows.go
if !strings.Contains(server, "=") {
cfg.HTTP = "http://" + server
cfg.HTTPS = "http://" + server
cfg.SOCKS = "socks5://" + server
Comment thread sysproxy_windows.go
Comment on lines +176 to +177
out, _ = exec.CommandContext(normalizeContext(ctx), "reg", "query", regKey, "/v", "ProxyOverride").Output()
cfg.NoProxy = extractRegValue(string(out), "ProxyOverride")
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build -o dist/${{ matrix.binary }} ./cmd/sysproxy
CGO_ENABLED: '0'
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build -o dist/${{ matrix.binary }} ./cmd/sysproxy
Comment thread cmd/sysproxy/main_test.go
}
}

// TestVersionJSON checks --json flag on version (unsupported; just ensure no panic).
Comment thread cmd/sysproxy/main.go
Comment on lines +82 to +90
scope, err := parseScope(scopeStr)
if err != nil {
die(err.Error())
}

timeout, err := time.ParseDuration(timeoutStr)
if err != nil {
die("invalid --timeout value: " + err.Error())
}
Comment thread .golangci.yml
Comment on lines 16 to +19
gosec:
excludes:
- G705
- G101 # false positive on example URLs in usage strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants