fix(config): Handle null alterId in VMess proxy config (#842)
* fix(config): Gracefully handle null alterId in proxy configurations * Fix wrong AI based changes --------- Co-authored-by: Kittros <yuan364299311@gmail.com>
This commit is contained in:
+5
-1
@@ -129,7 +129,11 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) (
|
|||||||
case "vmess", "vless", "tuic":
|
case "vmess", "vless", "tuic":
|
||||||
proxy["uuid"] = obMap["uuid"]
|
proxy["uuid"] = obMap["uuid"]
|
||||||
if t == "vmess" {
|
if t == "vmess" {
|
||||||
proxy["alterId"] = obMap["alter_id"]
|
if alterId, ok := obMap["alter_id"].(float64); ok {
|
||||||
|
proxy["alterId"] = int(alterId)
|
||||||
|
} else {
|
||||||
|
proxy["alterId"] = 0
|
||||||
|
}
|
||||||
proxy["cipher"] = "auto"
|
proxy["cipher"] = "auto"
|
||||||
}
|
}
|
||||||
if t == "vless" {
|
if t == "vless" {
|
||||||
|
|||||||
+3
-3
@@ -115,9 +115,9 @@ func vmess(data string, i int) (*map[string]interface{}, string, error) {
|
|||||||
if i > 0 {
|
if i > 0 {
|
||||||
tag = fmt.Sprintf("%d.%s", i, tag)
|
tag = fmt.Sprintf("%d.%s", i, tag)
|
||||||
}
|
}
|
||||||
alter_id, ok := dataJson["aid"].(int)
|
alter_id := 0
|
||||||
if !ok {
|
if aid, ok := dataJson["aid"].(float64); ok {
|
||||||
alter_id = 0
|
alter_id = int(aid)
|
||||||
}
|
}
|
||||||
vmess := map[string]interface{}{
|
vmess := map[string]interface{}{
|
||||||
"type": "vmess",
|
"type": "vmess",
|
||||||
|
|||||||
Reference in New Issue
Block a user