1 From 5db722b22b39642280572a62b149d4e1efa21ce3 Mon Sep 17 00:00:00 2001
2 From: mzz2017 <mzz@tuta.io>
3 Date: Mon, 8 Aug 2022 22:30:36 +0800
4 Subject: [PATCH] fix: seed cannot be read from vless sharing-link and add
5 missing sni field. #616
8 service/core/serverObj/v2ray.go | 24 +++++++++++-------------
9 1 file changed, 11 insertions(+), 13 deletions(-)
11 --- a/core/serverObj/v2ray.go
12 +++ b/core/serverObj/v2ray.go
13 @@ -12,7 +12,6 @@ import (
16 jsoniter "github.com/json-iterator/go"
17 - "github.com/tidwall/gjson"
18 "github.com/v2rayA/v2rayA/common"
19 "github.com/v2rayA/v2rayA/core/coreObj"
20 "github.com/v2rayA/v2rayA/core/v2ray/service"
21 @@ -39,6 +38,7 @@ type V2Ray struct {
22 Net string `json:"net"`
23 Type string `json:"type"`
24 Host string `json:"host"`
25 + SNI string `json:"sni"`
26 Path string `json:"path"`
27 TLS string `json:"tls"`
28 Flow string `json:"flow,omitempty"`
29 @@ -69,7 +69,8 @@ func ParseVlessURL(vless string) (data *
31 Net: u.Query().Get("type"),
32 Type: u.Query().Get("headerType"),
33 - Host: u.Query().Get("sni"),
34 + Host: u.Query().Get("host"),
35 + SNI: u.Query().Get("sni"),
36 Path: u.Query().Get("path"),
37 TLS: u.Query().Get("security"),
38 Flow: u.Query().Get("flow"),
39 @@ -86,16 +87,13 @@ func ParseVlessURL(vless string) (data *
43 - if data.Host == "" {
44 - data.Host = u.Query().Get("host")
50 data.Flow = "xtls-rprx-direct"
52 - if data.Type == "mkcp" || data.Type == "kcp" {
53 + if data.Net == "mkcp" || data.Net == "kcp" {
54 data.Path = u.Query().Get("seed")
57 @@ -145,6 +143,7 @@ func ParseVmessURL(vmess string) (data *
65 @@ -152,6 +151,7 @@ func ParseVmessURL(vmess string) (data *
72 TLS: map[string]string{"1": "tls"}[q.Get("tls")],
73 @@ -165,12 +165,6 @@ func ParseVmessURL(vmess string) (data *
77 - if info.Host == "" {
78 - sni := gjson.Get(raw, "sni")
80 - info.Host = sni.String()
84 // correct the wrong vmess as much as possible
85 if strings.HasPrefix(info.Host, "/") && info.Path == "" {
86 @@ -328,7 +322,9 @@ func (v *V2Ray) Configuration(info Prior
87 core.StreamSettings.TLSSettings.AllowInsecure = true
92 + core.StreamSettings.TLSSettings.ServerName = v.SNI
93 + } else if v.Host != "" {
94 core.StreamSettings.TLSSettings.ServerName = v.Host
97 @@ -345,6 +341,8 @@ func (v *V2Ray) Configuration(info Prior
100 core.StreamSettings.XTLSSettings.ServerName = v.Host
101 + } else if v.Host != "" {
102 + core.StreamSettings.TLSSettings.ServerName = v.Host
105 core.StreamSettings.XTLSSettings.AllowInsecure = true