014-fix-seed-cannot-be-read-from-vless-sharing-link-and-add-m.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. From 5db722b22b39642280572a62b149d4e1efa21ce3 Mon Sep 17 00:00:00 2001
  2. From: mzz2017 <[email protected]>
  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
  6. ---
  7. service/core/serverObj/v2ray.go | 24 +++++++++++-------------
  8. 1 file changed, 11 insertions(+), 13 deletions(-)
  9. --- a/core/serverObj/v2ray.go
  10. +++ b/core/serverObj/v2ray.go
  11. @@ -12,7 +12,6 @@ import (
  12. "time"
  13. jsoniter "github.com/json-iterator/go"
  14. - "github.com/tidwall/gjson"
  15. "github.com/v2rayA/v2rayA/common"
  16. "github.com/v2rayA/v2rayA/core/coreObj"
  17. "github.com/v2rayA/v2rayA/core/v2ray/service"
  18. @@ -39,6 +38,7 @@ type V2Ray struct {
  19. Net string `json:"net"`
  20. Type string `json:"type"`
  21. Host string `json:"host"`
  22. + SNI string `json:"sni"`
  23. Path string `json:"path"`
  24. TLS string `json:"tls"`
  25. Flow string `json:"flow,omitempty"`
  26. @@ -69,7 +69,8 @@ func ParseVlessURL(vless string) (data *
  27. ID: u.User.String(),
  28. Net: u.Query().Get("type"),
  29. Type: u.Query().Get("headerType"),
  30. - Host: u.Query().Get("sni"),
  31. + Host: u.Query().Get("host"),
  32. + SNI: u.Query().Get("sni"),
  33. Path: u.Query().Get("path"),
  34. TLS: u.Query().Get("security"),
  35. Flow: u.Query().Get("flow"),
  36. @@ -86,16 +87,13 @@ func ParseVlessURL(vless string) (data *
  37. if data.Type == "" {
  38. data.Type = "none"
  39. }
  40. - if data.Host == "" {
  41. - data.Host = u.Query().Get("host")
  42. - }
  43. if data.TLS == "" {
  44. data.TLS = "none"
  45. }
  46. if data.Flow == "" {
  47. data.Flow = "xtls-rprx-direct"
  48. }
  49. - if data.Type == "mkcp" || data.Type == "kcp" {
  50. + if data.Net == "mkcp" || data.Net == "kcp" {
  51. data.Path = u.Query().Get("seed")
  52. }
  53. return data, nil
  54. @@ -145,6 +143,7 @@ func ParseVmessURL(vmess string) (data *
  55. if aid == "" {
  56. aid = q.Get("aid")
  57. }
  58. + sni := q.Get("sni")
  59. info = V2Ray{
  60. ID: subMatch[1],
  61. Add: subMatch[2],
  62. @@ -152,6 +151,7 @@ func ParseVmessURL(vmess string) (data *
  63. Ps: ps,
  64. Host: obfsParam,
  65. Path: path,
  66. + SNI: sni,
  67. Net: obfs,
  68. Aid: aid,
  69. TLS: map[string]string{"1": "tls"}[q.Get("tls")],
  70. @@ -165,12 +165,6 @@ func ParseVmessURL(vmess string) (data *
  71. if err != nil {
  72. return
  73. }
  74. - if info.Host == "" {
  75. - sni := gjson.Get(raw, "sni")
  76. - if sni.Exists() {
  77. - info.Host = sni.String()
  78. - }
  79. - }
  80. }
  81. // correct the wrong vmess as much as possible
  82. if strings.HasPrefix(info.Host, "/") && info.Path == "" {
  83. @@ -328,7 +322,9 @@ func (v *V2Ray) Configuration(info Prior
  84. core.StreamSettings.TLSSettings.AllowInsecure = true
  85. }
  86. // SNI
  87. - if v.Host != "" {
  88. + if v.SNI != "" {
  89. + core.StreamSettings.TLSSettings.ServerName = v.SNI
  90. + } else if v.Host != "" {
  91. core.StreamSettings.TLSSettings.ServerName = v.Host
  92. }
  93. // Alpn
  94. @@ -345,6 +341,8 @@ func (v *V2Ray) Configuration(info Prior
  95. // SNI
  96. if v.Host != "" {
  97. core.StreamSettings.XTLSSettings.ServerName = v.Host
  98. + } else if v.Host != "" {
  99. + core.StreamSettings.TLSSettings.ServerName = v.Host
  100. }
  101. if v.AllowInsecure {
  102. core.StreamSettings.XTLSSettings.AllowInsecure = true