fix: seed cannot be read from vless sharing-link and add missing sni field. #616

This commit is contained in:
mzz2017 committed 2022-08-08 22:37:26 +08:00
1 parent 512e4f3292
commit 5a044e92be
1 file changed
+16 -18
+16 -18
View File
@@ -4,7 +4,6 @@ import (
"encoding/base64"
"fmt"
jsoniter "github.com/json-iterator/go"
"github.com/tidwall/gjson"
"github.com/v2rayA/v2rayA/common"
"github.com/v2rayA/v2rayA/common/ntp"
"github.com/v2rayA/v2rayA/core/coreObj"
@@ -34,11 +33,12 @@ type V2Ray struct {
Port string `json:"port"`
ID string `json:"id"`
Aid string `json:"aid"`
Net string `json:"net,omitempty"`
Type string `json:"type,omitempty"`
Host string `json:"host,omitempty"`
Path string `json:"path,omitempty"`
TLS string `json:"tls,omitempty"`
Net string `json:"net"`
Type string `json:"type"`
Host string `json:"host"`
SNI string `json:"sni"`
Path string `json:"path"`
TLS string `json:"tls"`
Flow string `json:"flow,omitempty"`
Alpn string `json:"alpn,omitempty"`
AllowInsecure bool `json:"allowInsecure"`
@@ -67,7 +67,8 @@ func ParseVlessURL(vless string) (data *V2Ray, err error) {
ID: u.User.String(),
Net: u.Query().Get("type"),
Type: u.Query().Get("headerType"),
Host: u.Query().Get("sni"),
Host: u.Query().Get("host"),
SNI: u.Query().Get("sni"),
Path: u.Query().Get("path"),
TLS: u.Query().Get("security"),
Flow: u.Query().Get("flow"),
@@ -84,16 +85,13 @@ func ParseVlessURL(vless string) (data *V2Ray, err error) {
if data.Type == "" {
data.Type = "none"
}
if data.Host == "" {
data.Host = u.Query().Get("host")
}
if data.TLS == "" {
data.TLS = "none"
}
if data.Flow == "" {
data.Flow = "xtls-rprx-direct"
}
if data.Type == "mkcp" || data.Type == "kcp" {
if data.Net == "mkcp" || data.Net == "kcp" {
data.Path = u.Query().Get("seed")
}
return data, nil
@@ -143,6 +141,7 @@ func ParseVmessURL(vmess string) (data *V2Ray, err error) {
if aid == "" {
aid = q.Get("aid")
}
sni := q.Get("sni")
info = V2Ray{
ID: subMatch[1],
Add: subMatch[2],
@@ -150,6 +149,7 @@ func ParseVmessURL(vmess string) (data *V2Ray, err error) {
Ps: ps,
Host: obfsParam,
Path: path,
SNI: sni,
Net: obfs,
Aid: aid,
TLS: map[string]string{"1": "tls"}[q.Get("tls")],
@@ -163,12 +163,6 @@ func ParseVmessURL(vmess string) (data *V2Ray, err error) {
if err != nil {
return
}
if info.Host == "" {
sni := gjson.Get(raw, "sni")
if sni.Exists() {
info.Host = sni.String()
}
}
}
// correct the wrong vmess as much as possible
if strings.HasPrefix(info.Host, "/") && info.Path == "" {
@@ -323,7 +317,9 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
core.StreamSettings.TLSSettings.AllowInsecure = true
}
// SNI
if v.Host != "" {
if v.SNI != "" {
core.StreamSettings.TLSSettings.ServerName = v.SNI
} else if v.Host != "" {
core.StreamSettings.TLSSettings.ServerName = v.Host
}
// Alpn
@@ -340,6 +336,8 @@ func (v *V2Ray) Configuration(info PriorInfo) (c Configuration, err error) {
// SNI
if v.Host != "" {
core.StreamSettings.XTLSSettings.ServerName = v.Host
} else if v.Host != "" {
core.StreamSettings.TLSSettings.ServerName = v.Host
}
if v.AllowInsecure {
core.StreamSettings.XTLSSettings.AllowInsecure = true