zygo

ncurses gopher client
Log | Files | Refs

commit 21b92681e8c228a2833b865841848b0fe3a0d45e
parent 8e4578dce73dedf5c13de024b82966de78411ede
Author: hhvn <dev@hhvn.uk>
Date:   Tue, 18 Jan 2022 20:11:26 +0000

zygo.c zygo.1: -u flag for tls upgrading

Diffstat:
Mzygo.1 | 8++++++--
Mzygo.c | 13++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/zygo.1 b/zygo.1 @@ -38,11 +38,12 @@ any links to the same server and port will be accessed over TLS. .Nm will also attempt to upgrade connections to TLS when it encounters a new server -if the +if it is invoked with the +.Fl u +flag, or if the .Ar autotls variable is set in .Ar config.h "." -(Off by default). .Ss Name .Nm is taken from the first four letters of the gopher genus Zygogeomys. @@ -76,6 +77,9 @@ Set the plumber to .Ar plumber "." .It Fl P Do not wait for the plumber to exit. +.It Fl u +Automatically upgrade connections to TLS. +.It Fl .Sh INPUT .Nm is constantly reading input. diff --git a/zygo.c b/zygo.c @@ -490,13 +490,17 @@ go(Elem *e, int mhist, int notls) { move(LINES - 1, 0); clrtoeol(); +#ifdef TLS if (!dup->tls && autotls && !notls && (!current || strcmp(current->server, dup->server) != 0)) { dup->tls = 1; printw("Attempting a TLS connection with %s:%s", dup->server, dup->port); } else { +#endif /* TLS */ printw("Connecting to %s:%s", dup->server, dup->port); +#ifdef TLS } +#endif /* TLS */ refresh(); if ((ret = net_connect(dup, e->tls != dup->tls)) == -1) { @@ -1061,7 +1065,7 @@ sighandler(int signal) { void usage(char *argv0) { - fprintf(stderr, "usage: %s [-kPv] [-p plumber] [uri]\n", basename(argv0)); + fprintf(stderr, "usage: %s [-kPvu] [-p plumber] [uri]\n", basename(argv0)); exit(EXIT_FAILURE); } @@ -1110,6 +1114,13 @@ main(int argc, char *argv[]) { case 'P': parallelplumb = 1; break; + case 'u': +#ifdef TLS + autotls = 1; +#else + error("TLS support not compiled"); +#endif /* TLS */ + break; case 'v': fprintf(stderr, "zygo %s\n", COMMIT); exit(EXIT_SUCCESS);