| 1 |
From: Shengjing Zhu <[email protected]> |
| 2 |
Date: Wed, 16 Aug 2023 17:44:36 +0800 |
| 3 |
Subject: bump quic-go to 0.37.4 |
| 4 |
|
| 5 |
Based on https://github.com/v2fly/v2ray-core/pull/2561 |
| 6 |
--- |
| 7 |
app/dns/nameserver_quic.go | 17 ++++++++++++++--- |
| 8 |
transport/internet/quic/conn.go | 2 +- |
| 9 |
transport/internet/quic/dialer.go | 10 +++++++--- |
| 10 |
transport/internet/quic/hub.go | 12 ++++++++---- |
| 11 |
4 files changed, 30 insertions(+), 11 deletions(-) |
| 12 |
|
| 13 |
diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go |
| 14 |
index 7acfc24..0e9d0fd 100644 |
| 15 |
--- a/app/dns/nameserver_quic.go |
| 16 |
+++ b/app/dns/nameserver_quic.go |
| 17 |
@@ -9,7 +9,7 @@ import ( |
| 18 |
"sync/atomic" |
| 19 |
"time" |
| 20 |
|
| 21 |
- "github.com/lucas-clemente/quic-go" |
| 22 |
+ "github.com/quic-go/quic-go" |
| 23 |
"golang.org/x/net/dns/dnsmessage" |
| 24 |
"golang.org/x/net/http2" |
| 25 |
"v2ray.com/core/common" |
| 26 |
@@ -360,12 +360,23 @@ func (s *QUICNameServer) getConnection() (quic.Connection, error) { |
| 27 |
} |
| 28 |
|
| 29 |
func (s *QUICNameServer) openConnection() (quic.Connection, error) { |
| 30 |
- tlsConfig := tls.Config{} |
| 31 |
+ tlsConfig := tls.Config{ |
| 32 |
+ ServerName: func() string { |
| 33 |
+ switch s.destination.Address.Family() { |
| 34 |
+ case net.AddressFamilyIPv4, net.AddressFamilyIPv6: |
| 35 |
+ return s.destination.Address.IP().String() |
| 36 |
+ case net.AddressFamilyDomain: |
| 37 |
+ return s.destination.Address.Domain() |
| 38 |
+ default: |
| 39 |
+ panic("unknown address family") |
| 40 |
+ } |
| 41 |
+ }(), |
| 42 |
+ } |
| 43 |
quicConfig := &quic.Config{ |
| 44 |
HandshakeIdleTimeout: handshakeIdleTimeout, |
| 45 |
} |
| 46 |
|
| 47 |
- conn, err := quic.DialAddrContext(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig) |
| 48 |
+ conn, err := quic.DialAddr(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig) |
| 49 |
if err != nil { |
| 50 |
return nil, err |
| 51 |
} |
| 52 |
diff --git a/transport/internet/quic/conn.go b/transport/internet/quic/conn.go |
| 53 |
index c59b2a7..c951ada 100644 |
| 54 |
--- a/transport/internet/quic/conn.go |
| 55 |
+++ b/transport/internet/quic/conn.go |
| 56 |
@@ -8,7 +8,7 @@ import ( |
| 57 |
"errors" |
| 58 |
"time" |
| 59 |
|
| 60 |
- "github.com/lucas-clemente/quic-go" |
| 61 |
+ "github.com/quic-go/quic-go" |
| 62 |
"v2ray.com/core/common" |
| 63 |
"v2ray.com/core/common/buf" |
| 64 |
"v2ray.com/core/common/net" |
| 65 |
diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go |
| 66 |
index 7dc891b..b0d1677 100644 |
| 67 |
--- a/transport/internet/quic/dialer.go |
| 68 |
+++ b/transport/internet/quic/dialer.go |
| 69 |
@@ -7,7 +7,7 @@ import ( |
| 70 |
"sync" |
| 71 |
"time" |
| 72 |
|
| 73 |
- "github.com/lucas-clemente/quic-go" |
| 74 |
+ "github.com/quic-go/quic-go" |
| 75 |
"v2ray.com/core/common" |
| 76 |
"v2ray.com/core/common/net" |
| 77 |
"v2ray.com/core/common/task" |
| 78 |
@@ -149,7 +149,6 @@ func (s *clientConnections) openConnection(destAddr net.Addr, config *Config, tl |
| 79 |
} |
| 80 |
|
| 81 |
quicConfig := &quic.Config{ |
| 82 |
- ConnectionIDLength: 12, |
| 83 |
HandshakeIdleTimeout: time.Second * 8, |
| 84 |
MaxIdleTimeout: time.Second * 30, |
| 85 |
} |
| 86 |
@@ -160,7 +159,12 @@ func (s *clientConnections) openConnection(destAddr net.Addr, config *Config, tl |
| 87 |
return nil, err |
| 88 |
} |
| 89 |
|
| 90 |
- conn, err := quic.DialContext(context.Background(), sysConn, destAddr, "", tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig) |
| 91 |
+ tr := quic.Transport{ |
| 92 |
+ Conn: sysConn, |
| 93 |
+ ConnectionIDLength: 12, |
| 94 |
+ } |
| 95 |
+ |
| 96 |
+ conn, err := tr.Dial(context.Background(), destAddr, tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig) |
| 97 |
if err != nil { |
| 98 |
sysConn.Close() |
| 99 |
return nil, err |
| 100 |
diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go |
| 101 |
index d3e0622..eba02da 100644 |
| 102 |
--- a/transport/internet/quic/hub.go |
| 103 |
+++ b/transport/internet/quic/hub.go |
| 104 |
@@ -6,7 +6,7 @@ import ( |
| 105 |
"context" |
| 106 |
"time" |
| 107 |
|
| 108 |
- "github.com/lucas-clemente/quic-go" |
| 109 |
+ "github.com/quic-go/quic-go" |
| 110 |
"v2ray.com/core/common" |
| 111 |
"v2ray.com/core/common/net" |
| 112 |
"v2ray.com/core/common/protocol/tls/cert" |
| 113 |
@@ -18,7 +18,7 @@ import ( |
| 114 |
// Listener is an internet.Listener that listens for TCP connections. |
| 115 |
type Listener struct { |
| 116 |
rawConn *sysConn |
| 117 |
- listener quic.Listener |
| 118 |
+ listener *quic.Listener |
| 119 |
done *done.Instance |
| 120 |
addConn internet.ConnHandler |
| 121 |
} |
| 122 |
@@ -104,7 +104,6 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti |
| 123 |
} |
| 124 |
|
| 125 |
quicConfig := &quic.Config{ |
| 126 |
- ConnectionIDLength: 12, |
| 127 |
HandshakeIdleTimeout: time.Second * 8, |
| 128 |
MaxIdleTimeout: time.Second * 45, |
| 129 |
MaxIncomingStreams: 32, |
| 130 |
@@ -117,7 +116,12 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti |
| 131 |
return nil, err |
| 132 |
} |
| 133 |
|
| 134 |
- qListener, err := quic.Listen(conn, tlsConfig.GetTLSConfig(), quicConfig) |
| 135 |
+ tr := quic.Transport{ |
| 136 |
+ Conn: conn, |
| 137 |
+ ConnectionIDLength: 12, |
| 138 |
+ } |
| 139 |
+ |
| 140 |
+ qListener, err := tr.Listen(tlsConfig.GetTLSConfig(), quicConfig) |
| 141 |
if err != nil { |
| 142 |
conn.Close() |
| 143 |
return nil, err |