Skip to content

Commit

Permalink
fixed udp oob buf
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana committed Sep 18, 2023
1 parent 4105aa0 commit b668a76
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/server/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ 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)
ob = pool.GetBuf(1024)
defer pool.ReleaseBuf(ob)
}

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 +88,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 b668a76

Please sign in to comment.