From 3375e13f90549f54a93ac19a787d01720b89c900 Mon Sep 17 00:00:00 2001 From: Rod Hynes Date: Mon, 11 Mar 2024 11:45:05 -0400 Subject: [PATCH] Fix "missing port in address" gQUIC dial failure --- psiphon/common/quic/gquic.go | 7 +++++++ psiphon/common/quic/quic_test.go | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/psiphon/common/quic/gquic.go b/psiphon/common/quic/gquic.go index d39470065..c11cc44ad 100644 --- a/psiphon/common/quic/gquic.go +++ b/psiphon/common/quic/gquic.go @@ -112,6 +112,13 @@ func gQUICDialContext( quicSNIAddress string, versionNumber uint32) (quicConnection, error) { + // The legacy gquic-go fork expects a port number in the SNI field + // (which is then stripped). Add a stub port value if none is present. + _, _, err := net.SplitHostPort(quicSNIAddress) + if err != nil { + quicSNIAddress = net.JoinHostPort(quicSNIAddress, "0") + } + quicConfig := &gquic.Config{ HandshakeTimeout: time.Duration(1<<63 - 1), IdleTimeout: CLIENT_IDLE_TIMEOUT, diff --git a/psiphon/common/quic/quic_test.go b/psiphon/common/quic/quic_test.go index ddda029cc..353ab7425 100644 --- a/psiphon/common/quic/quic_test.go +++ b/psiphon/common/quic/quic_test.go @@ -188,11 +188,16 @@ func runQUIC( } } + quicSNIAddress, _, err := net.SplitHostPort(serverAddress) + if err != nil { + return errors.Trace(err) + } + conn, err := Dial( ctx, packetConn, remoteAddr, - serverAddress, + quicSNIAddress, quicVersion, clientHelloSeed, clientObfuscationKey,