From f3e99058f9a6976144faac9f682fd0eddcfba721 Mon Sep 17 00:00:00 2001 From: Sanaei Date: Thu, 9 Jul 2026 02:03:05 +0200 Subject: [PATCH] fix(sub): apply host Allow Insecure to Hysteria2 subscription links (#5866) Host.AllowInsecure was only wired into the shared VLESS/VMess/Trojan/Shadowsocks endpoint path (applyEndpointAllowInsecure). Hysteria/Hysteria2 builds its links through its own applyExternalProxyHysteriaParams (raw hysteria2:// link) and buildHysteriaProxy (Clash/Mihomo proxy), neither of which read the host's allowInsecure flag, so a self-signed Hysteria2 host never got insecure=1 or skip-cert-verify: true. Fixes #5865. Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> --- internal/sub/clash_service.go | 3 +++ internal/sub/service.go | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/sub/clash_service.go b/internal/sub/clash_service.go index c77efe420..2ccf2169a 100644 --- a/internal/sub/clash_service.go +++ b/internal/sub/clash_service.go @@ -336,6 +336,9 @@ func (s *SubClashService) buildHysteriaProxy(subReq *SubService, inbound *model. } } } + if insecure, ok := ep["allowInsecure"].(bool); ok && insecure { + proxy["skip-cert-verify"] = true + } // Salamander obfs (Hysteria2). Read the same finalmask.udp[salamander] // block the subscription link generator uses. diff --git a/internal/sub/service.go b/internal/sub/service.go index 625e55d22..913f72f43 100644 --- a/internal/sub/service.go +++ b/internal/sub/service.go @@ -1556,17 +1556,18 @@ func applyExternalProxyTLSParams(ep map[string]any, params map[string]string, se // the inbound's own — Hysteria external proxies are typically alternate // endpoints (port-hop / CDN) fronting the same certificate. func applyExternalProxyHysteriaParams(ep map[string]any, params map[string]string) { - pins, ok := externalProxyPins(ep["pinnedPeerCertSha256"]) - if !ok { - return - } - hexPins := make([]string, 0, len(pins)) - for _, p := range pins { - if s, ok := p.(string); ok { - hexPins = append(hexPins, hysteriaPinHex(s)) + if pins, ok := externalProxyPins(ep["pinnedPeerCertSha256"]); ok { + hexPins := make([]string, 0, len(pins)) + for _, p := range pins { + if s, ok := p.(string); ok { + hexPins = append(hexPins, hysteriaPinHex(s)) + } } + params["pinSHA256"] = strings.Join(hexPins, ",") + } + if ai, ok := ep["allowInsecure"].(bool); ok && ai { + params["insecure"] = "1" } - params["pinSHA256"] = strings.Join(hexPins, ",") } // cloneStreamForExternalProxy returns a shallow clone of stream with