[subJson] inbound options #240 #318

This commit is contained in:
Alireza Ahmadi
2024-10-28 21:59:48 +01:00
parent 7b7e5ac79d
commit fecb29f6ab
8 changed files with 98 additions and 5 deletions
+6 -3
View File
@@ -14,8 +14,8 @@ const defaultJson = `
"inbounds": [ "inbounds": [
{ {
"type": "tun", "type": "tun",
"inet4_address": "172.19.0.1/30", "address": [
"inet6_address": [ "172.19.0.1/30",
"fdfe:dcba:9876::1/126" "fdfe:dcba:9876::1/126"
], ],
"mtu": 9000, "mtu": 9000,
@@ -249,8 +249,11 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
if _, ok := othersJson["dns"]; ok { if _, ok := othersJson["dns"]; ok {
(*jsonConfig)["dns"] = othersJson["dns"] (*jsonConfig)["dns"] = othersJson["dns"]
} }
if _, ok := othersJson["inbounds"]; ok {
(*jsonConfig)["inbounds"] = othersJson["inbounds"]
}
if _, ok := othersJson["experimental"]; ok { if _, ok := othersJson["experimental"]; ok {
(*jsonConfig)["experimental"] = othersJson["lexperimentalog"] (*jsonConfig)["experimental"] = othersJson["experimental"]
} }
if _, ok := othersJson["rule_set"]; ok { if _, ok := othersJson["rule_set"]; ok {
route["rule_set"] = othersJson["rule_set"] route["rule_set"] = othersJson["rule_set"]
+84
View File
@@ -62,6 +62,48 @@
></v-select> ></v-select>
</v-col> </v-col>
</v-row> </v-row>
<template v-if="enableInb">
<v-row>
<v-col cols="12" sm="6" md="3">
<v-combobox
v-model="inbounds[0].address"
:items="defaultInb[0].address"
chips
multiple
hide-details
:label="$t('in.addr')"
></v-combobox>
</v-col>
<v-col cols="12" sm="6" md="3" lg="2">
<v-text-field
type="number"
v-model.number="inbounds[0].mtu"
hide-details
label="MTU"
></v-text-field>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="6" md="3">
<v-combobox
v-model="inbounds[0].exclude_package"
:items="['ir.mci.ecareapp','com.myirancell']"
chips
multiple
hide-details
:label="$t('setting.excludePkg')"
></v-combobox>
</v-col>
<v-col cols="12" sm="6" md="3" lg="2">
<v-switch
v-model="platformProxy"
hide-details
color="primary"
label="Platform HTTP proxy"
></v-switch>
</v-col>
</v-row>
</template>
<v-card-actions> <v-card-actions>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-menu v-model="menu" :close-on-content-click="false" location="start"> <v-menu v-model="menu" :close-on-content-click="false" location="start">
@@ -76,6 +118,9 @@
<v-list-item> <v-list-item>
<v-switch v-model="enableDns" color="primary" label="DNS" hide-details></v-switch> <v-switch v-model="enableDns" color="primary" label="DNS" hide-details></v-switch>
</v-list-item> </v-list-item>
<v-list-item>
<v-switch v-model="enableInb" color="primary" :label="$t('objects.inbound')" hide-details></v-switch>
</v-list-item>
<v-list-item> <v-list-item>
<v-switch v-model="enableExp" color="primary" label="Experimental" hide-details></v-switch> <v-switch v-model="enableExp" color="primary" label="Experimental" hide-details></v-switch>
</v-list-item> </v-list-item>
@@ -98,6 +143,36 @@ export default {
"level": "info", "level": "info",
"timestamp": true "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: { defaultExp: {
"clash_api": { "clash_api": {
"external_controller": "127.0.0.1:9090", "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: { enableExp: {
get() :boolean { return this.subJsonExt?.experimental != undefined }, get() :boolean { return this.subJsonExt?.experimental != undefined },
set(v:boolean) { v ? this.subJsonExt.experimental = this.defaultExp : delete this.subJsonExt.experimental } set(v:boolean) { v ? this.subJsonExt.experimental = this.defaultExp : delete this.subJsonExt.experimental }
@@ -298,6 +377,11 @@ export default {
this.updateRuleSets() 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 }, rules():any { return this.subJsonExt?.rules?? undefined },
ruleToDirect: { ruleToDirect: {
get() :string[] { get() :string[] {
+1
View File
@@ -154,6 +154,7 @@ export default {
directDns: "Direct DNS", directDns: "Direct DNS",
toDirectDns: "Route to Direct DNS", toDirectDns: "Route to Direct DNS",
jsonSubOptions: "Other Options", jsonSubOptions: "Other Options",
excludePkg: "Exclude Packages",
}, },
client: { client: {
name: "Name", name: "Name",
+1
View File
@@ -153,6 +153,7 @@ export default {
directDns: "DNS مستقیم", directDns: "DNS مستقیم",
toDirectDns: "هدایت به DNS مستقیم", toDirectDns: "هدایت به DNS مستقیم",
jsonSubOptions: "گزینه‌های دیگر", jsonSubOptions: "گزینه‌های دیگر",
excludePkg: "نرم‌افزارهای استثنا",
}, },
client: { client: {
name: "نام", name: "نام",
+1
View File
@@ -154,6 +154,7 @@ export default {
directDns: "Прямой DNS", directDns: "Прямой DNS",
toDirectDns: "Маршрутизация на Direct DNS", toDirectDns: "Маршрутизация на Direct DNS",
jsonSubOptions: "Другие параметры", jsonSubOptions: "Другие параметры",
excludePkg: "Исключить пакеты",
}, },
client: { client: {
name: "Имя", name: "Имя",
+1
View File
@@ -154,6 +154,7 @@ export default {
directDns: "DNS Trực tiếp", directDns: "DNS Trực tiếp",
toDirectDns: "Chuyển hướng tới DNS Trực tiếp", toDirectDns: "Chuyển hướng tới DNS Trực tiếp",
jsonSubOptions: "Tùy chọn Khác", jsonSubOptions: "Tùy chọn Khác",
excludePkg: "Loại trừ Gói",
}, },
client: { client: {
name: "Tên", name: "Tên",
+1
View File
@@ -154,6 +154,7 @@ export default {
directDns: "直连 DNS", directDns: "直连 DNS",
toDirectDns: "路由到直连 DNS", toDirectDns: "路由到直连 DNS",
jsonSubOptions: "其他选项", jsonSubOptions: "其他选项",
excludePkg: "排除包",
}, },
client: { client: {
name: "名称", name: "名称",
+1
View File
@@ -155,6 +155,7 @@ export default {
directDns: "直連 DNS", directDns: "直連 DNS",
toDirectDns: "路由到直連 DNS", toDirectDns: "路由到直連 DNS",
jsonSubOptions: "其他選項", jsonSubOptions: "其他選項",
excludePkg: "排除包",
}, },
client: { client: {
name: "名稱", name: "名稱",