aboutsummaryrefslogtreecommitdiffstats
path: root/src/tai64.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-23 13:41:59 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-23 13:41:59 +0200
commit50aeefcb5198d99777e19f9a0100fe74af630dfb (patch)
tree5e8924cde01e586fcb1f7168946bee46528d70c9 /src/tai64.go
parentBeginning work on TUN interface (diff)
downloadwireguard-go-50aeefcb5198d99777e19f9a0100fe74af630dfb.tar.xz
wireguard-go-50aeefcb5198d99777e19f9a0100fe74af630dfb.zip
Beginning work noise handshake
Diffstat (limited to 'src/tai64.go')
-rw-r--r--src/tai64.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tai64.go b/src/tai64.go
new file mode 100644
index 0000000..d0d1432
--- /dev/null
+++ b/src/tai64.go
@@ -0,0 +1,23 @@
+package main
+
+import (
+ "encoding/binary"
+ "time"
+)
+
+const (
+ TAI64NBase = uint64(4611686018427387914)
+ TAI64NSize = 12
+)
+
+type TAI64N [TAI64NSize]byte
+
+func Timestamp() TAI64N {
+ var tai64n TAI64N
+ now := time.Now()
+ secs := TAI64NBase + uint64(now.Unix())
+ nano := uint32(now.UnixNano())
+ binary.BigEndian.PutUint64(tai64n[:], secs)
+ binary.BigEndian.PutUint32(tai64n[8:], nano)
+ return tai64n
+}