mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
chore: decrease memory copy in sing listener
This commit is contained in:
parent
b24f78b0b2
commit
2bbcfbe198
|
@ -193,12 +193,6 @@ func (c *packet) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
|||
err = errors.New("address is invalid")
|
||||
return
|
||||
}
|
||||
buff := buf.NewPacket()
|
||||
defer buff.Release()
|
||||
n, err = buff.Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.mutex.Lock()
|
||||
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")
|
||||
return
|
||||
}
|
||||
|
||||
buff := buf.NewPacket()
|
||||
defer buff.Release()
|
||||
n, err = buff.Write(b)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = conn.WritePacket(buff, M.SocksaddrFromNet(addr))
|
||||
if err != nil {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue
Block a user