From 3a2b819786707b1bf5dd42f3240bb65675e9d1a1 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Sun, 28 May 2023 09:33:42 +0800 Subject: [PATCH] chore: add WaitReadFrom support in hyPacketConn --- adapter/outbound/hysteria.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/adapter/outbound/hysteria.go b/adapter/outbound/hysteria.go index 6024ea10..2d5b90ac 100644 --- a/adapter/outbound/hysteria.go +++ b/adapter/outbound/hysteria.go @@ -318,6 +318,17 @@ func (c *hyPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) { return } +func (c *hyPacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error) { + b, addrStr, err := c.UDPConn.ReadFrom() + if err != nil { + return + } + data = b + put = func() {} + addr = M.ParseSocksaddr(addrStr).UDPAddr() + return +} + func (c *hyPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { err = c.UDPConn.WriteTo(p, M.SocksaddrFromNet(addr).String()) if err != nil {