fix(quic): preserve user-configured ALPN instead of hardcoding NextProtos

The QUIC listener and the QUIC/ICMP dialers unconditionally set
tlsCfg.NextProtos = ["h3", "quic/v1"], discarding any user-specified
ALPN values from TLS options (via tls.options.alpn in config).

Clone the TLS config and only apply the default NextProtos when none are
already configured, matching the existing pattern in the MASQUE HTTP/3
dialer. This enables non-HTTP/3 QUIC use cases like SMB-over-QUIC which
requires ALPN "smb".

Fixes go-gost/gost#872
This commit is contained in:
ginuerzh
2026-06-20 14:58:19 +08:00
parent c29517be4d
commit 296d87a597
3 changed files with 12 additions and 3 deletions
+4 -1
View File
@@ -133,7 +133,10 @@ func (d *icmpDialer) initSession(ctx context.Context, addr net.Addr, conn net.Pa
}
tlsCfg := d.options.TLSConfig
tlsCfg.NextProtos = []string{"h3", "quic/v1"}
tlsCfg = tlsCfg.Clone()
if len(tlsCfg.NextProtos) == 0 {
tlsCfg.NextProtos = []string{"h3", "quic/v1"}
}
session, err := quic.DialEarly(ctx, conn, addr, tlsCfg, quicConfig)
if err != nil {