update default config

This commit is contained in:
Alireza Ahmadi
2025-01-11 11:24:45 +01:00
parent 8fb5d3964a
commit 88adcc7c9a
3 changed files with 15 additions and 28 deletions
+1 -2
View File
@@ -26,8 +26,7 @@ var defaultConfig = `{
"protocol": [ "protocol": [
"dns" "dns"
], ],
"outbound": "dns-out", "action": "hijack-dns"
"action": "route"
} }
] ]
}, },
-10
View File
@@ -21,7 +21,6 @@ const defaultJson = `
"mtu": 9000, "mtu": 9000,
"auto_route": true, "auto_route": true,
"strict_route": false, "strict_route": false,
"sniff": true,
"endpoint_independent_nat": false, "endpoint_independent_nat": false,
"stack": "system", "stack": "system",
"platform": { "platform": {
@@ -36,7 +35,6 @@ const defaultJson = `
"type": "mixed", "type": "mixed",
"listen": "127.0.0.1", "listen": "127.0.0.1",
"listen_port": 2080, "listen_port": 2080,
"sniff": true,
"users": [] "users": []
} }
] ]
@@ -204,14 +202,6 @@ func (j *JsonService) addDefaultOutbounds(outbounds *[]map[string]interface{}, o
"type": "direct", "type": "direct",
"tag": "direct", "tag": "direct",
}, },
{
"type": "dns",
"tag": "dns-out",
},
{
"type": "block",
"tag": "block",
},
} }
*outbounds = append(outbound, *outbounds...) *outbounds = append(outbound, *outbounds...)
} }
+14 -16
View File
@@ -153,7 +153,6 @@ export default {
"mtu": 9000, "mtu": 9000,
"auto_route": true, "auto_route": true,
"strict_route": false, "strict_route": false,
"sniff": true,
"endpoint_independent_nat": false, "endpoint_independent_nat": false,
"stack": "system", "stack": "system",
"exclude_package": [], "exclude_package": [],
@@ -169,7 +168,6 @@ export default {
"type": "mixed", "type": "mixed",
"listen": "127.0.0.1", "listen": "127.0.0.1",
"listen_port": 2080, "listen_port": 2080,
"sniff": true,
"users": [] "users": []
} }
], ],
@@ -199,24 +197,24 @@ export default {
"tag": "local-dns", "tag": "local-dns",
"address": "local", "address": "local",
"detour": "direct" "detour": "direct"
},
{
"address": "rcode://success",
"tag": "block"
} }
], ],
"rules": [ "rules": [
{ {
"clash_mode": "Global", "clash_mode": "Global",
"source_ip_cidr": [ "source_ip_cidr": [
"172.19.0.0/30" "172.19.0.0/30",
"fdfe:dcba:9876::1/126"
], ],
"action": "route",
"server": "proxy-dns" "server": "proxy-dns"
}, },
{ {
"source_ip_cidr": [ "source_ip_cidr": [
"172.19.0.0/30" "172.19.0.0/30",
"fdfe:dcba:9876::1/126"
], ],
"action": "route",
"server": "proxy-dns" "server": "proxy-dns"
} }
], ],
@@ -319,10 +317,10 @@ export default {
if (v) { if (v) {
this.subJsonExt.dns = this.defaultDns this.subJsonExt.dns = this.defaultDns
if (this.rules == undefined) this.subJsonExt.rules = [] if (this.rules == undefined) this.subJsonExt.rules = []
this.subJsonExt.rules.unshift({ protocol: "dns", outbound: "dns-out" }) this.subJsonExt.rules.unshift({ protocol: "dns", action: "hijack-dns" })
} else { } else {
delete this.subJsonExt.dns delete this.subJsonExt.dns
const ruleDnsIndex = this.subJsonExt?.rules?.findIndex((r:any) => r.protocol == "dns" && r.outbound == "dns-out") const ruleDnsIndex = this.subJsonExt?.rules?.findIndex((r:any) => r.protocol == "dns" && r.action == "hijack-dns")
if (ruleDnsIndex >= 0) this.subJsonExt.rules.splice(ruleDnsIndex,1) if (ruleDnsIndex >= 0) this.subJsonExt.rules.splice(ruleDnsIndex,1)
if (this.rules.length == 0) delete this.subJsonExt.rules if (this.rules.length == 0) delete this.subJsonExt.rules
} }
@@ -348,7 +346,7 @@ export default {
if (v?.length>0) { if (v?.length>0) {
if (sIndex === -1) { if (sIndex === -1) {
this.dns.servers.push({ tag: "direct-dns", address: v, detour: "direct" }) this.dns.servers.push({ tag: "direct-dns", address: v, detour: "direct" })
this.dns.rules.push({ clash_mode: "Direct", server: "direct-dns" }) this.dns.rules.push({ clash_mode: "Direct", action: "route", server: "direct-dns" })
} else { } else {
this.dns.servers[sIndex].address = v this.dns.servers[sIndex].address = v
} }
@@ -369,7 +367,7 @@ export default {
if (ruleIndex >= 0){ if (ruleIndex >= 0){
this.dns.rules[ruleIndex].rule_set = v this.dns.rules[ruleIndex].rule_set = v
} else { } else {
this.dns.rules.push({ rule_set: v, server: "direct-dns" }) this.dns.rules.push({ rule_set: v, action: "route", server: "direct-dns" })
} }
} else { } else {
if (ruleIndex != -1) this.dns.rules.splice(ruleIndex,1) if (ruleIndex != -1) this.dns.rules.splice(ruleIndex,1)
@@ -395,7 +393,7 @@ export default {
this.rules[ruleIndex].rule_set = v this.rules[ruleIndex].rule_set = v
} else { } else {
if (this.rules == undefined) this.subJsonExt.rules = [] if (this.rules == undefined) this.subJsonExt.rules = []
this.rules.push({ rule_set: v, outbound: "direct" }) this.rules.push({ rule_set: v, action: "route", outbound: "direct" })
} }
} else { } else {
if (ruleIndex != -1) this.rules.splice(ruleIndex,1) if (ruleIndex != -1) this.rules.splice(ruleIndex,1)
@@ -405,17 +403,17 @@ export default {
}, },
ruleToBlock: { ruleToBlock: {
get() :string[] { get() :string[] {
const ruleIndex = this.rules?.findIndex((r:any) => r.outbound == "block" && Object.hasOwn(r,'rule_set')) const ruleIndex = this.rules?.findIndex((r:any) => r.action == "reject" && Object.hasOwn(r,'rule_set'))
return ruleIndex >= 0 ? this.rules[ruleIndex].rule_set : [] return ruleIndex >= 0 ? this.rules[ruleIndex].rule_set : []
}, },
set(v:string[]) { set(v:string[]) {
const ruleIndex = this.rules?.findIndex((r:any) => r.outbound == "block" && Object.hasOwn(r,'rule_set')) const ruleIndex = this.rules?.findIndex((r:any) => r.action == "reject" && Object.hasOwn(r,'rule_set'))
if (v.length>0) { if (v.length>0) {
if (ruleIndex >= 0){ if (ruleIndex >= 0){
this.rules[ruleIndex].rule_set = v this.rules[ruleIndex].rule_set = v
} else { } else {
if (this.rules == undefined) this.subJsonExt.rules = [] if (this.rules == undefined) this.subJsonExt.rules = []
this.rules.push({ rule_set: v, outbound: "block" }) this.rules.push({ rule_set: v, action: "reject" })
} }
} else { } else {
if (ruleIndex != -1) this.rules.splice(ruleIndex,1) if (ruleIndex != -1) this.rules.splice(ruleIndex,1)