mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 03:47:38 +03:00
Fix WriteAddrPort usage
This commit is contained in:
parent
0eec7bbe19
commit
03c21c0a12
5 changed files with 39 additions and 14 deletions
|
@ -104,7 +104,10 @@ func (c *AssociatePacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Sock
|
|||
func (c *AssociatePacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
||||
header := buf.With(buffer.ExtendHeader(3 + M.SocksaddrSerializer.AddrPortLen(destination)))
|
||||
common.Must(header.WriteZeroN(3))
|
||||
common.Must(M.SocksaddrSerializer.WriteAddrPort(header, destination))
|
||||
err := M.SocksaddrSerializer.WriteAddrPort(header, destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return common.Error(bufio.WritePacketBuffer(c.NetPacketConn, buffer, c.remoteAddr))
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,10 @@ func (v *VectorisedAssociatePacketConn) WriteVectorisedPacket(buffers []*buf.Buf
|
|||
header := buf.NewSize(3 + M.SocksaddrSerializer.AddrPortLen(destination))
|
||||
defer header.Release()
|
||||
common.Must(header.WriteZeroN(3))
|
||||
common.Must(M.SocksaddrSerializer.WriteAddrPort(header, destination))
|
||||
err := M.SocksaddrSerializer.WriteAddrPort(header, destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return v.VectorisedPacketWriter.WriteVectorisedPacket(append([]*buf.Buffer{header}, buffers...), destination)
|
||||
}
|
||||
|
||||
|
|
|
@ -193,8 +193,11 @@ func WriteRequest(writer io.Writer, request Request) error {
|
|||
buffer.WriteByte(Version),
|
||||
buffer.WriteByte(request.Command),
|
||||
buffer.WriteZero(),
|
||||
M.SocksaddrSerializer.WriteAddrPort(buffer, request.Destination),
|
||||
)
|
||||
err := M.SocksaddrSerializer.WriteAddrPort(buffer, request.Destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rw.WriteBytes(writer, buffer.Bytes())
|
||||
}
|
||||
|
||||
|
@ -244,8 +247,11 @@ func WriteResponse(writer io.Writer, response Response) error {
|
|||
buffer.WriteByte(Version),
|
||||
buffer.WriteByte(response.ReplyCode),
|
||||
buffer.WriteZero(),
|
||||
M.SocksaddrSerializer.WriteAddrPort(buffer, bind),
|
||||
)
|
||||
err := M.SocksaddrSerializer.WriteAddrPort(buffer, bind)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rw.WriteBytes(writer, buffer.Bytes())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue