hirc

IRC client
Log | Files | Refs

commit 8fc327cec768c29f0582ce3e0f9136f3013e041d
parent 5b4bd1b9b0a22f9dbacb0addd3aa59b58b6d3788
Author: hhvn <dev@hhvn.uk>
Date:   Thu, 21 Apr 2022 18:45:11 +0100

Fail gracefully with non-tls servers

Diffstat:
Msrc/serv.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/serv.c b/src/serv.c @@ -256,9 +256,7 @@ serv_connect(struct Server *server) { goto fail; } - freeaddrinfo(ai); server->rfd = server->wfd = fd; - server->connectfail = 0; hist_format(server->history, Activity_status, HIST_SHOW|HIST_MAIN, "SELF_CONNECTED %s %s %s", server->name, server->host, server->port); @@ -295,6 +293,13 @@ serv_connect(struct Server *server) { goto fail; } + if (tls_handshake(server->tls_ctx) == -1) { + hist_format(server->history, Activity_error, HIST_SHOW, + "SELF_CONNECTLOST %s %s %s :%s", + server->name, server->host, server->port, tls_error(server->tls_ctx)); + goto fail; + } + tls_config_free(tls_conf); if (tls_peer_cert_provided(server->tls_ctx)) { @@ -312,6 +317,9 @@ serv_connect(struct Server *server) { } #endif /* TLS */ + freeaddrinfo(ai); + server->connectfail = 0; + ircprintf(server, "NICK %s\r\n", server->self->nick); ircprintf(server, "USER %s * * :%s\r\n", server->username ? server->username : server->self->nick,