change []byte bufpool to *[]byte

This commit is contained in:
ginuerzh
2022-01-06 09:50:37 +08:00
parent 3b48c4acfb
commit f45dc93e92
16 changed files with 98 additions and 86 deletions

View File

@ -23,7 +23,7 @@ func (c *redirConn) Read(b []byte) (n int, err error) {
c.once.Do(func() {
n = copy(b, c.buf)
bufpool.Put(c.buf)
bufpool.Put(&c.buf)
c.buf = nil
})

View File

@ -14,7 +14,7 @@ func (l *redirectListener) listenUDP(addr *net.UDPAddr) (*net.UDPConn, error) {
func (l *redirectListener) accept() (conn net.Conn, err error) {
b := bufpool.Get(l.md.readBufferSize)
n, raddr, dstAddr, err := tproxy.ReadFromUDP(l.ln, b)
n, raddr, dstAddr, err := tproxy.ReadFromUDP(l.ln, *b)
if err != nil {
l.logger.Error(err)
return
@ -30,7 +30,7 @@ func (l *redirectListener) accept() (conn net.Conn, err error) {
conn = &redirConn{
Conn: c,
buf: b[:n],
buf: (*b)[:n],
ttl: l.md.ttl,
}
return