allow full config

This commit is contained in:
Hiddify
2024-04-08 09:52:31 +02:00
parent b265886306
commit dd0c3614c9
6 changed files with 27 additions and 15 deletions

View File

@@ -6,16 +6,17 @@ import (
)
type ConfigOptions struct {
LogLevel string `json:"log-level"`
EnableClashApi bool `json:"enable-clash-api"`
ClashApiPort uint16 `json:"clash-api-port"`
ClashApiSecret string `json:"web-secret"`
GeoIPPath string `json:"geoip-path"`
GeoSitePath string `json:"geosite-path"`
Rules []Rule `json:"rules"`
Warp WarpOptions `json:"warp"`
Mux MuxOptions `json:"mux"`
TLSTricks TLSTricks `json:"tls-tricks"`
EnableFullConfig bool `json:"enable-full-config"`
LogLevel string `json:"log-level"`
EnableClashApi bool `json:"enable-clash-api"`
ClashApiPort uint16 `json:"clash-api-port"`
ClashApiSecret string `json:"web-secret"`
GeoIPPath string `json:"geoip-path"`
GeoSitePath string `json:"geosite-path"`
Rules []Rule `json:"rules"`
Warp WarpOptions `json:"warp"`
Mux MuxOptions `json:"mux"`
TLSTricks TLSTricks `json:"tls-tricks"`
DNSOptions
InboundOptions
URLTestOptions

View File

@@ -29,9 +29,9 @@ func ParseConfig(path string, debug bool) ([]byte, error) {
if err != nil {
return nil, err
}
return ParseConfigContent(string(content), debug)
return ParseConfigContent(string(content), debug, false)
}
func ParseConfigContent(contentstr string, debug bool) ([]byte, error) {
func ParseConfigContent(contentstr string, debug bool, enableFullConfig bool) ([]byte, error) {
content := []byte(contentstr)
var jsonObj map[string]interface{} = make(map[string]interface{})
@@ -43,7 +43,12 @@ func ParseConfigContent(contentstr string, debug bool) ([]byte, error) {
if tmpJsonObj["outbounds"] == nil {
jsonObj["outbounds"] = []interface{}{jsonObj}
} else {
jsonObj["outbounds"] = tmpJsonObj["outbounds"]
if enableFullConfig {
jsonObj = tmpJsonObj
} else {
jsonObj["outbounds"] = tmpJsonObj["outbounds"]
}
}
} else if jsonArray, ok := tmpJsonResult.([]map[string]interface{}); ok {
jsonObj["outbounds"] = jsonArray