| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- From 5db722b22b39642280572a62b149d4e1efa21ce3 Mon Sep 17 00:00:00 2001
- From: mzz2017 <[email protected]>
- Date: Mon, 8 Aug 2022 22:30:36 +0800
- Subject: [PATCH] fix: seed cannot be read from vless sharing-link and add
- missing sni field. #616
- ---
- service/core/serverObj/v2ray.go | 24 +++++++++++-------------
- 1 file changed, 11 insertions(+), 13 deletions(-)
- --- a/core/serverObj/v2ray.go
- +++ b/core/serverObj/v2ray.go
- @@ -12,7 +12,6 @@ import (
- "time"
-
- jsoniter "github.com/json-iterator/go"
- - "github.com/tidwall/gjson"
- "github.com/v2rayA/v2rayA/common"
- "github.com/v2rayA/v2rayA/core/coreObj"
- "github.com/v2rayA/v2rayA/core/v2ray/service"
- @@ -39,6 +38,7 @@ type V2Ray struct {
- 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"`
- @@ -69,7 +69,8 @@ func ParseVlessURL(vless string) (data *
- 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"),
- @@ -86,16 +87,13 @@ func ParseVlessURL(vless string) (data *
- 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
- @@ -145,6 +143,7 @@ func ParseVmessURL(vmess string) (data *
- if aid == "" {
- aid = q.Get("aid")
- }
- + sni := q.Get("sni")
- info = V2Ray{
- ID: subMatch[1],
- Add: subMatch[2],
- @@ -152,6 +151,7 @@ func ParseVmessURL(vmess string) (data *
- Ps: ps,
- Host: obfsParam,
- Path: path,
- + SNI: sni,
- Net: obfs,
- Aid: aid,
- TLS: map[string]string{"1": "tls"}[q.Get("tls")],
- @@ -165,12 +165,6 @@ func ParseVmessURL(vmess string) (data *
- 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 == "" {
- @@ -328,7 +322,9 @@ func (v *V2Ray) Configuration(info Prior
- 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
- @@ -345,6 +341,8 @@ func (v *V2Ray) Configuration(info Prior
- // 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
|