mirror of
https://github.com/alireza0/s-ui.git
synced 2026-08-30 07:09:46 +00:00
optional default routing rules fo json sub #1112
Some checks are pending
Release S-UI / build-frontend (push) Waiting to run
Release S-UI / build-386 (push) Blocked by required conditions
Release S-UI / build-amd64 (push) Blocked by required conditions
Release S-UI / build-armv5 (push) Blocked by required conditions
Release S-UI / build-armv6 (push) Blocked by required conditions
Release S-UI / build-armv7 (push) Blocked by required conditions
Release S-UI / build-arm64 (push) Blocked by required conditions
Release S-UI / build-s390x (push) Blocked by required conditions
Build S-UI for Windows / build-frontend (push) Waiting to run
Build S-UI for Windows / build-windows-amd64 (push) Blocked by required conditions
Build S-UI for Windows / build-windows-arm64 (push) Blocked by required conditions
Some checks are pending
Release S-UI / build-frontend (push) Waiting to run
Release S-UI / build-386 (push) Blocked by required conditions
Release S-UI / build-amd64 (push) Blocked by required conditions
Release S-UI / build-armv5 (push) Blocked by required conditions
Release S-UI / build-armv6 (push) Blocked by required conditions
Release S-UI / build-armv7 (push) Blocked by required conditions
Release S-UI / build-arm64 (push) Blocked by required conditions
Release S-UI / build-s390x (push) Blocked by required conditions
Build S-UI for Windows / build-frontend (push) Waiting to run
Build S-UI for Windows / build-windows-amd64 (push) Blocked by required conditions
Build S-UI for Windows / build-windows-arm64 (push) Blocked by required conditions
This commit is contained in:
parent
839e37c5c3
commit
deb285d8bc
1 changed files with 12 additions and 6 deletions
|
|
@ -251,7 +251,10 @@ func (j *JsonService) addDefaultOutbounds(outbounds *[]map[string]interface{}, o
|
|||
}
|
||||
|
||||
func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
||||
rules_start := []interface{}{
|
||||
// Default routing rules, used only when the template doesn't define its own.
|
||||
// When the template provides `rules`, they are used verbatim so the user has
|
||||
// full control over ordering (e.g. rules before sniff) and which rules exist.
|
||||
defaultRules := []interface{}{
|
||||
map[string]interface{}{
|
||||
"action": "sniff",
|
||||
},
|
||||
|
|
@ -260,8 +263,6 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
|||
"action": "route",
|
||||
"outbound": "direct",
|
||||
},
|
||||
}
|
||||
rules_end := []interface{}{
|
||||
map[string]interface{}{
|
||||
"clash_mode": "Global",
|
||||
"action": "route",
|
||||
|
|
@ -271,7 +272,7 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
|||
route := map[string]interface{}{
|
||||
"auto_detect_interface": true,
|
||||
"final": "proxy",
|
||||
"rules": rules_start,
|
||||
"rules": defaultRules,
|
||||
}
|
||||
|
||||
othersStr, err := j.SettingService.GetSubJsonExt()
|
||||
|
|
@ -303,12 +304,17 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
|||
route["rule_set"] = othersJson["rule_set"]
|
||||
}
|
||||
if settingRules, ok := othersJson["rules"].([]interface{}); ok {
|
||||
rules := append(rules_start, settingRules...)
|
||||
route["rules"] = append(rules, rules_end...)
|
||||
route["rules"] = settingRules
|
||||
}
|
||||
if defaultDomainResolver, ok := othersJson["default_domain_resolver"].(string); ok {
|
||||
route["default_domain_resolver"] = defaultDomainResolver
|
||||
}
|
||||
if v, ok := othersJson["override_android_vpn"]; ok {
|
||||
route["override_android_vpn"] = v
|
||||
}
|
||||
if final, ok := othersJson["final"].(string); ok && final != "" {
|
||||
route["final"] = final
|
||||
}
|
||||
(*jsonConfig)["route"] = route
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue