chore: add WaitReadFrom support in quicStreamPacketConn

This commit is contained in:
wwqgtxx
2023-05-28 15:22:08 +08:00
parent 92f71fd25f
commit 7aae781569
4 changed files with 22 additions and 1 deletions

View File

@ -197,6 +197,22 @@ func (q *quicStreamPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err err
return
}
func (q *quicStreamPacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error) {
if q.inputConn != nil {
var packet Packet
packet, err = ReadPacket(q.inputConn)
if err != nil {
return
}
data = packet.DATA
put = N.NilPut
addr = packet.ADDR.UDPAddr()
} else {
err = net.ErrClosed
}
return
}
func (q *quicStreamPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
if q.udpRelayMode != "quic" && len(p) > q.maxUdpRelayPacketSize {
return 0, quic.ErrMessageTooLarge(q.maxUdpRelayPacketSize)