{"record":{"id":"d0e746aab63947ee","repo":"shadowsocks/shadowsocks-windows","slug":"unknown-forward-proxy","errorCode":null,"errorMessage":"Unknown forward proxy.","messagePattern":"Unknown forward proxy\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"shadowsocks-csharp/Controller/Service/TCPRelay.cs","lineNumber":675,"sourceCode":"                EndPoint pluginEP = _controller.GetPluginLocalEndPointIfConfigured(_server);\r\n\r\n                if (pluginEP != null)\r\n                {\r\n                    serverEP = pluginEP;\r\n                    remote = new DirectConnect();\r\n                }\r\n                else if (_config.useProxy)\r\n                {\r\n                    switch (_config.proxyType)\r\n                    {\r\n                        case ForwardProxyConfig.PROXY_SOCKS5:\r\n                            remote = new Socks5Proxy();\r\n                            break;\r\n                        case ForwardProxyConfig.PROXY_HTTP:\r\n                            remote = new HttpProxy();\r\n                            break;\r\n                        default:\r\n                            throw new NotSupportedException(\"Unknown forward proxy.\");\r\n                    }\r\n                    proxyEP = SocketUtil.GetEndPoint(_config.proxyServer, _config.proxyPort);\r\n                }\r\n                else\r\n                {\r\n                    remote = new DirectConnect();\r\n                }\r\n\r\n                AsyncSession session = new AsyncSession(remote);\r\n                lock (_closeConnLock)\r\n                {\r\n                    if (_closed)\r\n                    {\r\n                        remote.Close();\r\n                        return;\r\n                    }\r\n\r\n                    _currentRemoteSession = session;\r","sourceCodeStart":657,"sourceCodeEnd":693,"githubUrl":"https://github.com/shadowsocks/shadowsocks-windows/blob/891d971682eefcaa2e640258d3b352a3ad3b2233/shadowsocks-csharp/Controller/Service/TCPRelay.cs#L657-L693","documentation":"Thrown as NotSupportedException when config.useProxy is true but config.proxyType does not match PROXY_SOCKS5 or PROXY_HTTP. Only those two forward-proxy types are implemented; any other value falls through the switch's default. It fires during remote connection setup, before a proxy endpoint is resolved.","triggerScenarios":"A future/unknown proxyType constant was introduced without adding a case; gui-config.json was hand-edited and proxyType set to an invalid or typo'd value; an enum-like field stored as a string/int that deserialized to an unexpected value.","commonSituations":"Editing the config file and entering a wrong proxy type string; code merge that adds a new proxy type but forgets the switch case; corrupt config yielding an out-of-range integer.","solutions":["Set proxyType to one of the supported constants (PROXY_SOCKS5 or PROXY_HTTP), or disable useProxy.","If you genuinely need a new proxy type, add a matching case + implementation before using it.","Validate proxyType against the known set when loading config and reject invalid values early with a clear message."],"exampleFix":"// before\ndefault:\n    throw new NotSupportedException(\"Unknown forward proxy.\");\n\n// after: include the offending value\nthrow new NotSupportedException($\"Unknown forward proxy type: {_config.proxyType}\");","handlingStrategy":"validation","validationCode":"// Validate proxy type when loading config\nif (config.useProxy &&\n    config.proxyType != ForwardProxyConfig.PROXY_SOCKS5 &&\n    config.proxyType != ForwardProxyConfig.PROXY_HTTP)\n{ /* reset useProxy or clamp to a known type */ }","typeGuard":"bool IsValidProxyType(string t) =>\n    t == ForwardProxyConfig.PROXY_SOCKS5 || t == ForwardProxyConfig.PROXY_HTTP;","tryCatchPattern":"try { /* connect via forward proxy */ }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Unknown forward proxy\"))\n{ /* disable useProxy, inform user */ }","preventionTips":["Reject unknown proxyType at config load with a clear message.","When adding a proxy type, add the switch case in the same change.","Persist proxyType only through validated UI controls, not free text."],"tags":["configuration","proxy","forward-proxy","validation"],"backgroundTag":null,"analyzedSha":"891d971682eefcaa2e640258d3b352a3ad3b2233","analyzedAt":"2026-08-13T10:12:34.434Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}