diff options
50 files changed, 237 insertions, 137 deletions
@@ -1,3 +1,8 @@ +-- Noteworthy changes in version 1.1.10 (2021-01-30) +* Timers have been changed to use monotonic time instead of wall-clock time +* Fixed broken build with LibreSSL + + -- Noteworthy changes in version 1.1.9 (2020-11-16) * Implemented support for loading a user-provided private key and tls client certificate. The `irc::rsa_private_key_file`and `irc::tls_certificate_file` diff --git a/config.guess b/config.guess index 0fc11ed..1972fda 100755 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2020 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2020-11-07' +timestamp='2021-01-25' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ timestamp='2020-11-07' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2020 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -138,9 +138,7 @@ UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" @@ -149,16 +147,30 @@ Linux|GNU|GNU/*) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc + #elif defined(__GLIBC__) + LIBC=gnu #else #include <stdarg.h> + /* First heuristic to detect musl libc. */ #ifdef __DEFINED_va_list LIBC=musl - #else - LIBC=gnu #endif #endif EOF eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac @@ -176,10 +188,9 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ - "/sbin/$sysctl" 2>/dev/null || \ - "/usr/sbin/$sysctl" 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)) case "$UNAME_MACHINE_ARCH" in aarch64eb) machine=aarch64_be-unknown ;; @@ -984,6 +995,9 @@ EOF k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; @@ -1072,7 +1086,7 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) @@ -1468,8 +1482,8 @@ EOF i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; - i*86:AROS:*:*) - echo "$UNAME_MACHINE"-pc-aros + *:AROS:*:*) + echo "$UNAME_MACHINE"-unknown-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx @@ -1638,9 +1652,9 @@ This script (version $timestamp), has failed to recognize the operating system you are using. If your script is old, overwrite *all* copies of config.guess and config.sub with the latest versions from: - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub EOF year=$(echo $timestamp | sed 's,-.*,,') @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2020 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2020-11-07' +timestamp='2021-01-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -33,7 +33,7 @@ timestamp='2020-11-07' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2020 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -1185,6 +1185,7 @@ case $cpu-$vendor in | k1om \ | le32 | le64 \ | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ | m32c | m32r | m32rle \ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ @@ -1229,7 +1230,7 @@ case $cpu-$vendor in | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ | pru \ | pyramid \ - | riscv | riscv32 | riscv64 \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ | rl78 | romp | rs6000 | rx \ | s390 | s390x \ | score \ @@ -1241,6 +1242,7 @@ case $cpu-$vendor in | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ | spu \ | tahoe \ + | thumbv7* \ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ | tron \ | ubicom32 \ @@ -1681,11 +1683,14 @@ fi # Now, validate our (potentially fixed-up) OS. case $os in - # Sometimes we do "kernel-abi", so those need to count as OSes. + # Sometimes we do "kernel-libc", so those need to count as OSes. musl* | newlib* | uclibc*) ;; - # Likewise for "kernel-libc" - eabi | eabihf | gnueabi | gnueabihf) + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) ;; # Now accept the basic system types. # The portable systems comes first. @@ -1749,6 +1754,8 @@ case $kernel-$os in ;; kfreebsd*-gnu* | kopensolaris*-gnu*) ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; nto-qnx*) ;; os2-emx) @@ -1,7 +1,7 @@ #! /bin/sh # From configure.ac Id: configure.ac 9677 2020-10-24 11:10:13Z michael . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for hopm 1.1.9. +# Generated by GNU Autoconf 2.69 for hopm 1.1.10. # # Report bugs to <bugs@ircd-hybrid.org>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='hopm' PACKAGE_TARNAME='hopm' -PACKAGE_VERSION='1.1.9' -PACKAGE_STRING='hopm 1.1.9' +PACKAGE_VERSION='1.1.10' +PACKAGE_STRING='hopm 1.1.10' PACKAGE_BUGREPORT='bugs@ircd-hybrid.org' PACKAGE_URL='' @@ -1341,7 +1341,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures hopm 1.1.9 to adapt to many kinds of systems. +\`configure' configures hopm 1.1.10 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1412,7 +1412,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of hopm 1.1.9:";; + short | recursive ) echo "Configuration of hopm 1.1.10:";; esac cat <<\_ACEOF @@ -1537,7 +1537,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -hopm configure 1.1.9 +hopm configure 1.1.10 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1815,7 +1815,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by hopm $as_me 1.1.9, which was +It was created by hopm $as_me 1.1.10, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2678,7 +2678,7 @@ fi # Define the identity of the package. PACKAGE='hopm' - VERSION='1.1.9' + VERSION='1.1.10' cat >>confdefs.h <<_ACEOF @@ -15480,7 +15480,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by hopm $as_me 1.1.9, which was +This file was extended by hopm $as_me 1.1.10, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15546,7 +15546,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -hopm config.status 1.1.9 +hopm config.status 1.1.10 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index f742140..300cb68 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_REVISION([$Id$]) AC_PREREQ(2.69) -AC_INIT([hopm], [1.1.9], [bugs@ircd-hybrid.org]) +AC_INIT([hopm], [1.1.10], [bugs@ircd-hybrid.org]) AM_INIT_AUTOMAKE(1.16.1) AM_MAINTAINER_MODE AC_CONFIG_SRCDIR(src/opercmd.h) diff --git a/doc/reference.conf b/doc/reference.conf index 65a1b6c..0dd86c8 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -1,7 +1,7 @@ /* * Hybrid Open Proxy Monitor - HOPM sample configuration * - * Copyright (c) 2014-2020 ircd-hybrid development team + * Copyright (c) 2014-2021 ircd-hybrid development team * * $Id$ */ diff --git a/src/Makefile.am b/src/Makefile.am index 858547d..826cb8c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = libopm bin_PROGRAMS = hopm -AM_CPPFLAGS = -DHOPM_PREFIX="\"$(prefix)\"" -DHOPM_ETCDIR="\"$(sysconfdir)\"" -DHOPM_LOGDIR="\"$(localstatedir)/log\"" -DHOPM_BINPATH="\"$(bindir)/hopm\"" +AM_CPPFLAGS = -DHOPM_PREFIX="\"$(prefix)\"" -DHOPM_ETCDIR="\"$(sysconfdir)\"" -DHOPM_LOGDIR="\"$(localstatedir)/log\"" -DHOPM_BINPATH="\"$(bindir)/hopm\"" -I$(top_srcdir)/src/libopm/src/ AM_YFLAGS = -d hopm_SOURCES = compat.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 5da1450..a59e252 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -384,7 +384,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = libopm -AM_CPPFLAGS = -DHOPM_PREFIX="\"$(prefix)\"" -DHOPM_ETCDIR="\"$(sysconfdir)\"" -DHOPM_LOGDIR="\"$(localstatedir)/log\"" -DHOPM_BINPATH="\"$(bindir)/hopm\"" +AM_CPPFLAGS = -DHOPM_PREFIX="\"$(prefix)\"" -DHOPM_ETCDIR="\"$(sysconfdir)\"" -DHOPM_LOGDIR="\"$(localstatedir)/log\"" -DHOPM_BINPATH="\"$(bindir)/hopm\"" -I$(top_srcdir)/src/libopm/src/ AM_YFLAGS = -d hopm_SOURCES = compat.c \ compat.h \ diff --git a/src/compat.c b/src/compat.c index 51e30fa..134da9d 100644 --- a/src/compat.c +++ b/src/compat.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 Andy Smith - * 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 diff --git a/src/compat.h b/src/compat.h index 519e681..fc448dd 100644 --- a/src/compat.h +++ b/src/compat.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 Andy Smith - * 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 diff --git a/src/config-lexer.c b/src/config-lexer.c index 4987d2a..6b9f6e1 100644 --- a/src/config-lexer.c +++ b/src/config-lexer.c @@ -866,7 +866,7 @@ char *yytext; #line 1 "config-lexer.l" /* * Copyright (c) 2002 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 diff --git a/src/config-lexer.l b/src/config-lexer.l index e7a9afc..db4423c 100644 --- a/src/config-lexer.l +++ b/src/config-lexer.l @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/config-parser.y b/src/config-parser.y index 6db1406..e2f0bfb 100644 --- a/src/config-parser.y +++ b/src/config-parser.y @@ -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 diff --git a/src/config.c b/src/config.c index 30a02ed..773bc3f 100644 --- a/src/config.c +++ b/src/config.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/config.h b/src/config.h index da468a5..caa0b53 100644 --- a/src/config.h +++ b/src/config.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/dnsbl.c b/src/dnsbl.c index 9082d7a..9299e5f 100644 --- a/src/dnsbl.c +++ b/src/dnsbl.c @@ -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 diff --git a/src/dnsbl.h b/src/dnsbl.h index 746e4af..a40bbac 100644 --- a/src/dnsbl.h +++ b/src/dnsbl.h @@ -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 diff --git a/src/firedns.c b/src/firedns.c index bcee5da..81bf214 100644 --- a/src/firedns.c +++ b/src/firedns.c @@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "list.h" #include "log.h" #include "dnsbl.h" +#include "opm_gettime.h" #define FIREDNS_TRIES 3 @@ -602,7 +603,7 @@ firedns_send_requests(struct s_header *h, struct s_connection *s, int l) return -1; } - time(&s->start); + s->start = opm_gettime(); firedns_fdinuse++; firedns_errno = FDNS_ERR_NONE; @@ -799,7 +800,7 @@ firedns_cycle(void) if (ufds == NULL) ufds = xcalloc(sizeof(*ufds) * OptionsItem.dns_fdlimit); - time(&timenow); + timenow = opm_gettime(); LIST_FOREACH_SAFE(node, node_next, CONNECTIONS.head) { @@ -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) { @@ -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 diff --git a/src/libopm/src/Makefile.am b/src/libopm/src/Makefile.am index 7726c07..b0c9504 100644 --- a/src/libopm/src/Makefile.am +++ b/src/libopm/src/Makefile.am @@ -1,18 +1,20 @@ noinst_LTLIBRARIES = libopm.la -libopm_la_SOURCES = config.c \ - config.h \ - libopm.c \ - libopm.h \ - list.c \ - list.h \ - memory.c \ - memory.h \ - opm_common.h \ - opm_error.h \ - opm.h \ - opm_types.h \ - proxy.c \ +libopm_la_SOURCES = config.c \ + config.h \ + libopm.c \ + libopm.h \ + list.c \ + list.h \ + memory.c \ + memory.h \ + opm_common.h \ + opm_error.h \ + opm.h \ + opm_gettime.c \ + opm_gettime.h \ + opm_types.h \ + proxy.c \ proxy.h libopm_la_LIBADD = @LTLIBOBJS@ diff --git a/src/libopm/src/Makefile.in b/src/libopm/src/Makefile.in index 99bd4d1..4153926 100644 --- a/src/libopm/src/Makefile.in +++ b/src/libopm/src/Makefile.in @@ -112,7 +112,8 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libopm_la_DEPENDENCIES = @LTLIBOBJS@ -am_libopm_la_OBJECTS = config.lo libopm.lo list.lo memory.lo proxy.lo +am_libopm_la_OBJECTS = config.lo libopm.lo list.lo memory.lo \ + opm_gettime.lo proxy.lo libopm_la_OBJECTS = $(am_libopm_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -135,7 +136,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/config.Plo ./$(DEPDIR)/libopm.Plo \ ./$(DEPDIR)/list.Plo ./$(DEPDIR)/memory.Plo \ - ./$(DEPDIR)/proxy.Plo + ./$(DEPDIR)/opm_gettime.Plo ./$(DEPDIR)/proxy.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -307,19 +308,21 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libopm.la -libopm_la_SOURCES = config.c \ - config.h \ - libopm.c \ - libopm.h \ - list.c \ - list.h \ - memory.c \ - memory.h \ - opm_common.h \ - opm_error.h \ - opm.h \ - opm_types.h \ - proxy.c \ +libopm_la_SOURCES = config.c \ + config.h \ + libopm.c \ + libopm.h \ + list.c \ + list.h \ + memory.c \ + memory.h \ + opm_common.h \ + opm_error.h \ + opm.h \ + opm_gettime.c \ + opm_gettime.h \ + opm_types.h \ + proxy.c \ proxy.h libopm_la_LIBADD = @LTLIBOBJS@ @@ -381,6 +384,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopm.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opm_gettime.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxy.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @@ -545,6 +549,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libopm.Plo -rm -f ./$(DEPDIR)/list.Plo -rm -f ./$(DEPDIR)/memory.Plo + -rm -f ./$(DEPDIR)/opm_gettime.Plo -rm -f ./$(DEPDIR)/proxy.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ @@ -595,6 +600,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libopm.Plo -rm -f ./$(DEPDIR)/list.Plo -rm -f ./$(DEPDIR)/memory.Plo + -rm -f ./$(DEPDIR)/opm_gettime.Plo -rm -f ./$(DEPDIR)/proxy.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/src/libopm/src/libopm.c b/src/libopm/src/libopm.c index d6118ff..430a29d 100644 --- a/src/libopm/src/libopm.c +++ b/src/libopm/src/libopm.c @@ -44,6 +44,7 @@ #include "opm_error.h" #include "opm_types.h" #include "opm_common.h" +#include "opm_gettime.h" #include "list.h" #include "proxy.h" @@ -826,7 +827,7 @@ libopm_check_closed(OPM_T *scanner) if (LIST_SIZE(&scanner->scans) == 0) return; - time(&present); + present = opm_gettime(); timeout = *(int *)libopm_config(scanner->config, OPM_CONFIG_TIMEOUT); LIST_FOREACH_SAFE(node1, next1, scanner->scans.head) @@ -964,7 +965,7 @@ libopm_do_connect(OPM_T * scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn) #endif conn->state = OPM_STATE_ESTABLISHED; - time(&conn->creation); /* Stamp creation time, for timeout */ + conn->creation = opm_gettime(); /* Stamp creation time, for timeout */ } /* check_poll diff --git a/src/libopm/src/list.c b/src/libopm/src/list.c index eb237bc..aea809f 100644 --- a/src/libopm/src/list.c +++ b/src/libopm/src/list.c @@ -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 diff --git a/src/libopm/src/list.h b/src/libopm/src/list.h index 20dbef2..ebd0cef 100644 --- a/src/libopm/src/list.h +++ b/src/libopm/src/list.h @@ -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 diff --git a/src/libopm/src/memory.c b/src/libopm/src/memory.c index abde66b..d2c8c3a 100644 --- a/src/libopm/src/memory.c +++ b/src/libopm/src/memory.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/libopm/src/memory.h b/src/libopm/src/memory.h index 268be66..f841fe0 100644 --- a/src/libopm/src/memory.h +++ b/src/libopm/src/memory.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/libopm/src/opm_gettime.c b/src/libopm/src/opm_gettime.c new file mode 100644 index 0000000..e2107b3 --- /dev/null +++ b/src/libopm/src/opm_gettime.c @@ -0,0 +1,40 @@ +/* + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#include <stdlib.h> + +#include "opm_gettime.h" + +time_t +opm_gettime(void) +{ + struct timespec ts; + +#ifdef CLOCK_MONOTONIC_RAW + if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0) +#elif CLOCK_MONOTONIC + if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) +#else + if (clock_gettime(CLOCK_REALTIME, &ts) == 0) +#endif + return ts.tv_sec; + + exit(EXIT_FAILURE); + return -1; +} diff --git a/src/libopm/src/opm_gettime.h b/src/libopm/src/opm_gettime.h new file mode 100644 index 0000000..cba52fb --- /dev/null +++ b/src/libopm/src/opm_gettime.h @@ -0,0 +1,27 @@ +/* + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#ifndef OPM_GETTIME_H +#define OPM_GETTIME_H + +#include <time.h> + +extern time_t opm_gettime(void); +#endif + @@ -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 @@ -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 @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -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 @@ -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 diff --git a/src/match.c b/src/match.c index 7d00da3..3f5473b 100644 --- a/src/match.c +++ b/src/match.c @@ -1,7 +1,7 @@ /* * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) * - * Copyright (c) 1997-2020 ircd-hybrid development team + * Copyright (c) 1997-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 diff --git a/src/match.h b/src/match.h index 5ca4b0d..f0b38ba 100644 --- a/src/match.h +++ b/src/match.h @@ -1,7 +1,7 @@ /* * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) * - * Copyright (c) 1997-2020 ircd-hybrid development team + * Copyright (c) 1997-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 diff --git a/src/memory.c b/src/memory.c index 8e9178d..54347d6 100644 --- a/src/memory.c +++ b/src/memory.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/memory.h b/src/memory.h index a3970fa..67833dc 100644 --- a/src/memory.h +++ b/src/memory.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/negcache.c b/src/negcache.c index 4a36b2a..236b006 100644 --- a/src/negcache.c +++ b/src/negcache.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002-2003 Andy Smith - * 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 @@ -37,6 +37,7 @@ #include "config.h" #include "memory.h" #include "log.h" +#include "opm_gettime.h" extern unsigned int OPT_DEBUG; @@ -72,7 +73,7 @@ negcache_check(const char *ipstr) { struct negcache_item *n = pnode->data; - if (time(NULL) - n->seen <= OptionsItem.negcache) + if (opm_gettime() - n->seen <= OptionsItem.negcache) return n; } @@ -91,7 +92,7 @@ negcache_insert(const char *ipstr) return; /* Malformed IP address or already added to the trie */ struct negcache_item *n = xcalloc(sizeof(*n)); - n->seen = time(NULL); + n->seen = opm_gettime(); pnode->data = n; list_add(pnode, &n->node, &negcache_list); @@ -104,13 +105,14 @@ void negcache_rebuild(void) { node_t *node, *node_next; + time_t present = opm_gettime(); LIST_FOREACH_SAFE(node, node_next, negcache_list.head) { patricia_node_t *pnode = node->data; struct negcache_item *n = pnode->data; - if (n->seen + OptionsItem.negcache < time(NULL)) + if (n->seen + OptionsItem.negcache < present) { if (OPT_DEBUG >= 2) log_printf("NEGCACHE -> Deleting expired negcache node for %s added at %lu", diff --git a/src/negcache.h b/src/negcache.h index 625dcd0..6526b9a 100644 --- a/src/negcache.h +++ b/src/negcache.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002-2003 Andy Smith - * 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 diff --git a/src/opercmd.c b/src/opercmd.c index 8cc6bf7..cb1ed37 100644 --- a/src/opercmd.c +++ b/src/opercmd.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -35,6 +35,7 @@ #include "scan.h" #include "memory.h" #include "stats.h" +#include "opm_gettime.h" static list_t COMMANDS; /* List of active commands */ @@ -108,8 +109,7 @@ command_create(const struct OperCommandHash *tab, const char *param, const char command->tab = tab; command->irc_nick = xstrdup(irc_nick); command->target = target; - - time(&command->added); + command->added = opm_gettime(); return command; } @@ -226,7 +226,7 @@ command_timer(void) { static unsigned int interval; node_t *node, *node_next; - time_t present; + time_t present = opm_gettime(); /* Only perform command removal every OptionsItem.command_interval seconds */ if (interval++ < OptionsItem.command_interval) @@ -234,8 +234,6 @@ command_timer(void) else interval = 0; - time(&present); - LIST_FOREACH_SAFE(node, node_next, COMMANDS.head) { struct Command *command = node->data; diff --git a/src/opercmd.h b/src/opercmd.h index 1a77c07..1d9010d 100644 --- a/src/opercmd.h +++ b/src/opercmd.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/patchlevel.h b/src/patchlevel.h index 415cdac..8950374 100644 --- a/src/patchlevel.h +++ b/src/patchlevel.h @@ -4,5 +4,5 @@ */ #ifndef PATCHLEVEL -#define PATCHLEVEL "hopm-1.1.9" +#define PATCHLEVEL "hopm-1.1.10" #endif @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 diff --git a/src/stats.c b/src/stats.c index dd0ac8c..af6a545 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 @@ -34,7 +34,8 @@ #include "misc.h" #include "config.h" #include "stats.h" -#include "libopm/src/opm_types.h" +#include "opm_types.h" +#include "opm_gettime.h" static time_t STATS_UPTIME; static unsigned int STATS_CONNECTIONS; @@ -67,7 +68,7 @@ static struct StatsHash STATS_PROXIES[] = void stats_init(void) { - time(&STATS_UPTIME); + STATS_UPTIME = opm_gettime(); } /* stats_openproxy @@ -147,13 +148,9 @@ stats_dnsblsend(void) void stats_output(const char *target) { - time_t present; - time_t uptime; + time_t uptime = opm_gettime() - STATS_UPTIME; node_t *p; - time(&present); - uptime = present - STATS_UPTIME; - irc_send("PRIVMSG %s :Uptime: %s", target, time_dissect(uptime)); LIST_FOREACH(p, OpmItem.blacklists.head) diff --git a/src/stats.h b/src/stats.h index fba780c..972cfb1 100644 --- a/src/stats.h +++ b/src/stats.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2002 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 |