Skip to content

Commit

Permalink
fixed #715
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Sep 18, 2023
1 parent f6564ca commit f147d37
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/server/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ func (s *UDPServer) ServeUDP(c *net.UDPConn) error {
if err != nil {
return fmt.Errorf("failed to init oob handler, %w", err)
}
var ob *[]byte
var ob []byte
if oobReader != nil {
ob = pool.GetBuf(1024)
defer pool.ReleaseBuf(ob)
obp := pool.GetBuf(1024)
defer pool.ReleaseBuf(obp)
ob = *obp
}

for {
n, oobn, _, remoteAddr, err := c.ReadMsgUDPAddrPort(*rb, *ob)
n, oobn, _, remoteAddr, err := c.ReadMsgUDPAddrPort(*rb, ob)
if err != nil {
return fmt.Errorf("unexpected read err: %w", err)
}
Expand All @@ -88,7 +89,7 @@ func (s *UDPServer) ServeUDP(c *net.UDPConn) error {
var dstIpFromCm net.IP
if oobReader != nil {
var err error
dstIpFromCm, err = oobReader((*ob)[:oobn])
dstIpFromCm, err = oobReader(ob[:oobn])
if err != nil {
s.opts.Logger.Error("failed to get dst address from oob", zap.Error(err))
}
Expand Down

0 comments on commit f147d37

Please sign in to comment.