fix: Converter panic on bad VMess share links

This commit is contained in:
gVisor bot 2023-04-12 14:40:38 +08:00
parent 4733356a76
commit da1b748348
2 changed files with 20 additions and 11 deletions

View file

@ -9,10 +9,12 @@ const BufferSize = buf.BufferSize
type Buffer = buf.Buffer
var New = buf.New
var StackNew = buf.StackNew
var StackNewSize = buf.StackNewSize
var With = buf.With
var (
New = buf.New
StackNew = buf.StackNew
StackNewSize = buf.StackNewSize
With = buf.With
)
var KeepAlive = common.KeepAlive
@ -21,5 +23,7 @@ func Dup[T any](obj T) T {
return common.Dup(obj)
}
var Must = common.Must
var Error = common.Error
var (
Must = common.Must
Error = common.Error
)

View file

@ -5,10 +5,11 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/Dreamacro/clash/log"
"net/url"
"strconv"
"strings"
"github.com/Dreamacro/clash/log"
)
// ConvertsV2Ray convert V2Ray subscribe proxies data to clash proxies config
@ -201,7 +202,8 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
vmess["servername"] = sni
}
network := strings.ToLower(values["net"].(string))
network, _ := values["net"].(string)
network = strings.ToLower(network)
if values["type"] == "http" {
network = "http"
} else if network == "http" {
@ -209,10 +211,13 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
}
vmess["network"] = network
tls := strings.ToLower(values["tls"].(string))
tls, ok := values["tls"].(string)
if ok {
tls = strings.ToLower(tls)
if strings.HasSuffix(tls, "tls") {
vmess["tls"] = true
}
}
switch network {
case "http":