mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
1 parent
9eadb8d9f4
commit
a7d0421c93
15 files changed
+422
-171
No files matched your search
@@ -81,10 +81,9 @@ func NewClientConn(c net.Conn, uuid [16]byte, network, target string) (*ClientCo
|
||||
buf.WriteByte(byte(cmd)) // cmd
|
||||
|
||||
// target
|
||||
err = binary.Write(buf, binary.BigEndian, uint16(port)) // port
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var portBuf [2]byte
|
||||
binary.BigEndian.PutUint16(portBuf[:], uint16(port))
|
||||
buf.Write(portBuf[:])
|
||||
buf.WriteByte(byte(atyp)) // atyp
|
||||
buf.Write(addr) //addr
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ func (pc *PktConn) WriteTo(b []byte, addr net.Addr) (int, error) {
|
||||
buf := pool.GetBytesBuffer()
|
||||
defer pool.PutBytesBuffer(buf)
|
||||
|
||||
binary.Write(buf, binary.BigEndian, uint16(len(b)))
|
||||
var hdr [2]byte
|
||||
binary.BigEndian.PutUint16(hdr[:], uint16(len(b)))
|
||||
buf.Write(hdr[:])
|
||||
buf.Write(b)
|
||||
|
||||
n, err := pc.Write(buf.Bytes())
|
||||
|
||||
Reference in new issue
Block a user