diff --git a/sub/clashService.go b/sub/clashService.go index a0649f6..d483aee 100644 --- a/sub/clashService.go +++ b/sub/clashService.go @@ -129,7 +129,11 @@ func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}) ( case "vmess", "vless", "tuic": proxy["uuid"] = obMap["uuid"] 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" } if t == "vless" { diff --git a/util/linkToJson.go b/util/linkToJson.go index 8957b90..654c1d9 100644 --- a/util/linkToJson.go +++ b/util/linkToJson.go @@ -115,9 +115,9 @@ func vmess(data string, i int) (*map[string]interface{}, string, error) { if i > 0 { tag = fmt.Sprintf("%d.%s", i, tag) } - alter_id, ok := dataJson["aid"].(int) - if !ok { - alter_id = 0 + alter_id := 0 + if aid, ok := dataJson["aid"].(float64); ok { + alter_id = int(aid) } vmess := map[string]interface{}{ "type": "vmess",