pading compatibitlity

pull/320/head
Darien Raymond 8 years ago
parent 0b16486fce
commit bc80cc72c7
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -74,6 +74,10 @@ func (v *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ
buffer = append(buffer, v.requestBodyKey...)
buffer = append(buffer, v.responseHeader, byte(header.Option))
padingLen := dice.Roll(16)
if header.Security.Is(protocol.SecurityType_LEGACY) {
// Disable padding in legacy mode for a smooth transition.
padingLen = 0
}
security := byte(padingLen<<4) | byte(header.Security)
buffer = append(buffer, security, byte(0), byte(header.Command))
buffer = header.Port.Bytes(buffer)
@ -90,9 +94,11 @@ func (v *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ
buffer = append(buffer, header.Address.Domain()...)
}
pading := make([]byte, padingLen)
rand.Read(pading)
buffer = append(buffer, pading...)
if padingLen > 0 {
pading := make([]byte, padingLen)
rand.Read(pading)
buffer = append(buffer, pading...)
}
fnv1a := fnv.New32a()
fnv1a.Write(buffer)

Loading…
Cancel
Save