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:
1 parent
c29517be4d
commit
296d87a597
3 files changed
+12
-3
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -115,7 +115,10 @@ func (d *quicDialer) 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 {
|
||||
|
||||
@@ -110,7 +110,10 @@ func (l *quicListener) Init(md md.Metadata) (err error) {
|
||||
}
|
||||
|
||||
tlsCfg := l.options.TLSConfig
|
||||
tlsCfg.NextProtos = []string{"h3", "quic/v1"}
|
||||
tlsCfg = tlsCfg.Clone()
|
||||
if len(tlsCfg.NextProtos) == 0 {
|
||||
tlsCfg.NextProtos = []string{"h3", "quic/v1"}
|
||||
}
|
||||
|
||||
ln, err := quic.ListenEarly(conn, tlsCfg, config)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user