v2rayA/v2rayA · error

getwebproxy: %v

Error message

getwebproxy: %v

What it means

readServiceState queries the current proxy configuration of a macOS network service with networksetup -getwebproxy (and -getsecurewebproxy/-getsocksproxy). If the -getwebproxy invocation exits non-zero, the function returns this "getwebproxy: %v" error. Typically this happens when the service name is empty, invalid, or networksetup cannot run in the current session.

Source

Thrown at service/kernel/iptables/systemProxy_macos.go:104

	for _, line := range lines {
		line = strings.TrimSpace(line)
		if strings.HasPrefix(line, "Enabled:") {
			val := strings.TrimSpace(strings.TrimPrefix(line, "Enabled:"))
			enabled = val == "Yes"
		} else if strings.HasPrefix(line, "URL:") {
			url = strings.TrimSpace(strings.TrimPrefix(line, "URL:"))
		}
	}
	return
}

// readServiceState reads and returns the current proxy state for a given network service
func readServiceState(service string) (*macosServiceState, error) {
	state := &macosServiceState{}

	out, err := exec.Command("/usr/sbin/networksetup", "-getwebproxy", service).Output()
	if err != nil {
		return nil, fmt.Errorf("getwebproxy: %v", err)
	}
	state.webEnabled, state.webServer, state.webPort = parseProxyOutput(string(out))

	out, err = exec.Command("/usr/sbin/networksetup", "-getsecurewebproxy", service).Output()
	if err != nil {
		return nil, fmt.Errorf("getsecurewebproxy: %v", err)
	}
	state.secureWebEnabled, state.secureWebServer, state.secureWebPort = parseProxyOutput(string(out))

	out, err = exec.Command("/usr/sbin/networksetup", "-getsocksfirewallproxy", service).Output()
	if err != nil {
		return nil, fmt.Errorf("getsocksfirewallproxy: %v", err)
	}
	state.socksEnabled, state.socksServer, state.socksPort = parseProxyOutput(string(out))

	out, err = exec.Command("/usr/sbin/networksetup", "-getautoproxyurl", service).Output()
	if err != nil {
		return nil, fmt.Errorf("getautoproxyurl: %v", err)

View on GitHub (pinned to 71e5442fc5)

Solutions

  1. Check the wrapped error text: run networksetup -getwebproxy "<service>" manually to see networksetup's own message
  2. Validate the service name matches exactly what -listallnetworkservices printed (quoting/spaces matter)
  3. Run from an admin GUI session or with sudo when invoked over SSH
  4. Skip services that do not support web proxies instead of failing the whole status read

Example fix

// before
out, err := exec.Command("/usr/sbin/networksetup", "-getwebproxy", service).Output()
// after (caller-side guard)
if service == "" || strings.Contains(service, "*") { return nil, nil }
out, err := exec.Command("/usr/sbin/networksetup", "-getwebproxy", service).Output()
Defensive patterns

Strategy: try-catch

Validate before calling

out, err := exec.Command("/usr/sbin/networksetup", "-listallnetworkservices").Output()
if err != nil { return err }
valid := map[string]bool{}
for _, l := range strings.Split(string(out), "\n")[1:] {
    l = strings.TrimSpace(l)
    if l != "" && !strings.Contains(l, "*") { valid[l] = true }
}
if !valid[service] { return fmt.Errorf("unknown service %q", service) }

Try / catch

state, err := readServiceState(service)
if err != nil {
    log.Debugf("skipping %s: %v", service, err) // non-fatal for status aggregation
    return nil, nil
}

Prevention

When it happens

Trigger: Service names containing asterisks/disabled entries slipping through the filter; calling from a non-GUI session where networksetup errors out; a service name with characters networksetup rejects; networksetup missing from /usr/sbin.

Common situations: SSH/daemon execution of proxy status checks; macOS updates renaming services (e.g. "Wi-Fi" localized names); iterating all services where one specialized service (VPN/PPP) fails the -getwebproxy query.

Related errors


AI-assisted analysis of v2rayA/v2rayA@71e5442fc5 (2026-09-05). Data as JSON: /api/errors/ced1e103a4e37db8. Report an issue: GitHub.