-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
From 2eaae3d11ea6b6954e820c48c36b9122e3882562 Mon Sep 17 00:00:00 2001 | ||
From: Irine Sistiana <49315432+IrineSistiana@users.noreply.github.com> | ||
Date: Tue, 19 Sep 2023 07:59:17 +0800 | ||
Subject: [PATCH] fixed #715 | ||
|
||
--- | ||
pkg/server/udp.go | 11 ++++++----- | ||
1 file changed, 6 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/pkg/server/udp.go b/pkg/server/udp.go | ||
index a1e478b..8bb1b85 100644 | ||
--- a/pkg/server/udp.go | ||
+++ b/pkg/server/udp.go | ||
@@ -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) | ||
} | ||
@@ -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)) | ||
} | ||
-- | ||
2.34.8 | ||
|