From c6f1602a58a44d5012ee3be3458233a5f29c01f3 Mon Sep 17 00:00:00 2001 From: Tobias Girstmair Date: Wed, 29 May 2024 20:01:49 +0200 Subject: [PATCH] Revert "allow building without libtls" this is extremely ugly. by keeping in the revision history, it should be cherry-pickable when so desired. This reverts commit 15803f20b91e3dc483fa35c58c2d4267e5f19488. --- ircpipe.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/ircpipe.c b/ircpipe.c index 3608d4e..59a2c63 100644 --- a/ircpipe.c +++ b/ircpipe.c @@ -11,9 +11,7 @@ #include #include -#ifndef DISABLELIBTLS #include -#endif #define DEFAULT_TLS NO_TLS #define DEFAULT_PORT_TCP "6667" @@ -44,20 +42,13 @@ enum tls_use_e { typedef struct { int fd; /* always contains the underlying file descriptor */ -#ifndef DISABLELIBTLS struct tls *tls; /* tls context, or NULL with plain socket */ -#endif } sock_t; -#ifndef DISABLELIBTLS #define _IMPLFN(fn, sock, buf, sz) ( \ sock.tls \ ? tls_ ## fn(sock.tls, buf, sz) \ : fn(sock.fd, buf, sz) \ ) -#else -#define _IMPLFN(fn, sock, buf, sz) \ - fn(sock.fd, buf, sz) -#endif #define READ(sock, buf, sz) _IMPLFN(read, sock, buf, sz) #define WRITE(sock, buf, sz) _IMPLFN(write, sock, buf, sz) @@ -92,7 +83,6 @@ sock_t irc_connect(const char *host, const char *port, const int tls, const char sock.fd = -1; } else { /* connection established. */ -#ifndef DISABLELIBTLS if (tls != NO_TLS) { struct tls *ctx = tls_client(); struct tls_config *cfg = tls_config_new(); @@ -114,7 +104,6 @@ sock_t irc_connect(const char *host, const char *port, const int tls, const char sock.tls = ctx; } else sock.tls = NULL; -#endif /* connect timeout here */ } @@ -295,9 +284,7 @@ int irc_poll(const sock_t sock, const int infd, const int outfd) { if (fds[IRC].revents & POLLIN) { n = READ(sock, buf, BUFSIZ); buf[n] = '\0'; if (n == 0) return -1; /* server closed connection */ -#ifndef DISABLELIBTLS fds[IRC].events = POLLIN | (n==TLS_WANT_POLLOUT?POLLOUT:0); -#endif write(outfd, buf, n); if (irc_answer(sock, buf, want_pong?PING:NO_CMD) & PING) want_pong = 0; @@ -307,15 +294,11 @@ int irc_poll(const sock_t sock, const int infd, const int outfd) { n = read(infd, buf, BUFSIZ); buf[n] = '\0'; if (n == 0) return 0; /* we closed connection */ n = WRITE(sock, buf, n); -#ifndef DISABLELIBTLS fds[IRC].events = POLLIN | (n==TLS_WANT_POLLOUT?POLLOUT:0); -#endif } if (fds[IRC].revents & POLLOUT) { /* needed for TLS only */ n = WRITE(sock, buf, n); -#ifndef DISABLELIBTLS fds[IRC].events = POLLIN | (n==TLS_WANT_POLLOUT?POLLOUT:0); -#endif } if (want_pong && irc_time() - recv_ts > PING_INTERVAL + PONG_TIMEOUT) { @@ -332,12 +315,10 @@ int irc_poll(const sock_t sock, const int infd, const int outfd) { void irc_cleanup(const sock_t sock) { WRITE(sock, "QUIT :ircpipe\r\n", 15); -#ifndef DISABLELIBTLS if (sock.tls) { tls_close(sock.tls); tls_free(sock.tls); } -#endif shutdown(sock.fd, SHUT_RDWR); close(sock.fd); } @@ -377,11 +358,9 @@ int main(int argc, char **argv) { case 'n': nick = optarg; break; case 'p': pass_type = SERVER_PASSWD; break; case 'P': pass_type = SASL_PLAIN_PASSWD; break; - case 'S': tls = NO_TLS; break; -#ifndef DISABLELIBTLS case 's': tls = USE_TLS; break; + case 'S': tls = NO_TLS; break; case 'k': tls = INSECURE_TLS; break; -#endif case 'j': chan = optarg; break; default: irc_help(argv[0], opt != 'h'); } -- 2.39.3