From 91e2a902d867c46bf8267b3a4a39a7bc3ba4d747 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 2ca19bfae..1ece60cde 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,