From: Shengjing Zhu <zhsj@debian.org>
Date: Wed, 16 Aug 2023 17:22:31 +0800
Subject: Compatibility with golang-github-lucas-clemente-quic-go 0.37.4

---
 lib/connections/quic_dial.go |  2 +-
 lib/connections/quic_misc.go | 17 ++++++++---------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/connections/quic_dial.go b/lib/connections/quic_dial.go
index d47d3b8..672faba 100644
--- a/lib/connections/quic_dial.go
+++ b/lib/connections/quic_dial.go
@@ -73,7 +73,7 @@ func (d *quicDialer) Dial(ctx context.Context, _ protocol.DeviceID, uri *url.URL
 	ctx, cancel := context.WithTimeout(ctx, quicOperationTimeout)
 	defer cancel()
 
-	session, err := quic.DialContext(ctx, conn, addr, uri.Host, d.tlsCfg, quicConfig)
+	session, err := quic.Dial(ctx, conn, addr, d.tlsCfg, quicConfig)
 	if err != nil {
 		if createdConn != nil {
 			_ = createdConn.Close()
diff --git a/lib/connections/quic_misc.go b/lib/connections/quic_misc.go
index fb8e704..8438a24 100644
--- a/lib/connections/quic_misc.go
+++ b/lib/connections/quic_misc.go
@@ -13,16 +13,15 @@ import (
 	"crypto/tls"
 	"net"
 	"net/url"
+	"time"
 
 	"github.com/lucas-clemente/quic-go"
 )
 
-var (
-	quicConfig = &quic.Config{
-		ConnectionIDLength: 4,
-		KeepAlive:          true,
-	}
-)
+var quicConfig = &quic.Config{
+	MaxIdleTimeout:  30 * time.Second,
+	KeepAlivePeriod: 15 * time.Second,
+}
 
 func quicNetwork(uri *url.URL) string {
 	switch uri.Scheme {
@@ -36,7 +35,7 @@ func quicNetwork(uri *url.URL) string {
 }
 
 type quicTlsConn struct {
-	quic.Session
+	quic.Connection
 	quic.Stream
 	// If we created this connection, we should be the ones closing it.
 	createdConn net.PacketConn
@@ -44,7 +43,7 @@ type quicTlsConn struct {
 
 func (q *quicTlsConn) Close() error {
 	sterr := q.Stream.Close()
-	seerr := q.Session.CloseWithError(0, "closing")
+	seerr := q.Connection.CloseWithError(0, "closing")
 	var pcerr error
 	if q.createdConn != nil {
 		pcerr = q.createdConn.Close()
@@ -59,7 +58,7 @@ func (q *quicTlsConn) Close() error {
 }
 
 func (q *quicTlsConn) ConnectionState() tls.ConnectionState {
-	return q.Session.ConnectionState().TLS.ConnectionState
+	return q.Connection.ConnectionState().TLS
 }
 
 func packetConnUnspecified(conn interface{}) bool {
