Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wgconfig Show the time of the latest handshake prop...



details:   https://anonhg.NetBSD.org/src/rev/a8bda5de0ab8
branches:  trunk
changeset: 943213:a8bda5de0ab8
user:      tih <tih%NetBSD.org@localhost>
date:      Fri Aug 28 17:17:53 2020 +0000

description:
Show the time of the latest handshake properly formatted.

diffstat:

 usr.sbin/wgconfig/wgconfig.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 9d0f9b1a3a0d -r a8bda5de0ab8 usr.sbin/wgconfig/wgconfig.c
--- a/usr.sbin/wgconfig/wgconfig.c      Fri Aug 28 17:15:04 2020 +0000
+++ b/usr.sbin/wgconfig/wgconfig.c      Fri Aug 28 17:17:53 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $      */
+/*     $NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $ */
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ryota%gmail.com@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: wgconfig.c,v 1.4 2020/08/21 17:51:31 martin Exp $");
+__RCSID("$NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $");
 
 #include <sys/ioctl.h>
 
@@ -241,7 +241,7 @@
 show_peer(prop_dictionary_t peer, const char *prefix, bool show_psk)
 {
        prop_object_t prop_obj;
-       uint64_t sec;
+       time_t sec;
 
        prop_obj = prop_dictionary_get(peer, "public_key");
        if (prop_obj == NULL) {
@@ -265,10 +265,14 @@
 
        handle_allowed_ips(peer, prefix);
 
-       if (prop_dictionary_get_uint64(peer, "last_handshake_time_sec", &sec))
-               printf("%slatest-handshake: %"PRIu64"\n", prefix, sec);
-       else
+       if (prop_dictionary_get_int64(peer, "last_handshake_time_sec", &sec)) {
+               if (sec > 0)
+                       printf("%slatest-handshake: %s", prefix, ctime(&sec));
+               else
+                       printf("%slatest-handshake: (never)\n", prefix);
+       } else {
                printf("%slatest-handshake: (none)\n", prefix);
+       }
 }
 
 static int



Home | Main Index | Thread Index | Old Index