From 6cd90ae1dd53cbcb7b8e76cc385fdc3bdcc5d2fe Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 28 Sep 2024 00:38:55 +0100 Subject: [PATCH] reuse single buffers --- pkg/udpproxy/session.go | 2 +- pkg/udpproxy/udpproxy.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/udpproxy/session.go b/pkg/udpproxy/session.go index b802742..2d5b2b5 100644 --- a/pkg/udpproxy/session.go +++ b/pkg/udpproxy/session.go @@ -38,8 +38,8 @@ func newSession(caddr *net.UDPAddr, raddr *net.UDPAddr, proxyConn *net.UDPConn) } func (s *session) listen() error { + buf := make([]byte, 2048) for { - buf := make([]byte, 2048) n, err := s.serverConn.Read(buf) if err != nil { log.Error(err) diff --git a/pkg/udpproxy/udpproxy.go b/pkg/udpproxy/udpproxy.go index f2e66c9..6437da9 100644 --- a/pkg/udpproxy/udpproxy.go +++ b/pkg/udpproxy/udpproxy.go @@ -46,8 +46,8 @@ func (c *Client) ListenAndServe() error { go c.pruneSessions() + buf := make([]byte, 2048) for { - buf := make([]byte, 2048) n, caddr, err := c.proxyConn.ReadFromUDP(buf) if err != nil { log.Error(err)