address is always in numeric dotted-quad form, and the port is given as
a plain number. On input, DNS hostnames and symbolic port names are
permitted. Name resolution does not block the main server, but will
-block the requesting client. This hopefully makes life simpler for
-stupid clients. Complex clients which don't wish to be held up can open
-extra connections or do the resolution themselves.)
+block the requesting client, unless the command is run in the background.
.PP
If, on input, no recognised address family token is found, the following
words are assumed to represent an
.B INET
-address.
+address. Addresses output by the server always have an address family
+token.
.SS "Key-value output"
Some commands (e.g.,
.B STATS
.B "DAEMON"
Causes the server to disassociate itself from its terminal and become a
background task. This only works once. A warning is issued.
-.TP
+.SP
.BI "EPING \fR[" options "\fR] " peer
Sends an encrypted ping to the peer, and expects an encrypted response.
This checks that the peer is running (and not being impersonated), and
.BI "\-timeout " time
Wait for
.I time
-seconds before giving up on a response. The default is 5 seconds. (The
-time format is the same as for the
-.B "ADD \-keepalive"
-option.)
+seconds before giving up on a response. The default is 5 seconds. The
+.I time
+is expressed as a nonnegative integer followed optionally by
+.BR d ,
+.BR h ,
+.BR m ,
+or
+.BR s
+for days, hours, minutes, or seconds respectively; if no suffix is
+given, seconds are assumed.
.\"-opts
.RE
.SP
.SH "SUMMARY"
.SS "Command responses"
.nf
+.BI "BGDETACH " tag
.BI "BGFAIL " tag " " tokens \fR...
.BI "BGINFO " tag " " tokens \fR...
.BI "BGOK " tag
const char *fmt, va_list ap)
{
dstr d = DSTR_INIT;
+
if (tag) dstr_puts(&d, "BG");
dstr_puts(&d, status);
if (tag) quotify(&d, tag);
const char *fmt, ...)
{
va_list ap;
+
va_start(ap, fmt);
a_vwrite(a, status, tag, fmt, ap);
va_end(ap);
static void a_info(admin *a, const char *fmt, ...)
{
va_list ap;
+
va_start(ap, fmt);
a_vwrite(a, "INFO", 0, fmt, ap);
va_end(ap);
static void a_fail(admin *a, const char *fmt, ...)
{
va_list ap;
+
va_start(ap, fmt);
a_vwrite(a, "FAIL", 0, fmt, ap);
va_end(ap);
dstr_destroy(&d);
}
-static void a_valert(unsigned f_and, unsigned f_eq, const char *tag,
+static void a_valert(unsigned f_and, unsigned f_eq, const char *status,
const char *fmt, va_list ap)
{
dstr d = DSTR_INIT;
if (!(flags & F_INIT))
return;
a_vformat(&d, fmt, ap);
- a_rawalert(f_and, f_eq, tag, fmt ? d.buf : 0, fmt ? d.len : 0);
+ a_rawalert(f_and, f_eq, status, fmt ? d.buf : 0, fmt ? d.len : 0);
dstr_destroy(&d);
}
-static void a_alert(unsigned f_and, unsigned f_eq, const char *tag,
+static void a_alert(unsigned f_and, unsigned f_eq, const char *status,
const char *fmt, ...)
{
va_list ap;
+
va_start(ap, fmt);
- a_valert(f_and, f_eq, tag, fmt, ap);
+ a_valert(f_and, f_eq, status, fmt, ap);
va_end(ap);
}
*/
static void a_sighup(int sig, void *v)
-{
- a_warn("SERVER", "ignore", "signal", "SIGHUP", A_END);
-}
+ { a_warn("SERVER", "ignore", "signal", "SIGHUP", A_END); }
/* --- @a_parsetime@ --- *
*
#endif
static void acmd_watch(admin *a, unsigned ac, char *av[])
-{
- traceish(a, ac, av, "watch", w_opts, &a->f);
-}
+ { traceish(a, ac, av, "watch", w_opts, &a->f); }
static void alertcmd(admin *a, unsigned f_and, unsigned f_eq,
const char *status, char *av[])
{ alertcmd(a, AF_WARN, AF_WARN, "WARN", av); }
static void acmd_port(admin *a, unsigned ac, char *av[])
-{
- a_info(a, "%u", p_port(), A_END);
- a_ok(a);
-}
+ { a_info(a, "%u", p_port(), A_END); a_ok(a); }
static void acmd_daemon(admin *a, unsigned ac, char *av[])
{
static void acmd_list(admin *a, unsigned ac, char *av[])
{
peer *p;
+
for (p = p_first(); p; p = p_next(p))
a_info(a, "%s", p_name(p), A_END);
a_ok(a);
a_info(a, "start-time=%s", timestr(st->t_start), A_END);
a_info(a, "last-packet-time=%s", timestr(st->t_last), A_END);
a_info(a, "last-keyexch-time=%s", timestr(st->t_kx), A_END);
- a_info(a, "packets-in=%lu bytes-in=%lu", st->n_in, st->sz_in, A_END);
- a_info(a, "packets-out=%lu bytes-out=%lu",
- st->n_out, st->sz_out, A_END);
- a_info(a, "keyexch-packets-in=%lu keyexch-bytes-in=%lu",
- st->n_kxin, st->sz_kxin, A_END);
- a_info(a, "keyexch-packets-out=%lu keyexch-bytes-out=%lu",
- st->n_kxout, st->sz_kxout, A_END);
- a_info(a, "ip-packets-in=%lu ip-bytes-in=%lu",
- st->n_ipin, st->sz_ipin, A_END);
- a_info(a, "ip-packets-out=%lu ip-bytes-out=%lu",
- st->n_ipout, st->sz_ipout, A_END);
+ a_info(a, "packets-in=%lu", st->n_in, "bytes-in=%lu", st->sz_in, A_END);
+ a_info(a,
+ "packets-out=%lu", st->n_out,
+ "bytes-out=%lu", st->sz_out,
+ A_END);
+ a_info(a,
+ "keyexch-packets-in=%lu", st->n_kxin,
+ "keyexch-bytes-in=%lu", st->sz_kxin,
+ A_END);
+ a_info(a,
+ "keyexch-packets-out=%lu", st->n_kxout,
+ "keyexch-bytes-out=%lu", st->sz_kxout,
+ A_END);
+ a_info(a,
+ "ip-packets-in=%lu", st->n_ipin,
+ "ip-bytes-in=%lu", st->sz_ipin,
+ A_END);
+ a_info(a,
+ "ip-packets-out=%lu", st->n_ipout,
+ "ip-bytes-out=%lu", st->sz_ipout,
+ A_END);
a_info(a, "rejected-packets=%lu", st->n_reject, A_END);
a_ok(a);
}
static void acmd_kill(admin *a, unsigned ac, char *av[])
{
peer *p;
+
if ((p = a_findpeer(a, av[0])) != 0) {
p_destroy(p);
a_ok(a);
static void acmd_forcekx(admin *a, unsigned ac, char *av[])
{
peer *p;
+
if ((p = a_findpeer(a, av[0])) != 0) {
kx_start(&p->kx, 1);
a_ok(a);
static void acmd_tunnels(admin *a, unsigned ac, char *av[])
{
int i;
+
for (i = 0; tunnels[i]; i++)
a_info(a, "%s", tunnels[i]->name, A_END);
a_ok(a);
static void acmd_help(admin *a, unsigned ac, char *av[])
{
const acmd *c;
+
for (c = acmdtab; c->name; c++) {
if (c->help)
a_info(a, "%s", c->name, "*%s", c->help, A_END);
* Use: Informs the admin module that it's a daemon.
*/
-void a_daemon(void)
-{
- flags |= F_DAEMON;
-}
+void a_daemon(void) { flags |= F_DAEMON; }
/* --- @a_init@ --- *
*