go test: correct tai64n and formatting

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-06-01 19:08:24 +02:00
parent 19c89f3c3a
commit 9fbd187288
1 changed files with 26 additions and 26 deletions

View File

@ -61,7 +61,7 @@ func main() {
now := time.Now()
tai64n := make([]byte, 12)
binary.BigEndian.PutUint64(tai64n[:], 4611686018427387914+uint64(now.Unix()))
binary.BigEndian.PutUint32(tai64n[8:], uint32(now.UnixNano()))
binary.BigEndian.PutUint32(tai64n[8:], uint32(now.Nanosecond()))
initiationPacket := make([]byte, 8)
initiationPacket[0] = 1 // Type: Initiation
initiationPacket[1] = 0 // Reserved
@ -134,9 +134,9 @@ func main() {
pingPacket[1] = 0 // Reserved
pingPacket[2] = 0 // Reserved
pingPacket[3] = 0 // Reserved
binary.LittleEndian.PutUint32(pingPacket[4:], theirIndex)
binary.LittleEndian.PutUint32(pingPacket[4:], theirIndex) // Their index
binary.LittleEndian.PutUint64(pingPacket[8:], 0) // Nonce
pingPacket = sendCipher.Encrypt(pingPacket, nil, pingData)
pingPacket = sendCipher.Encrypt(pingPacket, nil, pingData) // Payload data
if _, err := conn.Write(pingPacket); err != nil {
log.Fatalf("error writing ping message: %s", err)
}
@ -178,7 +178,7 @@ func main() {
keepalivePacket[1] = 0 // Reserved
keepalivePacket[2] = 0 // Reserved
keepalivePacket[3] = 0 // Reserved
binary.LittleEndian.PutUint32(keepalivePacket[4:], theirIndex)
binary.LittleEndian.PutUint32(keepalivePacket[4:], theirIndex) // Their index
binary.LittleEndian.PutUint64(keepalivePacket[8:], 1) // Nonce
keepalivePacket = sendCipher.Encrypt(keepalivePacket, nil, nil) // Empty data means keepalive
if _, err := conn.Write(keepalivePacket); err != nil {