Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Jun 15, 2016
2 parents e8095ee + 932ea6a commit 5c9897e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions shadowsocks/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const (
type Conn struct {
net.Conn
*Cipher
readBuf []byte
writeBuf []byte
chunkId uint32
readBuf []byte
writeBuf []byte
chunkId uint32
}

func NewConn(c net.Conn, cipher *Cipher) *Conn {
Expand Down Expand Up @@ -142,11 +142,19 @@ func (c *Conn) Read(b []byte) (n int, err error) {
}

func (c *Conn) Write(b []byte) (n int, err error) {
nn := len(b)
if c.ota {
chunkId := c.GetAndIncrChunkId()
b = otaReqChunkAuth(c.iv, chunkId, b)
}
return c.write(b)
headerLen := len(b) - nn

n, err = c.write(b)
// Make sure <= 0 <= len(b), where b is the slice passed in.
if n >= headerLen {
n -= headerLen
}
return
}

func (c *Conn) write(b []byte) (n int, err error) {
Expand Down

0 comments on commit 5c9897e

Please sign in to comment.