Skip to content

Commit

Permalink
mosdns: fix udp server
Browse files Browse the repository at this point in the history
  • Loading branch information
sbwml committed Sep 19, 2023
1 parent 632f190 commit 1f3883a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions mosdns/patches/110-fixed-715.patch
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

0 comments on commit 1f3883a

Please sign in to comment.