mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-02 09:23:54 +00:00
feat: sing-box 支持 MASQUE
This commit is contained in:
7 files changed
+453
-24
No files matched your search
+21
-5
@@ -72,13 +72,29 @@ function operator(proxies = [], targetPlatform, context) {
|
||||
// Loon 文档要求多个 DNS 用双引号包裹; Sub-Store 输入额外兼容不加双引号的列表, 输出始终带双引号
|
||||
// 脚本快捷设置: $server['server-dns'] = ['223.5.5.5', 'https://dns.example.com/dns-query', 'quic://dns.example.com', 'h3://dns.example.com/dns-query']
|
||||
// 移除可用 delete $server['server-dns'], 空数组不输出该字段
|
||||
// 41. sing-box WireGuard/Tailscale 支持 `_on_demand` 设置 `on_demand`, 值为布尔值 `true`/`false`, 允许 endpoint 在需要时断开连接; sing-box 1.15.0 起支持. 例如: $server._on_demand = true
|
||||
// 41. sing-box WireGuard/Tailscale/MASQUE 支持 `_on_demand` 设置 `on_demand`, 值为布尔值 `true`/`false`, 允许 endpoint 在需要时断开连接; sing-box 1.15.0 起支持. 例如: $server._on_demand = true
|
||||
// 42. sing-box WireGuard/Tailscale 支持 `_listen_port` 设置本地 UDP 监听端口 `listen_port`, 接受 0–65535 的整数或整数字符串, `0` 表示自动选择; Tailscale 需要 sing-box 1.14.0+. WireGuard 的非零 `listen_port` 不能与 `detour`/`dialer-proxy` 同时使用. 例如: $server._listen_port = 51820
|
||||
// 43. sing-box WireGuard 支持 `_name` 设置系统接口名称 `name`, 配合 `system: true` 使用; 节点的 `name` 仍用于输出 `tag`. 例如: $server._name = 'wg0'
|
||||
// 44. sing-box WireGuard 支持 `_udp_mapping` 设置 `udp_mapping`, 可选 `endpoint_independent`(默认)、`address_dependent`、`address_and_port_dependent`; 控制 UDP NAT 映射复用方式, sing-box 1.14.0 起支持. 例如: $server._udp_mapping = 'endpoint_independent'
|
||||
// 45. sing-box WireGuard 支持 `_udp_filtering` 设置 `udp_filtering`, 可选 `endpoint_independent`(默认)、`address_dependent`、`address_and_port_dependent`; 控制 UDP NAT 接受哪些远端回包, sing-box 1.14.0 起支持. 例如: $server._udp_filtering = 'address_and_port_dependent'
|
||||
// 46. sing-box WireGuard 支持 `_udp_nat_max` 设置 `udp_nat_max`, 接受 0–4294967295 的整数或整数字符串, 限制 UDP NAT 会话数; `0` 使用 sing-box 的平台默认值, sing-box 1.14.0 起支持. 例如: $server._udp_nat_max = 8192
|
||||
// 43. sing-box WireGuard/MASQUE 支持 `_name` 设置系统接口名称 `name`, 配合 `system: true` 使用; 节点的 `name` 仍用于输出 `tag`. 例如: $server._name = 'wg0'
|
||||
// 44. sing-box WireGuard/MASQUE 支持 `_udp_mapping` 设置 `udp_mapping`, 可选 `endpoint_independent`(默认)、`address_dependent`、`address_and_port_dependent`; 控制 UDP NAT 映射复用方式, WireGuard 需要 sing-box 1.14.0+, MASQUE 需要 1.15.0+. 例如: $server._udp_mapping = 'endpoint_independent'
|
||||
// 45. sing-box WireGuard/MASQUE 支持 `_udp_filtering` 设置 `udp_filtering`, 可选 `endpoint_independent`(默认)、`address_dependent`、`address_and_port_dependent`; 控制 UDP NAT 接受哪些远端回包, WireGuard 需要 sing-box 1.14.0+, MASQUE 需要 1.15.0+. 例如: $server._udp_filtering = 'address_and_port_dependent'
|
||||
// 46. sing-box WireGuard/MASQUE 支持 `_udp_nat_max` 设置 `udp_nat_max`, 接受 0–4294967295 的整数或整数字符串, 限制 UDP NAT 会话数; `0` 使用 sing-box 的平台默认值, WireGuard 需要 sing-box 1.14.0+, MASQUE 需要 1.15.0+. 例如: $server._udp_nat_max = 8192
|
||||
// 47. sing-box Tailscale 支持 `_taildrop_directory` 设置接收 Taildrop 文件的目录 `taildrop_directory`, 值为字符串; 相对路径基于 sing-box 工作目录, 默认 `Taildrop`, sing-box 1.14.0 起支持. 例如: $server._taildrop_directory = './taildrop'
|
||||
// 48. sing-box 1.15.0+ 支持将内部类型 `masque-surge` 输出为 `endpoints` 中的 `masque-client`(CONNECT-IP). JSON/JSON5/YAML 输入也允许写 `type: 'masque-sing-box'`, 解析后内部 type 仍为 `masque-surge`; mihomo 的 `masque` 不会按此转换
|
||||
// 协议区别: Surge 文档描述的是 HTTP/3 CONNECT/CONNECT-UDP, sing-box `masque-client` 是 CONNECT-IP; 共用内部 type 不代表服务器协议兼容, 跨客户端使用需要服务器分别支持对应协议. Surge 文档: https://manual.nssurge.com/policies/masque.html
|
||||
// 可直接输入 Surge 格式: MASQUE = masque,masque.example.com,443,username=example-user,password=example-password,sni=masque.example.com
|
||||
// 通用字段: `username`, `password`, `path`, `headers`(值支持字符串或字符串数组), `advertise-routes`(CIDR 字符串或数组), `system`(布尔值), `mtu`, `udp-timeout`; `path` 默认 /.well-known/masque/ip/{target}/{ipproto}/, `mtu` 默认 1280
|
||||
// `_version` 设置 HTTP 版本 1/2/3(整数或整数字符串), 省略或 0 默认 HTTP/3; `_disable_version_fallback`(布尔值) 禁止自动回退到较低 HTTP 版本
|
||||
// HTTP/2 和 HTTP/3 可设置 `_idle_timeout`, `_keep_alive_period`(Go Duration 字符串, 如 '30s'), `_stream_receive_window`, `_connection_receive_window`(容量字符串, 如 '64 MB'), `_max_concurrent_streams`(非负整数或整数字符串)
|
||||
// 仅 HTTP/3 可设置 `_initial_packet_size`(0–65535 的整数或整数字符串), `_disable_path_mtu_discovery`(布尔值); HTTP/1 不输出 HTTP2/QUIC 字段, HTTP/2 不输出 QUIC 专属字段, HTTP/3 不输出 uTLS
|
||||
// 复用上面的 `_name`, `_on_demand`, `_udp_mapping`, `_udp_filtering`, `_udp_nat_max` 和 TLS/DNS/前置代理字段; Surge `[Keystore]` 的 client-cert 引用不能直接转换, 请使用 `_client_certificate`/`_client_certificate_path` 和 `_client_key`/`_client_key_path` 提供实际证书和密钥
|
||||
// sing-box MASQUE 不支持 Surge 的端口跳跃, 只使用 `port`; `ports`/`hop-interval`/`ecn` 不输出
|
||||
// 输出 Surge/SurgeMac 时, `_version` 只能省略或设为 0/3(支持整数字符串), `_disable_version_fallback` 若设置必须为 true; HTTP/1、HTTP/2、需要回退的配置会过滤并记录原因, `alpn` 仍可按 Surge 文档自定义
|
||||
// Surge 无法表达以下字段, 显式设置时会过滤整个节点并记录字段名(包括 false、0、空字符串/空容器, null/undefined 视为未设置): `path`, `headers`, `advertise-routes`, `system`, `_name`, `mtu`, `_on_demand`, `udp-timeout`, `_udp_mapping`, `_udp_filtering`, `_udp_nat_max`, `_idle_timeout`, `_keep_alive_period`, `_stream_receive_window`, `_connection_receive_window`, `_max_concurrent_streams`, `_initial_packet_size`, `_disable_path_mtu_discovery`
|
||||
// 同样会过滤 sing-box 的 `_certificate`/`_certificate_path`/`_certificate_public_key_sha256`、`_client_certificate`/`_client_certificate_path`/`_client_key`/`_client_key_path`、`_ech`/`ech-opts`、`_curve_preferences`、`_fragment`/`_fragment_fallback_delay`/`_record_fragment`、`reality-opts`、`_dns_server`/`_domain_resolver`、`detour`; Surge 客户端证书请用 `keystore-client-cert`, 前置代理请用 `underlying-proxy`
|
||||
// Surge MASQUE 也会过滤 `plugin: 'shadow-tls'`, 以及同时设置非空 `ports` 和 `underlying-proxy` 的节点. 上述检查在开启“含不支持的协议”时仍生效, 不会静默丢弃参数后输出
|
||||
// 脚本示例: if ($server.type === 'masque-surge') { $server._on_demand = true; $server._version = 3; $server._disable_version_fallback = true; $server.mtu = 1280; $server._udp_nat_max = 8192; }
|
||||
// 完整 MASQUE/HTTP2/QUIC/UDP NAT 字段的单行 JSON 输入示例(含 TLS、DNS 和前置代理; 地址、凭据、证书文件及 DNS/代理 tag 均为示例, 按需替换或删除; 此例会被 Surge/SurgeMac 过滤):
|
||||
// {"type":"masque-sing-box","name":"MASQUE sing-box","server":"masque.example.com","port":443,"username":"example-user","password":"example-password","path":"/.well-known/masque/ip/{target}/{ipproto}/","headers":{"Host":"masque.example.com","X-Example":["one","two"]},"_version":3,"_disable_version_fallback":true,"advertise-routes":["10.9.0.0/24","fd00:9::/64"],"system":false,"_name":"masque0","mtu":1280,"_on_demand":true,"_idle_timeout":"1m","_keep_alive_period":"10s","_stream_receive_window":"64 MB","_connection_receive_window":"128 MB","_max_concurrent_streams":100,"_initial_packet_size":1331,"_disable_path_mtu_discovery":false,"udp-timeout":"5m","_udp_mapping":"endpoint_independent","_udp_filtering":"address_and_port_dependent","_udp_nat_max":8192,"tls":true,"sni":"masque.example.com","alpn":["h3"],"skip-cert-verify":false,"_certificate_path":"ca.pem","_client_certificate_path":"client.pem","_client_key_path":"client.key","tfo":true,"fast-open":true,"underlying-proxy":"upstream","_domain_resolver":{"server":"dns-masque","strategy":"prefer_ipv6"}}
|
||||
|
||||
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
|
||||
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件
|
||||
|
||||
Reference in new issue
Block a user