Skip to content

Commit

Permalink
Restore compatibility with protocol version 4
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Jul 31, 2016
1 parent 35dff7f commit cb0b832
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ func (cnx *ClientConnection) getOperation(h1 []byte, isMove bool) {

func (cnx *ClientConnection) storeOperation(h1 []byte) {
conf, reader, writer := cnx.conf, cnx.reader, cnx.writer
rbuf := make([]byte, 120)
var rbuf []byte
if cnx.clientVersion < 5 {
rbuf = make([]byte, 112)
} else {
rbuf = make([]byte, 120)
}
if _, err := io.ReadFull(reader, rbuf); err != nil {
log.Print(err)
return
Expand All @@ -102,8 +107,15 @@ func (cnx *ClientConnection) storeOperation(h1 []byte) {
return
}
encryptSkID := rbuf[40:48]
ts := rbuf[48:56]
signature := rbuf[56:120]
var ts, signature []byte
if cnx.clientVersion < 5 {
ts = make([]byte, 8)
binary.LittleEndian.PutUint64(ts, uint64(time.Now().Unix()))
signature = rbuf[48:112]
} else {
ts = rbuf[48:56]
signature = rbuf[56:120]
}
opcode := byte('S')

wh2 := auth2store(conf, cnx.clientVersion, h1, opcode, encryptSkID, ts, signature)
Expand Down

0 comments on commit cb0b832

Please sign in to comment.