diff options
Diffstat (limited to 'src/irc.c')
| -rw-r--r-- | src/irc.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -1,6 +1,6 @@ /* * Copyright (c) 2002-2003 Erik Fears - * Copyright (c) 2014-2020 ircd-hybrid development team + * Copyright (c) 2014-2021 ircd-hybrid development team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,6 +54,7 @@ #include "negcache.h" #include "memory.h" #include "main.h" +#include "opm_gettime.h" /* @@ -599,9 +600,16 @@ irc_init(void) if (IRCItem.tls_hostname_verification) { +#ifndef LIBRESSL_VERSION_NUMBER SSL_set_hostflags(ssl_handle, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); if (SSL_set1_host(ssl_handle, IRCItem.server) == 0) +#else + X509_VERIFY_PARAM *param = SSL_get0_param(ssl_handle); + X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); + + if (X509_VERIFY_PARAM_set1_host(param, IRCItem.server, 0) == 0) +#endif { log_printf("IRC -> unable to set expected DNS hostname"); /* OpenSSL is unable to verify the server hostname at this point, so we exit. */ @@ -657,20 +665,16 @@ irc_close(void) static void irc_connect(void) { - time_t present; - - time(&present); - /* Only try to reconnect every IRCItem.reconnectinterval seconds */ - if ((present - IRC_LASTRECONNECT) < IRCItem.reconnectinterval) + if ((opm_gettime() - IRC_LASTRECONNECT) < IRCItem.reconnectinterval) { /* Sleep to avoid excessive CPU */ sleep(1); return; } - time(&IRC_LASTRECONNECT); - time(&IRC_LAST); + IRC_LASTRECONNECT = + IRC_LAST = opm_gettime(); irc_init(); @@ -714,7 +718,7 @@ irc_connect(void) IRCItem.username, IRCItem.username, IRCItem.realname); - time(&IRC_LAST); + IRC_LAST = opm_gettime(); } /* irc_parse @@ -774,7 +778,7 @@ irc_parse(void) if (OPT_DEBUG >= 2) log_printf("IRC READ -> %s", IRC_RAW); - time(&IRC_LAST); + IRC_LAST = opm_gettime(); /* Store a copy of IRC_RAW for the handlers (for functions that need PROOF) */ strlcpy(msg, IRC_RAW, sizeof(msg)); @@ -1016,11 +1020,7 @@ irc_send_channels(const char *data, ...) void irc_timer(void) { - time_t present, delta; - - time(&present); - - delta = present - IRC_LAST; + time_t delta = opm_gettime() - IRC_LAST; /* No data in IRCItem.readtimeout seconds */ if (delta >= IRCItem.readtimeout) @@ -1029,7 +1029,7 @@ irc_timer(void) irc_close(); /* Make sure we don't do this again for a while */ - time(&IRC_LAST); + IRC_LAST = opm_gettime(); } else if (delta >= IRCItem.readtimeout / 2) { |
