chika0801 / sing-box-examples

sing-box 配置示例
https://github.com/SagerNet/sing-box
1.61k stars 270 forks source link

TUN模式下,增加platform:http_proxy,后路由判断失效. #87

Closed odesky closed 6 months ago

odesky commented 6 months ago

使用:https://github.com/chika0801/sing-box-examples/blob/main/Tun/config_client_android_remote_dns_with_fakeip.json 模版。 当在TUN中加入http_proxy后。

"inbounds": [
    {
      "type": "tun",
      "tag": "tun-in",
      .......
      "platform": {
        "http_proxy": {
          "enabled": true,
          "server": "127.0.0.1",
          "server_port": 1080
        }
      }     
    },
    { 
      "tag": "mixed-in", 
      "type": "mixed",
      "domain_strategy": "", 
      "sniff": true, 
      "sniff_override_destination": false,
      "listen": "127.0.0.1", 
      "listen_port": 1080     
    } 
  ]

路由中的叛断失效。

  "route": {
    "rule_set": [
      ......
    ],
    "rules": [
     .......
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "rule_set": "geoip-cn"
          },
          {
            "rule_set": [
              "geosite-cn",
              "geosite-category-companies@cn"
            ]
          }
        ],
        "outbound": "direct"
      },
      ........
  },
chika0801 commented 6 months ago
    { 
      "tag": "mixed-in", 
      "type": "mixed",
      "domain_strategy": "", 
      "sniff": true, 
      "sniff_override_destination": false,
      "listen": "127.0.0.1", 
      "listen_port": 1080,
      "domain_strategy": "ipv4_only" // 增加这段
    } 

作用是把接收到的目标地址是域名的请求,用内置DNS,根据规则查询后得到IPv4。

IPv4和域名作用条件进入路由。

      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "rule_set": "geoip-cn"
          },
          {
            "rule_set": [
              "geosite-cn",
              "geosite-category-companies@cn"
            ]
          }
        ],
        "outbound": "direct"
      },

你这条是且的关系,现在有了IPv4和域名2个条件能进行匹配了。

chika0801 commented 6 months ago

你可以把日志级别用trace/debug等,自己找域名测试,观察日志就懂了。

odesky commented 6 months ago

大神,您好。 果然是"domain_strategy": "ipv4_only" 的问题。在没有增加的时候。域名都会走PROXY。而不是直连。