fix: Converter panic on bad VMess share links

This commit is contained in:
H1JK 2023-04-12 14:40:38 +08:00
parent e745755a46
commit 836615aac9
2 changed files with 20 additions and 11 deletions

View file

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

View file

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