SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.01k stars 2.38k forks source link

请问起一个入站服务,可以配置自己特有的路由规则吗? #2229

Closed bsdcpp closed 2 weeks ago

bsdcpp commented 2 weeks ago

类似mihomo的sub-rule,谢谢。

sub-rules:
  sub-rule-name1:
    - DOMAIN,google.com,ss1
    - DOMAIN,baidu.com,DIRECT
  sub-rule-name2:
    - IP-CIDR,1.1.1.1/32,REJECT
    - IP-CIDR,8.8.8.8/32,ss1
    - DOMAIN,dns.alidns.com,REJECT

# 流量入站
listeners:
  - name: shadowsocks-in-1
    type: shadowsocks
    port: 10813
    listen: 0.0.0.0
    rule: sub-rule-name1 # 默认使用 rules,如果未找到 sub-rule 则直接使用 rules
    password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=
    cipher: 2022-blake3-aes-256-gcm

看过singbox入站配置,没看到相应字段

{
  "type": "shadowsocks",
  "tag": "ss-in",

  ... // 监听字段

  "method": "2022-blake3-aes-128-gcm",
  "password": "8JCsPssfgS8tiRwiMlhARg==",
  "multiplex": {}
}

监听字段

{
  "listen": "::",
  "listen_port": 5353,
  "tcp_fast_open": false,
  "tcp_multi_path": false,
  "udp_fragment": false,
  "udp_timeout": "5m",
  "detour": "another-in",
  "sniff": false,
  "sniff_override_destination": false,
  "sniff_timeout": "300ms",
  "domain_strategy": "prefer_ipv6",
  "udp_disable_domain_unmapping": false
}
junx964 commented 2 weeks ago

"tag": "ss-in", 是干嘛的, 路由中有一个配置是”inbound“,发挥你的脑洞吧。

bsdcpp commented 2 weeks ago

"tag": "ss-in", 是干嘛的, 路由中有一个配置是”inbound“,发挥你的脑洞吧。

等于本地起代理服务,外网连进来。我用过homeproxy,也是没有规则配置,看来这个服务是跟随透明代理整体规则走的,无法定制每个listener的规则走向