mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 07:05:06 +03:00
Merge branch 'future' into develop-future
This commit is contained in:
commit
fdb296047b
28 changed files with 1049 additions and 880 deletions
|
@ -251,7 +251,6 @@ func (c *Conn) Read(b []byte) (int, error) {
|
|||
}
|
||||
// Copy results to the output slice and clean up
|
||||
copy(b, bs)
|
||||
util.PutBytes(bs)
|
||||
// Return the number of bytes copied to the slice, along with any error
|
||||
return n, err
|
||||
}
|
||||
|
@ -322,10 +321,11 @@ func (c *Conn) writeNoCopy(msg FlowKeyMessage) error {
|
|||
// returned.
|
||||
func (c *Conn) Write(b []byte) (int, error) {
|
||||
written := len(b)
|
||||
msg := FlowKeyMessage{Message: append(util.GetBytes(), b...)}
|
||||
bs := make([]byte, 0, len(b)+crypto.BoxOverhead)
|
||||
bs = append(bs, b...)
|
||||
msg := FlowKeyMessage{Message: bs}
|
||||
err := c.writeNoCopy(msg)
|
||||
if err != nil {
|
||||
util.PutBytes(msg.Message)
|
||||
written = 0
|
||||
}
|
||||
return written, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue