@@ -48,6 +48,7 @@ type Sessions struct {
48
48
49
49
type SessionProtocol struct {
50
50
s * Sessions
51
+ transport * quic.Transport
51
52
proto string
52
53
streams chan net.Conn
53
54
sessions sync.Map // types.PublicKey -> *activeSession
@@ -60,6 +61,7 @@ type activeSession struct {
60
61
}
61
62
62
63
func NewSessions (log types.Logger , r * router.Router , protos []string ) * Sessions {
64
+ transport := & quic.Transport {Conn : r }
63
65
ctx , cancel := context .WithCancel (context .Background ())
64
66
s := & Sessions {
65
67
r : r ,
@@ -74,9 +76,10 @@ func NewSessions(log types.Logger, r *router.Router, protos []string) *Sessions
74
76
}
75
77
for _ , proto := range protos {
76
78
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 ),
80
83
}
81
84
}
82
85
@@ -87,7 +90,7 @@ func NewSessions(log types.Logger, r *router.Router, protos []string) *Sessions
87
90
NextProtos : protos ,
88
91
}
89
92
90
- listener , err := quic .Listen (r , s .tlsServerCfg , s .quicConfig )
93
+ listener , err := transport .Listen (s .tlsServerCfg , s .quicConfig )
91
94
if err != nil {
92
95
panic (fmt .Errorf ("quic.NewSocketFromPacketConnNoClose: %w" , err ))
93
96
}
0 commit comments