From 3c3d87c3be4c32b6d4472c974ac313495248eb60 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 23 Mar 2021 19:37:05 -0400 Subject: Add typer -P and -c to connect to pounce Of course, running this full time would really fill up the buffer... --- bin/man1/typer.1 | 11 ++++++++++- bin/typer.c | 21 +++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/man1/typer.1 b/bin/man1/typer.1 index cb00d618..11856406 100644 --- a/bin/man1/typer.1 +++ b/bin/man1/typer.1 @@ -8,7 +8,8 @@ . .Sh SYNOPSIS .Nm -.Op Fl v +.Op Fl Pv +.Op Fl c Ar cert .Op Fl n Ar nick .Op Fl p Ar port .Op Fl u Ar user @@ -21,6 +22,14 @@ is an IRC bot that types all day long. The arguments are as follows: .Bl -tag -width Ds +.It Fl P +Request the +.Sy causal.agency/passive +vendor-specific capability. +.It Fl c Ar cert +Use the TLS client certificate +and private key loaded from +.Ar cert . .It Fl n Ar nick Set the nickname. The default is diff --git a/bin/typer.c b/bin/typer.c index 4842bb95..5ee94515 100644 --- a/bin/typer.c +++ b/bin/typer.c @@ -97,11 +97,15 @@ static void timer(int sig) { int main(int argc, char *argv[]) { const char *host = NULL; const char *port = "6697"; + const char *cert = NULL; const char *nick = "typer"; const char *user = "typer"; + bool passive = false; - for (int opt; 0 < (opt = getopt(argc, argv, "n:p:u:v"));) { + for (int opt; 0 < (opt = getopt(argc, argv, "Pc:n:p:u:v"));) { switch (opt) { + break; case 'P': passive = true; + break; case 'c': cert = optarg; break; case 'n': nick = optarg; break; case 'p': port = optarg; break; case 'u': user = optarg; @@ -119,6 +123,11 @@ int main(int argc, char *argv[]) { struct tls_config *config = tls_config_new(); if (!config) errx(EX_SOFTWARE, "tls_config_new"); + if (cert) { + int error = tls_config_set_keypair_file(config, cert, cert); + if (error) errx(EX_CONFIG, "%s: %s", cert, tls_config_error(config)); + } + int error = tls_configure(client, config); if (error) errx(EX_SOFTWARE, "tls_configure: %s", tls_error(client)); tls_config_free(config); @@ -126,9 +135,13 @@ int main(int argc, char *argv[]) { error = tls_connect(client, host, port); if (error) errx(EX_UNAVAILABLE, "tls_connect: %s", tls_error(client)); - format("CAP REQ message-tags\r\n"); - format("NICK %s\r\n", nick); - format("USER %s 0 * :typer\r\n", user); + format( + "CAP REQ :message-tags%s\r\n" + "NICK %s\r\n" + "USER %s 0 * :typer\r\n", + (passive ? " causal.agency/passive" : ""), + nick, user + ); signal(SIGALRM, timer); struct itimerval itimer = { .it_interval.tv_sec = 5, .it_value.tv_sec = 5 }; -- cgit 1.4.1