From 26aa9c3b7ede8826b0c4fd18bc1924dbd771957d Mon Sep 17 00:00:00 2001 From: kento2 Date: Wed, 9 Sep 2026 03:26:53 +0200 Subject: [PATCH] add man pages + add -n option to nobotgate-access --- doc/nobotgate-access.1 | 13 +++++++++++++ doc/nobotgate.1 | 24 ++++++++++++++++++++++++ meson.build | 5 +++++ nobotgate-access.c | 19 +++++++++++++++---- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 doc/nobotgate-access.1 create mode 100644 doc/nobotgate.1 diff --git a/doc/nobotgate-access.1 b/doc/nobotgate-access.1 new file mode 100644 index 0000000..76c3356 --- /dev/null +++ b/doc/nobotgate-access.1 @@ -0,0 +1,13 @@ +.TH nobotgate-access 3 +.SH NAME +nobotgate-access \- respond with http +.SH SYNOPSIS +nobotgate-access [-c] PROG ARGS +.SH DESCRIPTION +nobotgate-access is meant to run under a superserver such +as tcpserver(1) or inetd(8). It reads http request headers +from stdin(unless \-n is given), prints http response +OK headers and finally exec's into PROG where the first +argument is set to PROG and the remaining to ARGS. +.SH "SEE ALSO" +nobotgate(1), tcpserver(1), inetd(8) diff --git a/doc/nobotgate.1 b/doc/nobotgate.1 new file mode 100644 index 0000000..9a56157 --- /dev/null +++ b/doc/nobotgate.1 @@ -0,0 +1,24 @@ +.TH nobotgate 3 +.SH NAME +nobotgate \- block bots using http header authentication +.SH SYNOPSIS +nobotgate TOKENFILE VALID INVALID +.SH DESCRIPTION +nobotgate-access is meant to run under a superserver such +as tcpserver(1) or inetd(8). +It reads http request headers from stdin and tries find a +HTTP Bearer token. If no token is found or the token is not +listed in TOKENFILE, it exec's into INVALID. +If a token is found and the token is listed in +TOKENFILE, it exec's into VALID. +.SH "TOKENFILE FORMAT" +The tokenfile is parsed line by line. Empty lines are +ignored. +The token begins at line start and ends at the first space +in the line(the space is not part of the token of course). +.SH "EXAMPLE" +An example tokenfile: + 1234 this is bob's token + abc223-23cm ci/cd token +.SH "SEE ALSO" +nobotgate-access(1), tcpserver(1), inetd(8) diff --git a/meson.build b/meson.build index dd200a5..79eedac 100644 --- a/meson.build +++ b/meson.build @@ -26,3 +26,8 @@ executable('nobotgate', files( executable('nobotgate-access', files( './nobotgate-access.c', ), dependencies:deps, install:true) + +install_man([ + './doc/nobotgate.1', + './doc/nobotgate-access.1', +]) diff --git a/nobotgate-access.c b/nobotgate-access.c index 9472176..e5a4d76 100644 --- a/nobotgate-access.c +++ b/nobotgate-access.c @@ -3,7 +3,9 @@ #include #include -#define dieusage() die(100, argv0, " PROG ARGS"); +#define dieusage() die(100, argv0, " [-n] PROG ARGS"); + +static int consume=1; static void consume_headers(void) { char buf[2048]; @@ -19,12 +21,21 @@ static void consume_headers(void) { int main(int argc, char **argv) { char *header; - (void)argc; + int i; errmsg_iam(*argv); + for (i=1;i