mirror of
https://github.com/cbeuw/Cloak.git
synced 2024-11-15 18:13:29 +00:00
Rename a variable and modify a test
This commit is contained in:
parent
586cc5ebb6
commit
572fe8486a
@ -35,10 +35,10 @@ func MakeObfs(salsaKey [32]byte, payloadCipher cipher.AEAD) Obfser {
|
|||||||
if len(buf) < usefulLen {
|
if len(buf) < usefulLen {
|
||||||
return 0, errors.New("buffer is too small")
|
return 0, errors.New("buffer is too small")
|
||||||
}
|
}
|
||||||
used := buf[:usefulLen]
|
useful := buf[:usefulLen] // tls header + payload + potential overhead
|
||||||
recordLayer := used[0:5]
|
recordLayer := useful[0:5]
|
||||||
header := used[5 : 5+HEADER_LEN]
|
header := useful[5 : 5+HEADER_LEN]
|
||||||
encryptedPayload := used[5+HEADER_LEN:]
|
encryptedPayload := useful[5+HEADER_LEN:]
|
||||||
|
|
||||||
// header: [StreamID 4 bytes][Seq 4 bytes][Closing 1 byte][extraLen 1 bytes][random 2 bytes]
|
// header: [StreamID 4 bytes][Seq 4 bytes][Closing 1 byte][extraLen 1 bytes][random 2 bytes]
|
||||||
putU32(header[0:4], f.StreamID)
|
putU32(header[0:4], f.StreamID)
|
||||||
|
@ -25,14 +25,10 @@ func BenchmarkRecvDataFromRemote(b *testing.B) {
|
|||||||
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
||||||
n, _ := sesh.Obfs(f, obfsBuf)
|
n, _ := sesh.Obfs(f, obfsBuf)
|
||||||
|
|
||||||
originalHeader := make([]byte, 12)
|
|
||||||
copy(originalHeader, obfsBuf[5:17])
|
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sesh.recvDataFromRemote(obfsBuf[:n])
|
sesh.recvDataFromRemote(obfsBuf[:n])
|
||||||
b.SetBytes(int64(n))
|
b.SetBytes(int64(n))
|
||||||
copy(obfsBuf[5:17], originalHeader)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -41,15 +37,10 @@ func BenchmarkRecvDataFromRemote(b *testing.B) {
|
|||||||
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
||||||
n, _ := sesh.Obfs(f, obfsBuf)
|
n, _ := sesh.Obfs(f, obfsBuf)
|
||||||
|
|
||||||
// because deobfs decrypts the header in-place, which alters the input
|
|
||||||
originalHeader := make([]byte, 12)
|
|
||||||
copy(originalHeader, obfsBuf[5:17])
|
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sesh.recvDataFromRemote(obfsBuf[:n])
|
sesh.recvDataFromRemote(obfsBuf[:n])
|
||||||
b.SetBytes(int64(n))
|
b.SetBytes(int64(n))
|
||||||
copy(obfsBuf[5:17], originalHeader)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -58,14 +49,10 @@ func BenchmarkRecvDataFromRemote(b *testing.B) {
|
|||||||
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
sesh := MakeSession(0, UNLIMITED_VALVE, obfuscator, util.ReadTLS)
|
||||||
n, _ := sesh.Obfs(f, obfsBuf)
|
n, _ := sesh.Obfs(f, obfsBuf)
|
||||||
|
|
||||||
originalHeader := make([]byte, 12)
|
|
||||||
copy(originalHeader, obfsBuf[5:17])
|
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sesh.recvDataFromRemote(obfsBuf[:n])
|
sesh.recvDataFromRemote(obfsBuf[:n])
|
||||||
b.SetBytes(int64(n))
|
b.SetBytes(int64(n))
|
||||||
copy(obfsBuf[5:17], originalHeader)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user