From d35f5d99e0a8164983eb3d1b2cdbf1779edd50f1 Mon Sep 17 00:00:00 2001 From: mzz2017 Date: Fri, 19 Aug 2022 22:23:19 +0800 Subject: [PATCH] feat(vmess): fuzzily parse allowInsecure --- service/core/serverObj/v2ray.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/core/serverObj/v2ray.go b/service/core/serverObj/v2ray.go index b7db9eda..c3b4bf50 100644 --- a/service/core/serverObj/v2ray.go +++ b/service/core/serverObj/v2ray.go @@ -4,6 +4,8 @@ import ( "encoding/base64" "fmt" jsoniter "github.com/json-iterator/go" + "github.com/tidwall/gjson" + "github.com/tidwall/sjson" "github.com/v2rayA/v2rayA/common" "github.com/v2rayA/v2rayA/common/ntp" "github.com/v2rayA/v2rayA/core/coreObj" @@ -165,6 +167,12 @@ func ParseVmessURL(vmess string) (data *V2Ray, err error) { info.Net = "ws" } } else { + // fuzzily parse allowInsecure + if allowInsecure := gjson.Get(raw, "allowInsecure"); allowInsecure.Exists() { + if newRaw, err := sjson.Set(raw, "allowInsecure", allowInsecure.Bool()); err == nil { + raw = newRaw + } + } err = jsoniter.Unmarshal([]byte(raw), &info) if err != nil { return