chore: decrease memory copy in sing listener
This commit is contained in:
parent
51004b14d9
commit
150bf7fc65
1 changed files with 8 additions and 6 deletions
|
@ -193,12 +193,6 @@ func (c *packet) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
||||||
err = errors.New("address is invalid")
|
err = errors.New("address is invalid")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buff := buf.NewPacket()
|
|
||||||
defer buff.Release()
|
|
||||||
n, err = buff.Write(b)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.mutex.Lock()
|
c.mutex.Lock()
|
||||||
defer c.mutex.Unlock()
|
defer c.mutex.Unlock()
|
||||||
|
@ -207,6 +201,14 @@ func (c *packet) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
||||||
err = errors.New("writeBack to closed connection")
|
err = errors.New("writeBack to closed connection")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buff := buf.NewPacket()
|
||||||
|
defer buff.Release()
|
||||||
|
n, err = buff.Write(b)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = conn.WritePacket(buff, M.SocksaddrFromNet(addr))
|
err = conn.WritePacket(buff, M.SocksaddrFromNet(addr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue