From f51b0040cf88c30dbc1515ceb0e5b0d79948bf61 Mon Sep 17 00:00:00 2001 From: mrchatam Date: Sat, 12 Sep 2026 12:34:10 +0330 Subject: [PATCH] fix(link): map vcn to verifyPeerCertByName in applySecurity (#6479) Go share-link importer dropped verifyPeerCertByName for VLESS/Trojan/SS TLS while the TS parser and Hysteria2 path already kept it. Fixes #6477. Co-authored-by: mrchatam <287639636+mrchatam@users.noreply.github.com> --- internal/util/link/outbound.go | 1 + internal/util/link/outbound_helpers_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/util/link/outbound.go b/internal/util/link/outbound.go index f6206646f..1b762030f 100644 --- a/internal/util/link/outbound.go +++ b/internal/util/link/outbound.go @@ -666,6 +666,7 @@ func applySecurity(stream map[string]any, p url.Values) { tls["alpn"] = splitComma(alpn) } tls["echConfigList"] = p.Get("ech") + tls["verifyPeerCertByName"] = p.Get("vcn") tls["pinnedPeerCertSha256"] = p.Get("pcs") case "reality": re := stream["realitySettings"].(map[string]any) diff --git a/internal/util/link/outbound_helpers_test.go b/internal/util/link/outbound_helpers_test.go index f2bab9ab0..d0b659da6 100644 --- a/internal/util/link/outbound_helpers_test.go +++ b/internal/util/link/outbound_helpers_test.go @@ -123,12 +123,12 @@ func TestParse_RealitySecurityMapped(t *testing.T) { } func TestParse_TLSSecurityMapped(t *testing.T) { - res, err := ParseLink("trojan://pw@h.com:443?type=tcp&security=tls&sni=SNI&fp=chrome&alpn=h2,http/1.1&ech=ECH&pcs=PCS") + res, err := ParseLink("trojan://pw@h.com:443?type=tcp&security=tls&sni=SNI&fp=chrome&alpn=h2,http/1.1&ech=ECH&vcn=VCN&pcs=PCS") if err != nil { t.Fatalf("parse: %v", err) } tls := streamSub(t, res, "tlsSettings") - if tls["serverName"] != "SNI" || tls["fingerprint"] != "chrome" || tls["echConfigList"] != "ECH" || tls["pinnedPeerCertSha256"] != "PCS" { + if tls["serverName"] != "SNI" || tls["fingerprint"] != "chrome" || tls["echConfigList"] != "ECH" || tls["verifyPeerCertByName"] != "VCN" || tls["pinnedPeerCertSha256"] != "PCS" { t.Errorf("tlsSettings fields = %#v", tls) } if alpn, _ := tls["alpn"].([]string); !reflect.DeepEqual(alpn, []string{"h2", "http/1.1"}) {