{"record":{"id":"ced1e103a4e37db8","repo":"v2rayA/v2rayA","slug":"getwebproxy-v","errorCode":null,"errorMessage":"getwebproxy: %v","messagePattern":"getwebproxy: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/kernel/iptables/systemProxy_macos.go","lineNumber":104,"sourceCode":"\tfor _, line := range lines {\n\t\tline = strings.TrimSpace(line)\n\t\tif strings.HasPrefix(line, \"Enabled:\") {\n\t\t\tval := strings.TrimSpace(strings.TrimPrefix(line, \"Enabled:\"))\n\t\t\tenabled = val == \"Yes\"\n\t\t} else if strings.HasPrefix(line, \"URL:\") {\n\t\t\turl = strings.TrimSpace(strings.TrimPrefix(line, \"URL:\"))\n\t\t}\n\t}\n\treturn\n}\n\n// readServiceState reads and returns the current proxy state for a given network service\nfunc readServiceState(service string) (*macosServiceState, error) {\n\tstate := &macosServiceState{}\n\n\tout, err := exec.Command(\"/usr/sbin/networksetup\", \"-getwebproxy\", service).Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getwebproxy: %v\", err)\n\t}\n\tstate.webEnabled, state.webServer, state.webPort = parseProxyOutput(string(out))\n\n\tout, err = exec.Command(\"/usr/sbin/networksetup\", \"-getsecurewebproxy\", service).Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getsecurewebproxy: %v\", err)\n\t}\n\tstate.secureWebEnabled, state.secureWebServer, state.secureWebPort = parseProxyOutput(string(out))\n\n\tout, err = exec.Command(\"/usr/sbin/networksetup\", \"-getsocksfirewallproxy\", service).Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getsocksfirewallproxy: %v\", err)\n\t}\n\tstate.socksEnabled, state.socksServer, state.socksPort = parseProxyOutput(string(out))\n\n\tout, err = exec.Command(\"/usr/sbin/networksetup\", \"-getautoproxyurl\", service).Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getautoproxyurl: %v\", err)","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/kernel/iptables/systemProxy_macos.go#L86-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the wrapped error text: run networksetup -getwebproxy \"<service>\" manually to see networksetup's own message","Validate the service name matches exactly what -listallnetworkservices printed (quoting/spaces matter)","Run from an admin GUI session or with sudo when invoked over SSH","Skip services that do not support web proxies instead of failing the whole status read"],"exampleFix":"// before\nout, err := exec.Command(\"/usr/sbin/networksetup\", \"-getwebproxy\", service).Output()\n// after (caller-side guard)\nif service == \"\" || strings.Contains(service, \"*\") { return nil, nil }\nout, err := exec.Command(\"/usr/sbin/networksetup\", \"-getwebproxy\", service).Output()","handlingStrategy":"try-catch","validationCode":"out, err := exec.Command(\"/usr/sbin/networksetup\", \"-listallnetworkservices\").Output()\nif err != nil { return err }\nvalid := map[string]bool{}\nfor _, l := range strings.Split(string(out), \"\\n\")[1:] {\n    l = strings.TrimSpace(l)\n    if l != \"\" && !strings.Contains(l, \"*\") { valid[l] = true }\n}\nif !valid[service] { return fmt.Errorf(\"unknown service %q\", service) }","typeGuard":null,"tryCatchPattern":"state, err := readServiceState(service)\nif err != nil {\n    log.Debugf(\"skipping %s: %v\", service, err) // non-fatal for status aggregation\n    return nil, nil\n}","preventionTips":["Quote service names exactly as listed by -listallnetworkservices","Skip services that don't support web proxies instead of failing","Run in an admin GUI session or with sudo over SSH","Re-read service names after macOS upgrades (names/localization change)"],"tags":["go","macos","networksetup","system-proxy"],"backgroundTag":"networksetup-failed","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}