mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
conn: add CopyN function
This commit is contained in:
1 parent
c01c2d1839
commit
47e20cf7f4
4 files changed
+28
-4
No files matched your search
@@ -9,6 +9,7 @@ import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/nadoo/glider/common/conn"
|
||||
"github.com/nadoo/glider/common/pool"
|
||||
)
|
||||
|
||||
@@ -38,7 +39,7 @@ func NewConn(c net.Conn, uuid [16]byte, target string) (*Conn, error) {
|
||||
|
||||
buf.WriteByte(Version) // ver
|
||||
buf.Write(uuid[:]) // uuid
|
||||
buf.WriteByte(0) // addinfo
|
||||
buf.WriteByte(0) // addLen
|
||||
buf.WriteByte(CmdTCP) // cmd
|
||||
|
||||
// target
|
||||
@@ -67,8 +68,8 @@ func (c *Conn) Read(b []byte) (n int, err error) {
|
||||
return n, errors.New("version not supported")
|
||||
}
|
||||
|
||||
if addLen := int64(buf[1]); addLen != 0 {
|
||||
io.CopyN(ioutil.Discard, c.Conn, addLen)
|
||||
if addLen := int64(buf[1]); addLen > 0 {
|
||||
conn.CopyN(ioutil.Discard, c.Conn, addLen)
|
||||
}
|
||||
c.rcved = true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user