mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
info printing updates
This commit is contained in:
@@ -45,7 +45,7 @@ int if_idx;
|
||||
|
||||
if (sock != NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
if (nl_failed != 0) /* don't bother re-opening */
|
||||
return -1;
|
||||
|
||||
@@ -85,7 +85,7 @@ error:
|
||||
if (cache != NULL)
|
||||
nl_cache_free(cache);
|
||||
nl_failed = 1;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,9 @@ void print_iface_stats(const char *iface, time_t since, FILE * out)
|
||||
char buf1[32], buf2[32];
|
||||
time_t diff = time(0) - since;
|
||||
|
||||
if (iface == NULL || iface[0] == 0)
|
||||
return;
|
||||
|
||||
if (open_netlink(iface) < 0)
|
||||
return;
|
||||
|
||||
@@ -139,7 +142,7 @@ void print_iface_stats(const char *iface, time_t since, FILE * out)
|
||||
bytes2human(rx, buf1, sizeof(buf1), NULL);
|
||||
bytes2human(tx, buf2, sizeof(buf2), NULL);
|
||||
fprintf(out, "\tRX: %"PRIu64" (%s) TX: %"PRIu64" (%s)\n", rx, buf1, tx, buf2);
|
||||
|
||||
|
||||
value2speed(rx, diff, buf1, sizeof(buf1));
|
||||
value2speed(tx, diff, buf2, sizeof(buf2));
|
||||
fprintf(out, "\tAverage bandwidth RX: %s TX: %s\n", buf1, buf2);
|
||||
|
||||
@@ -55,5 +55,5 @@ void print_time_ival7(time_t t, FILE * fout)
|
||||
fprintf(fout, "%2lum:%02us", t / 60, (unsigned)t % 60);
|
||||
else
|
||||
/* Translation Hint: Seconds:Centiseconds */
|
||||
fprintf(fout, _("%4lus"), t);
|
||||
fprintf(fout, _("%5lus"), t);
|
||||
}
|
||||
|
||||
11
src/occtl.c
11
src/occtl.c
@@ -33,6 +33,7 @@
|
||||
|
||||
#define DEFAULT_TIMEOUT (10*1000)
|
||||
#define NO_GROUP "(none)"
|
||||
#define NO_USER "(none)"
|
||||
|
||||
#define ERR_SERVER_UNREACHABLE "could not send message; is server online?\n"
|
||||
|
||||
@@ -677,7 +678,7 @@ int handle_list_users_cmd(DBusConnection * conn, const char *arg)
|
||||
|
||||
/* add header */
|
||||
if (iteration++ == 0) {
|
||||
fprintf(out, "%6s %8s %8s %14s %14s %6s %7s %14s %9s\n",
|
||||
fprintf(out, "%8s %8s %8s %14s %14s %6s %7s %14s %9s\n",
|
||||
"id", "user", "group", "ip", "vpn-ip", "device",
|
||||
"since", "cipher", "status");
|
||||
}
|
||||
@@ -689,7 +690,10 @@ int handle_list_users_cmd(DBusConnection * conn, const char *arg)
|
||||
if (groupname == NULL || groupname[0] == 0)
|
||||
groupname = NO_GROUP;
|
||||
|
||||
fprintf(out, "%6u %8s %8s %14s %14s %6s ",
|
||||
if (username == NULL || username[0] == 0)
|
||||
username = NO_USER;
|
||||
|
||||
fprintf(out, "%8u %8s %8s %14s %14s %6s ",
|
||||
(unsigned)id, username, groupname, ip, vpn_ip, device);
|
||||
|
||||
print_time_ival7(t, out);
|
||||
@@ -865,6 +869,9 @@ int common_info_cmd(DBusMessageIter * args)
|
||||
goto error_parse;
|
||||
dbus_message_iter_get_basic(&subs, &dtls_ciphersuite);
|
||||
|
||||
if (username == NULL || username[0] == 0)
|
||||
username = NO_USER;
|
||||
|
||||
fprintf(out, "\tUsername: %s ", username);
|
||||
|
||||
if (groupname == NULL || groupname[0] == 0)
|
||||
|
||||
Reference in New Issue
Block a user