prettier display
This commit is contained in:
parent
b110ac9d5f
commit
3808a58b42
|
@ -1,4 +1,4 @@
|
||||||
.\" $NetBSD: blacklistctl.8,v 1.3 2015/01/25 23:07:16 wiz Exp $
|
.\" $NetBSD: blacklistctl.8,v 1.4 2015/01/26 02:31:52 christos Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
|
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd January 24, 2015
|
.Dd January 25, 2015
|
||||||
.Dt BLACKLISTCTL 8
|
.Dt BLACKLISTCTL 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -35,8 +35,13 @@
|
||||||
.Nd display and change the state of blacklistd
|
.Nd display and change the state of blacklistd
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
|
<<<<<<< blacklistctl.8
|
||||||
|
dump
|
||||||
|
.Op Fl abdnrw
|
||||||
|
=======
|
||||||
.Cm dump
|
.Cm dump
|
||||||
.Op Fl abdr
|
.Op Fl abdr
|
||||||
|
>>>>>>> 1.3
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
is a program used to display the state of
|
is a program used to display the state of
|
||||||
|
@ -50,8 +55,14 @@ Show all database entries, by default it shows only the embryonic ones.
|
||||||
Show only the blocked entries.
|
Show only the blocked entries.
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Increase debugging level.
|
Increase debugging level.
|
||||||
|
.It Fl n
|
||||||
|
Don't display a header.
|
||||||
.It Fl r
|
.It Fl r
|
||||||
Show the remaining blocked time instead of the last activity time.
|
Show the remaining blocked time instead of the last activity time.
|
||||||
|
.It Fl w
|
||||||
|
Normally the width of addresses is good for IPv4, the
|
||||||
|
.Fl w
|
||||||
|
flag, makes the display wide enough for IPv6 addresses.
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr blacklistd 8
|
.Xr blacklistd 8
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: blacklistctl.c,v 1.14 2015/01/24 15:33:03 christos Exp $ */
|
/* $NetBSD: blacklistctl.c,v 1.15 2015/01/26 02:31:52 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2015 The NetBSD Foundation, Inc.
|
* Copyright (c) 2015 The NetBSD Foundation, Inc.
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: blacklistctl.c,v 1.14 2015/01/24 15:33:03 christos Exp $");
|
__RCSID("$NetBSD: blacklistctl.c,v 1.15 2015/01/26 02:31:52 christos Exp $");
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -60,7 +60,7 @@ usage(int c)
|
||||||
warnx("Missing/unknown command");
|
warnx("Missing/unknown command");
|
||||||
else
|
else
|
||||||
warnx("Unknown option `%c'", (char)c);
|
warnx("Unknown option `%c'", (char)c);
|
||||||
fprintf(stderr, "Usage: %s dump [-abdr]\n", getprogname());
|
fprintf(stderr, "Usage: %s dump [-abdnrw]\n", getprogname());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +74,10 @@ main(int argc, char *argv[])
|
||||||
struct dbinfo dbi;
|
struct dbinfo dbi;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int all, blocked, remain;
|
int all, blocked, remain, wide, noheader;
|
||||||
int o;
|
int o;
|
||||||
|
|
||||||
blocked = all = remain = 0;
|
noheader = wide = blocked = all = remain = 0;
|
||||||
lfun = dlog;
|
lfun = dlog;
|
||||||
|
|
||||||
if (argc == 1 || strcmp(argv[1], "dump") != 0)
|
if (argc == 1 || strcmp(argv[1], "dump") != 0)
|
||||||
|
@ -86,7 +86,7 @@ main(int argc, char *argv[])
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
||||||
while ((o = getopt(argc, argv, "abdr")) != -1)
|
while ((o = getopt(argc, argv, "abdrw")) != -1)
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
|
@ -98,9 +98,14 @@ main(int argc, char *argv[])
|
||||||
case 'd':
|
case 'd':
|
||||||
debug++;
|
debug++;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
noheader = 1;
|
||||||
case 'r':
|
case 'r':
|
||||||
remain = 1;
|
remain = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
wide = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(o);
|
usage(o);
|
||||||
break;
|
break;
|
||||||
|
@ -111,6 +116,10 @@ main(int argc, char *argv[])
|
||||||
err(EXIT_FAILURE, "Can't open `%s'", dbname);
|
err(EXIT_FAILURE, "Can't open `%s'", dbname);
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
wide = wide ? 8 * 4 + 7 : 4 * 3 + 3;
|
||||||
|
if (!noheader)
|
||||||
|
printf("%*.*s:port\tid\tnfail\t%s\n", wide, wide,
|
||||||
|
"address", remain ? "remaining time" : "last access");
|
||||||
for (i = 1; state_iterate(db, &ss, &c, &dbi, i) != 0; i = 0) {
|
for (i = 1; state_iterate(db, &ss, &c, &dbi, i) != 0; i = 0) {
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
if (!all) {
|
if (!all) {
|
||||||
|
@ -123,7 +132,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&ss);
|
sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&ss);
|
||||||
printf("%15.15s:%d\t", buf, c.c_port);
|
printf("%*.*s:%d\t", wide, wide, buf, c.c_port);
|
||||||
if (remain)
|
if (remain)
|
||||||
fmtydhms(buf, sizeof(buf),
|
fmtydhms(buf, sizeof(buf),
|
||||||
c.c_duration - (ts.tv_sec - dbi.last));
|
c.c_duration - (ts.tv_sec - dbi.last));
|
||||||
|
|
Loading…
Reference in New Issue