1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Fix closing quic connections

This commit is contained in:
mcrakhman 2024-10-29 13:20:44 +01:00
parent 3f56f5f5d3
commit b18f615c66
No known key found for this signature in database
GPG key ID: DED12CFEF5B8396B

View file

@ -78,11 +78,26 @@ func (q *quicMultiConn) Close() error {
return q.Connection.CloseWithError(2, "")
}
const (
reset quic.StreamErrorCode = 0
)
type quicNetConn struct {
quic.Stream
localAddr, remoteAddr net.Addr
}
func (q quicNetConn) Close() error {
// From quic docs: https://quic-go.net/docs/quic/streams/
// "Calling Close on a quic.Stream closes the send side of the stream.
// Note that for bidirectional streams, Close only closes the send side of the stream.
// It is still possible to read from the stream until the peer closes or resets the stream."
//
// That's why we cancel read explicitly (same approach used in libp2p)
q.Stream.CancelRead(reset)
return q.Stream.Close()
}
func (q quicNetConn) LocalAddr() net.Addr {
return q.localAddr
}