aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-18 15:22:56 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-18 15:22:56 +0200
commit18714fc4a444f3369dc9ca25e5a6e50343770ea4 (patch)
tree2f517973541ac510895a878c5dd9dff86927d947 /src/config.go
parentFixed file descriptor leak on linux (diff)
downloadwireguard-go-18714fc4a444f3369dc9ca25e5a6e50343770ea4.tar.xz
wireguard-go-18714fc4a444f3369dc9ca25e5a6e50343770ea4.zip
Added last_handshake_time fields to UAPI
Diffstat (limited to 'src/config.go')
-rw-r--r--src/config.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/config.go b/src/config.go
index d92e8d7..ad4ac97 100644
--- a/src/config.go
+++ b/src/config.go
@@ -10,6 +10,7 @@ import (
"strings"
"sync/atomic"
"syscall"
+ "time"
)
const (
@@ -58,8 +59,15 @@ func ipcGetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
if peer.endpoint != nil {
send("endpoint=" + peer.endpoint.String())
}
- send(fmt.Sprintf("tx_bytes=%d", peer.txBytes))
- send(fmt.Sprintf("rx_bytes=%d", peer.rxBytes))
+
+ nano := atomic.LoadInt64(&peer.stats.lastHandshakeNano)
+ secs := nano / time.Second.Nanoseconds()
+ nano %= time.Second.Nanoseconds()
+
+ send(fmt.Sprintf("last_handshake_time_sec=%d", secs))
+ send(fmt.Sprintf("last_handshake_time_nsec=%d", nano))
+ send(fmt.Sprintf("tx_bytes=%d", peer.stats.txBytes))
+ send(fmt.Sprintf("rx_bytes=%d", peer.stats.rxBytes))
send(fmt.Sprintf("persistent_keepalive_interval=%d",
atomic.LoadUint64(&peer.persistentKeepaliveInterval),
))