From dd6fe6c41b6477a78206e318b000a806e829556e Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield Date: Tue, 5 Mar 2024 07:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20`loopback`=20=E5=87=BA?= =?UTF-8?q?=E7=AB=99=E7=9A=84=E7=AE=80=E6=98=93=E4=BD=BF=E7=94=A8=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=20(#478)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add `loopback` pages to sidebar * Add usage for `loopback` --- docs/.vuepress/config/sidebar/en.ts | 1 + docs/.vuepress/config/sidebar/zh.ts | 1 + docs/config/outbounds/loopback.md | 40 ++++++++++++++++++++++++++++ docs/en/config/outbounds/loopback.md | 40 ++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) diff --git a/docs/.vuepress/config/sidebar/en.ts b/docs/.vuepress/config/sidebar/en.ts index b9d014689..af8de2652 100755 --- a/docs/.vuepress/config/sidebar/en.ts +++ b/docs/.vuepress/config/sidebar/en.ts @@ -49,6 +49,7 @@ export const sidebarEn: SidebarConfig = { '/en/config/outbounds/dns.md', '/en/config/outbounds/freedom.md', '/en/config/outbounds/http.md', + '/en/config/outbounds/loopback.md', '/en/config/outbounds/shadowsocks.md', '/en/config/outbounds/socks.md', '/en/config/outbounds/trojan.md', diff --git a/docs/.vuepress/config/sidebar/zh.ts b/docs/.vuepress/config/sidebar/zh.ts index 5039c4349..87112d7c5 100755 --- a/docs/.vuepress/config/sidebar/zh.ts +++ b/docs/.vuepress/config/sidebar/zh.ts @@ -49,6 +49,7 @@ export const sidebarZh: SidebarConfig = { '/config/outbounds/dns.md', '/config/outbounds/freedom.md', '/config/outbounds/http.md', + '/config/outbounds/loopback.md', '/config/outbounds/shadowsocks.md', '/config/outbounds/socks.md', '/config/outbounds/trojan.md', diff --git a/docs/config/outbounds/loopback.md b/docs/config/outbounds/loopback.md index 3787e8472..79b896f5f 100644 --- a/docs/config/outbounds/loopback.md +++ b/docs/config/outbounds/loopback.md @@ -15,3 +15,43 @@ Loopback 是个出站数据协议,其作用为将经该出站传出的数据 用于重新路由的入站协议标识。 该标识可以在路由中用于 `inboundTag` ,表示该出站中的数据可以被对应的路由规则再次处理。 + +### 如何使用? + +如果需要将已经通过路由规则分流过的流量再由其它路由规则做更细致的分流,比如由同一组路由规则分流后的 TCP 流量和 UDP 要走不同的出站,则可以使用 `loopback` 出站完成。 + +``` jsonc +{ + "outbounds": [ + { + "protocol": "loopback", + "tag": "need-to-split", + "settings": { + "tag": "traffic-input" // 该 tag 在下方用于 RuleObject 的 inboundTag + } + }, + { + "tag": "tcp-output", + // protocol, settings, streamSettings 之类的设置 + }, + { + "tag": "udp-output", + // protocol, settings, streamSettings 之类的设置 + } + ], + "routing": { + "rules": [ + { + "inboundTag": ["traffic-input"], // loopback 设定的 tag + "network": "tcp", + "outboundTag": "tcp-output" + }, + { + "inboundTag": ["traffic-input"], // loopback 设定的 tag + "network": "udp", + "outboundTag": "udp-output" + } + ] + } +} +``` \ No newline at end of file diff --git a/docs/en/config/outbounds/loopback.md b/docs/en/config/outbounds/loopback.md index d4cc77011..6405e258b 100644 --- a/docs/en/config/outbounds/loopback.md +++ b/docs/en/config/outbounds/loopback.md @@ -15,3 +15,43 @@ Loopback is an outbound protocol. It can send traffics through corresponding out Use as an inbound tag for routing. This tag can be used as `inboundTag` in routing rules, all traffics going through this outbound can be rerouted with routing rules with corresponding inbound tag. + +### How to use? + +If you need to do some more detailed routing for traffics that have been routed by routing rules, like splitting routed traffics to TCP traffics and UDP traffics and send them to different outbounds, this can be done with `loopback` outbound. + +``` jsonc +{ + "outbounds": [ + { + "protocol": "loopback", + "tag": "need-to-split", + "settings": { + "tag": "traffic-input" // This tag will be used as the inboundTag inside the RuleObject + } + }, + { + "tag": "tcp-output", + // protocol, settings, streamSettings etc. + }, + { + "tag": "udp-output", + // protocol, settings, streamSettings etc. + } + ], + "routing": { + "rules": [ + { + "inboundTag": ["traffic-input"], // tag set in the loopback outbound setting + "network": "tcp", + "outboundTag": "tcp-output" + }, + { + "inboundTag": ["traffic-input"], // tag set in the loopback outbound + "network": "udp", + "outboundTag": "udp-output" + } + ] + } +} +``` \ No newline at end of file