Skip to content

Commit ea4c337

Browse files
committed
Use new quic api
1 parent 0b58977 commit ea4c337

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

sessions/dial.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"net"
2626

2727
"github.com/matrix-org/pinecone/types"
28-
"github.com/quic-go/quic-go"
2928
)
3029

3130
// DialContext dials a given public key using the supplied network.
@@ -87,7 +86,7 @@ retry:
8786
},
8887
}
8988

90-
session.Connection, err = quic.Dial(ctx, s.s.r, addr, tlsConfig, s.s.quicConfig)
89+
session.Connection, err = s.transport.Dial(ctx, addr, tlsConfig, s.s.quicConfig)
9190
session.Unlock()
9291
if err != nil {
9392
if err == context.DeadlineExceeded {

sessions/sessions.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Sessions struct {
4848

4949
type SessionProtocol struct {
5050
s *Sessions
51+
transport *quic.Transport
5152
proto string
5253
streams chan net.Conn
5354
sessions sync.Map // types.PublicKey -> *activeSession
@@ -60,6 +61,7 @@ type activeSession struct {
6061
}
6162

6263
func NewSessions(log types.Logger, r *router.Router, protos []string) *Sessions {
64+
transport := &quic.Transport{Conn: r}
6365
ctx, cancel := context.WithCancel(context.Background())
6466
s := &Sessions{
6567
r: r,
@@ -74,9 +76,10 @@ func NewSessions(log types.Logger, r *router.Router, protos []string) *Sessions
7476
}
7577
for _, proto := range protos {
7678
s.protocols[proto] = &SessionProtocol{
77-
s: s,
78-
proto: proto,
79-
streams: make(chan net.Conn, 1),
79+
s: s,
80+
transport: transport,
81+
proto: proto,
82+
streams: make(chan net.Conn, 1),
8083
}
8184
}
8285

@@ -87,7 +90,7 @@ func NewSessions(log types.Logger, r *router.Router, protos []string) *Sessions
8790
NextProtos: protos,
8891
}
8992

90-
listener, err := quic.Listen(r, s.tlsServerCfg, s.quicConfig)
93+
listener, err := transport.Listen(s.tlsServerCfg, s.quicConfig)
9194
if err != nil {
9295
panic(fmt.Errorf("quic.NewSocketFromPacketConnNoClose: %w", err))
9396
}

0 commit comments

Comments
 (0)