{"record":{"id":"c6e4d7347fc5404b","repo":"v2rayA/v2rayA","slug":"undefined-v-mode-of-transparent-proxy","errorCode":null,"errorMessage":"undefined \"%v\" mode of transparent proxy","messagePattern":"undefined \"(.+?)\" mode of transparent proxy","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/kernel/v2ray/transparent.go","lineNumber":181,"sourceCode":"\tcase configure.TransparentTproxy:\n\t\tif err = iptables.Tproxy.GetSetupCommands().Run(true); err != nil {\n\t\t\tif strings.Contains(err.Error(), \"TPROXY\") && strings.Contains(err.Error(), \"No chain\") {\n\t\t\t\terr = fmt.Errorf(\"you does not compile xt_TPROXY in kernel\")\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"not support \\\"tproxy\\\" mode of transparent proxy: %w\", err)\n\t\t}\n\t\tiptables.SetWatcher(iptables.Tproxy)\n\tcase configure.TransparentRedirect:\n\t\tif err = iptables.Redirect.GetSetupCommands().Run(true); err != nil {\n\t\t\treturn fmt.Errorf(\"not support \\\"redirect\\\" mode of transparent proxy: %w\", err)\n\t\t}\n\t\tiptables.SetWatcher(iptables.Redirect)\n\tcase configure.TransparentSystemProxy:\n\t\tif err = iptables.SystemProxy.GetSetupCommands().Run(true); err != nil {\n\t\t\treturn fmt.Errorf(\"not support \\\"system proxy\\\" mode of transparent proxy: %w\", err)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"undefined \\\"%v\\\" mode of transparent proxy\", setting.TransparentType)\n\t}\n\n\t// 无论哪种透明代理模式，都用 nat 表的 REDIRECT 将 DNS 流量（:53）转到 DNS 模块（:52353）。\n\t// 同时拦截 OUTPUT（本地进程）和 PREROUTING（LAN 设备）的 DNS 查询。\n\t// TPROXY 模式对回环（loopback）流量的 TPROXY 拦截不可靠，而 REDIRECT 在 OUTPUT 链上稳定。\n\t//\n\t// IMPORTANT (fix): mark 0x80 豁免规则必须排在 REDIRECT 规则之前，否则 v2raya-core\n\t// 自己向上游转发的 DNS 查询（socket 带 SO_MARK=0x80）会被自己的 REDIRECT 规则劫持回\n\t// :52353，形成无限回环（内存雪崩直至 OOM）。iptables 按顺序匹配：\n\t//   - REDIRECT 用 -A（追加到链尾），确保在 mark 豁免之后\n\t//   - mark 豁免用 -I（插入到链首），确保最先匹配\n\tif ShouldLocalDnsListen() {\n\t\tdnsRedirect := `\niptables -w 2 -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-port 52353\niptables -w 2 -t nat -A OUTPUT -p tcp --dport 53 -j REDIRECT --to-port 52353\niptables -w 2 -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-port 52353\niptables -w 2 -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-port 52353\niptables -w 2 -t nat -I OUTPUT -m mark --mark 0x80/0x80 -j RETURN","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/kernel/v2ray/transparent.go#L163-L199","documentation":"The configured TransparentType value did not match any known mode (tproxy, redirect, system proxy, tinytun). This is a configuration-validation error indicating the setting file holds an out-of-range or corrupted value for the transparent proxy type.","triggerScenarios":"writeTransparentProxyRules hits the default branch of its switch because setting.TransparentType contains an unknown/zero/legacy value — e.g. a hand-edited config, an older config version whose enum numeric value no longer maps, or a config written by a different fork.","commonSituations":"Manually editing the settings JSON with an invalid string; downgrading/upgrading v2rayA where enum representation changed; config sync from another tool writing raw values.","solutions":["Open v2rayA settings and re-select a valid transparent-proxy mode (tproxy / redirect / system proxy / tinytun).","Or delete/reset the settings store so defaults are regenerated.","Log the offending value (%v is interpolated) and fix the config file directly.","If you wrote the config programmatically, validate the enum before persisting."],"exampleFix":"// before (config)\n\"transparentType\": \"tun2socks\"   // unknown value\n// after\n\"transparentType\": \"redirect\"","handlingStrategy":"validation","validationCode":"valid := map[configure.TransparentType]bool{\n\tconfigure.TransparentTproxy: true, configure.TransparentRedirect: true,\n\tconfigure.TransparentSystemProxy: true, configure.TransparentTun: v2ray.IsTinyTunEnabled(),\n}\nif !valid[setting.TransparentType] { return fmt.Errorf(\"invalid transparent type: %v\", setting.TransparentType) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit the settings enum values.","Validate TransparentType after config load/migration.","Re-select the mode in the UI after upgrading versions."],"tags":["configuration","validation","transparent-proxy","enum"],"backgroundTag":"invalid-config-value","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"}