From fecb29f6ab57e8f66f50a8a5054685aa7c00a105 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Mon, 28 Oct 2024 21:59:48 +0100 Subject: [PATCH] [subJson] inbound options #240 #318 --- backend/sub/jsonService.go | 13 ++-- frontend/src/components/SubJsonExt.vue | 84 ++++++++++++++++++++++++++ frontend/src/locales/en.ts | 1 + frontend/src/locales/fa.ts | 1 + frontend/src/locales/ru.ts | 1 + frontend/src/locales/vi.ts | 1 + frontend/src/locales/zhcn.ts | 1 + frontend/src/locales/zhtw.ts | 1 + 8 files changed, 98 insertions(+), 5 deletions(-) diff --git a/backend/sub/jsonService.go b/backend/sub/jsonService.go index 033c52d..12a63d8 100644 --- a/backend/sub/jsonService.go +++ b/backend/sub/jsonService.go @@ -14,10 +14,10 @@ const defaultJson = ` "inbounds": [ { "type": "tun", - "inet4_address": "172.19.0.1/30", - "inet6_address": [ - "fdfe:dcba:9876::1/126" - ], + "address": [ + "172.19.0.1/30", + "fdfe:dcba:9876::1/126" + ], "mtu": 9000, "auto_route": true, "strict_route": false, @@ -249,8 +249,11 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error { if _, ok := othersJson["dns"]; ok { (*jsonConfig)["dns"] = othersJson["dns"] } + if _, ok := othersJson["inbounds"]; ok { + (*jsonConfig)["inbounds"] = othersJson["inbounds"] + } if _, ok := othersJson["experimental"]; ok { - (*jsonConfig)["experimental"] = othersJson["lexperimentalog"] + (*jsonConfig)["experimental"] = othersJson["experimental"] } if _, ok := othersJson["rule_set"]; ok { route["rule_set"] = othersJson["rule_set"] diff --git a/frontend/src/components/SubJsonExt.vue b/frontend/src/components/SubJsonExt.vue index 6c9f445..489924a 100644 --- a/frontend/src/components/SubJsonExt.vue +++ b/frontend/src/components/SubJsonExt.vue @@ -62,6 +62,48 @@ > + @@ -76,6 +118,9 @@ + + + @@ -98,6 +143,36 @@ export default { "level": "info", "timestamp": true }, + defaultInb: [ + { + "type": "tun", + "address": [ + "172.19.0.1/30", + "fdfe:dcba:9876::1/126" + ], + "mtu": 9000, + "auto_route": true, + "strict_route": false, + "sniff": true, + "endpoint_independent_nat": false, + "stack": "system", + "exclude_package": [], + "platform": { + "http_proxy": { + "enabled": true, + "server": "127.0.0.1", + "server_port": 2080 + } + } + }, + { + "type": "mixed", + "listen": "127.0.0.1", + "listen_port": 2080, + "sniff": true, + "users": [] + } + ], defaultExp: { "clash_api": { "external_controller": "127.0.0.1:9090", @@ -253,6 +328,10 @@ export default { } } }, + enableInb: { + get() :boolean { return this.subJsonExt?.inbounds != undefined }, + set(v:boolean) { v ? this.subJsonExt.inbounds = this.defaultInb.slice() : delete this.subJsonExt.inbounds } + }, enableExp: { get() :boolean { return this.subJsonExt?.experimental != undefined }, set(v:boolean) { v ? this.subJsonExt.experimental = this.defaultExp : delete this.subJsonExt.experimental } @@ -298,6 +377,11 @@ export default { this.updateRuleSets() } }, + inbounds():any[] { return this.subJsonExt?.inbounds?? undefined }, + platformProxy: { + get() :boolean { return this.inbounds[0]?.platform != undefined }, + set(v:boolean) { this.subJsonExt.inbounds[0].platform = v ? this.defaultInb[0].platform : undefined } + }, rules():any { return this.subJsonExt?.rules?? undefined }, ruleToDirect: { get() :string[] { diff --git a/frontend/src/locales/en.ts b/frontend/src/locales/en.ts index 74162bf..f5311a2 100644 --- a/frontend/src/locales/en.ts +++ b/frontend/src/locales/en.ts @@ -154,6 +154,7 @@ export default { directDns: "Direct DNS", toDirectDns: "Route to Direct DNS", jsonSubOptions: "Other Options", + excludePkg: "Exclude Packages", }, client: { name: "Name", diff --git a/frontend/src/locales/fa.ts b/frontend/src/locales/fa.ts index eaab04b..5e67fcc 100644 --- a/frontend/src/locales/fa.ts +++ b/frontend/src/locales/fa.ts @@ -153,6 +153,7 @@ export default { directDns: "DNS مستقیم", toDirectDns: "هدایت به DNS مستقیم", jsonSubOptions: "گزینه‌های دیگر", + excludePkg: "نرم‌افزارهای استثنا", }, client: { name: "نام", diff --git a/frontend/src/locales/ru.ts b/frontend/src/locales/ru.ts index 8ae8b58..6ccfd2d 100644 --- a/frontend/src/locales/ru.ts +++ b/frontend/src/locales/ru.ts @@ -154,6 +154,7 @@ export default { directDns: "Прямой DNS", toDirectDns: "Маршрутизация на Direct DNS", jsonSubOptions: "Другие параметры", + excludePkg: "Исключить пакеты", }, client: { name: "Имя", diff --git a/frontend/src/locales/vi.ts b/frontend/src/locales/vi.ts index 166cba4..baca341 100644 --- a/frontend/src/locales/vi.ts +++ b/frontend/src/locales/vi.ts @@ -154,6 +154,7 @@ export default { directDns: "DNS Trực tiếp", toDirectDns: "Chuyển hướng tới DNS Trực tiếp", jsonSubOptions: "Tùy chọn Khác", + excludePkg: "Loại trừ Gói", }, client: { name: "Tên", diff --git a/frontend/src/locales/zhcn.ts b/frontend/src/locales/zhcn.ts index c6fa608..975d54c 100644 --- a/frontend/src/locales/zhcn.ts +++ b/frontend/src/locales/zhcn.ts @@ -154,6 +154,7 @@ export default { directDns: "直连 DNS", toDirectDns: "路由到直连 DNS", jsonSubOptions: "其他选项", + excludePkg: "排除包", }, client: { name: "名称", diff --git a/frontend/src/locales/zhtw.ts b/frontend/src/locales/zhtw.ts index 31ca51c..7b769af 100644 --- a/frontend/src/locales/zhtw.ts +++ b/frontend/src/locales/zhtw.ts @@ -155,6 +155,7 @@ export default { directDns: "直連 DNS", toDirectDns: "路由到直連 DNS", jsonSubOptions: "其他選項", + excludePkg: "排除包", }, client: { name: "名稱",