From cb65b2f4536a6e574e523520f522125dba88d22e Mon Sep 17 00:00:00 2001 From: nite07 Date: Thu, 21 Mar 2024 00:59:47 +0800 Subject: [PATCH] update: vless,vmess parser --- parser/vless.go | 43 ++++++++++++++----------------------------- parser/vmess.go | 14 ++++++++------ 2 files changed, 22 insertions(+), 35 deletions(-) diff --git a/parser/vless.go b/parser/vless.go index 38986f2..1fc12c6 100644 --- a/parser/vless.go +++ b/parser/vless.go @@ -69,34 +69,24 @@ func ParseVless(proxy string) (model.Outbound, error) { } result.VLESSOptions.OutboundTLSOptionsContainer = model.OutboundTLSOptionsContainer{ TLS: &model.OutboundTLSOptions{ - Enabled: true, - ALPN: alpn, - Insecure: params.Get("allowInsecure") == "1", + Enabled: true, + ALPN: alpn, + ServerName: params.Get("sni"), + Insecure: params.Get("allowInsecure") == "1", }, } + if params.Get("fp") != "" { + result.VLESSOptions.OutboundTLSOptionsContainer.TLS.UTLS = &model.OutboundUTLSOptions{ + Enabled: true, + Fingerprint: params.Get("fp"), + } + } } if params.Get("security") == "reality" { - var alpn []string - if strings.Contains(params.Get("alpn"), ",") { - alpn = strings.Split(params.Get("alpn"), ",") - } else { - alpn = nil - } - result.VLESSOptions.OutboundTLSOptionsContainer = model.OutboundTLSOptionsContainer{ - TLS: &model.OutboundTLSOptions{ - Enabled: true, - ServerName: params.Get("sni"), - UTLS: &model.OutboundUTLSOptions{ - Enabled: params.Get("fp") != "", - Fingerprint: params.Get("fp"), - }, - Reality: &model.OutboundRealityOptions{ - Enabled: true, - PublicKey: params.Get("pbk"), - ShortID: params.Get("sid"), - }, - ALPN: alpn, - }, + result.VLESSOptions.OutboundTLSOptionsContainer.TLS.Reality = &model.OutboundRealityOptions{ + Enabled: true, + PublicKey: params.Get("pbk"), + ShortID: params.Get("sid"), } } if params.Get("type") == "ws" { @@ -115,11 +105,6 @@ func ParseVless(proxy string) (model.Outbound, error) { Type: "quic", QUICOptions: model.V2RayQUICOptions{}, } - result.VLESSOptions.OutboundTLSOptionsContainer = model.OutboundTLSOptionsContainer{ - TLS: &model.OutboundTLSOptions{ - Enabled: true, - }, - } } if params.Get("type") == "grpc" { result.VLESSOptions.Transport = &model.V2RayTransportOptions{ diff --git a/parser/vmess.go b/parser/vmess.go index 8bf7b1c..262d871 100644 --- a/parser/vmess.go +++ b/parser/vmess.go @@ -79,9 +79,16 @@ func ParseVmess(proxy string) (model.Outbound, error) { UTLS: &model.OutboundUTLSOptions{ Fingerprint: vmess.Fp, }, - ALPN: alpn, + ALPN: alpn, + ServerName: vmess.Sni, }, } + if vmess.Fp != "" { + result.VMessOptions.OutboundTLSOptionsContainer.TLS.UTLS = &model.OutboundUTLSOptions{ + Enabled: true, + Fingerprint: vmess.Fp, + } + } } if vmess.Net == "ws" { @@ -108,11 +115,6 @@ func ParseVmess(proxy string) (model.Outbound, error) { Type: "quic", QUICOptions: quic, } - result.VMessOptions.OutboundTLSOptionsContainer = model.OutboundTLSOptionsContainer{ - TLS: &model.OutboundTLSOptions{ - Enabled: true, - }, - } } if vmess.Net == "grpc" {