mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-07 11:23:12 +02:00
Reformat all source code, using 'make format' (clang-format 21.1.8)
This reformats entire UnrealIRCd source code, according to .clang-format which was previously commited. This is reproducable using clang-format version 21.1.8. These are only visual changes, they have no effect on code. This commit will be added to .git-blame-ignore-revs so 'git blame' and the similar blame view on GitHub will ignore this commit.
This commit is contained in:
+6
-6
@@ -19,20 +19,20 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __channel_include__
|
||||
#ifndef __channel_include__
|
||||
#define __channel_include__
|
||||
#define CREATE 1 /* whether a channel should be created or just tested for existance */
|
||||
#define CREATE 1 /* whether a channel should be created or just tested for existance */
|
||||
|
||||
#define MODEBUFLEN 200
|
||||
#define MAXBANLEN 200 /* Maximum length of a complete ban */
|
||||
#define MODEBUFLEN 200
|
||||
#define MAXBANLEN 200 /* Maximum length of a complete ban */
|
||||
|
||||
#define ChannelExists(n) (find_channel(n))
|
||||
#define ChannelExists(n) (find_channel(n))
|
||||
|
||||
/* NOTE: Timestamps will be added to MODE-commands, so never make
|
||||
* RESYNCMODES and MODEPARAMS higher than MAXPARA-3. DALnet servers
|
||||
* before Dreamforge aren't safe with more than six. -Donwulff
|
||||
*/
|
||||
#include "msg.h"
|
||||
#define MAXMODEPARAMS (MAXPARA_USER-3) /* Maximum modes processed */
|
||||
#define MAXMODEPARAMS (MAXPARA_USER - 3) /* Maximum modes processed */
|
||||
|
||||
#endif
|
||||
|
||||
+81
-81
@@ -19,27 +19,27 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __common_include__
|
||||
#ifndef __common_include__
|
||||
#define __common_include__
|
||||
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <malloc.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
typedef int bool;
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#include "sys.h"
|
||||
@@ -48,48 +48,48 @@ typedef int bool;
|
||||
#include "list.h"
|
||||
|
||||
#ifdef DEVELOP_CVS
|
||||
#define ID_Copyright(x) static char id_copyright[] = x
|
||||
#define ID_Notes(x) static char id_notes[] = x
|
||||
#define ID_Copyright(x) static char id_copyright[] = x
|
||||
#define ID_Notes(x) static char id_notes[] = x
|
||||
#else
|
||||
#define ID_Copyright(x)
|
||||
#define ID_Notes(x)
|
||||
#define ID_Copyright(x)
|
||||
#define ID_Notes(x)
|
||||
#endif
|
||||
|
||||
#define BMAGIC 0x4675636B596F754661736369737473
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DEADBEEF_ADDR 0xDEADBEEFDEADBEEF
|
||||
#define DEADBEEF_ADDR 0xDEADBEEFDEADBEEF
|
||||
#else
|
||||
#define DEADBEEF_ADDR 0xDEADBEEF
|
||||
#define DEADBEEF_ADDR 0xDEADBEEF
|
||||
#endif
|
||||
|
||||
#define BASE_VERSION "UnrealIRCd"
|
||||
#ifndef _WIN32
|
||||
#define FDwrite(x,y,z) write(x, y, z)
|
||||
#define FDwrite(x, y, z) write(x, y, z)
|
||||
#else
|
||||
#define FDwrite(x,y,z) send(x, y, z, 0)
|
||||
#define FDwrite(x, y, z) send(x, y, z, 0)
|
||||
#endif
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#undef TRUE
|
||||
#endif
|
||||
|
||||
#ifdef FALSE
|
||||
#undef FALSE
|
||||
#undef FALSE
|
||||
#endif
|
||||
|
||||
#define FALSE (0)
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
#ifndef UNSURE
|
||||
#define UNSURE (2)
|
||||
#define UNSURE (2)
|
||||
#endif
|
||||
|
||||
#define mycmp(a,b) \
|
||||
( (toupper(a[0])!=toupper(b[0])) || smycmp((a)+1,(b)+1) )
|
||||
#define mycmp(a, b) \
|
||||
((toupper(a[0]) != toupper(b[0])) || smycmp((a) + 1, (b) + 1))
|
||||
extern int smycmp(const char *, const char *);
|
||||
#ifndef GLIBC2_x
|
||||
extern int myncmp(const char *, const char *, int);
|
||||
@@ -98,7 +98,7 @@ extern int myncmp(const char *, const char *, int);
|
||||
extern char *strtoken(char **, char *, char *);
|
||||
extern char *strtoken_noskip(char **, char *, char *);
|
||||
|
||||
extern MODVAR int global_count, max_global_count;
|
||||
extern MODVAR int global_count, max_global_count;
|
||||
#ifdef _WIN32
|
||||
extern int gettimeofday(struct timeval *tp, void *tzp);
|
||||
#endif
|
||||
@@ -106,10 +106,10 @@ extern int gettimeofday(struct timeval *tp, void *tzp);
|
||||
#define PRECISE_CHECK
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern MODVAR u_char tolowertab[], touppertab[];
|
||||
@@ -131,36 +131,36 @@ extern MODVAR u_char tolowertab[], touppertab[];
|
||||
#undef iscntrl
|
||||
extern MODVAR unsigned char char_atribs[];
|
||||
|
||||
#define PRINT 1
|
||||
#define CNTRL 2
|
||||
#define ALPHA 4
|
||||
#define PUNCT 8
|
||||
#define DIGIT 16
|
||||
#define SPACE 32
|
||||
#define ALLOW 64
|
||||
#define PRINT 1
|
||||
#define CNTRL 2
|
||||
#define ALPHA 4
|
||||
#define PUNCT 8
|
||||
#define DIGIT 16
|
||||
#define SPACE 32
|
||||
#define ALLOW 64
|
||||
#define ALLOWN 128
|
||||
|
||||
#ifndef KLINE_TEMP
|
||||
#define KLINE_PERM 0
|
||||
#define KLINE_TEMP 1
|
||||
#define KLINE_AKILL 2
|
||||
#define KLINE_EXCEPT 3
|
||||
#define KLINE_PERM 0
|
||||
#define KLINE_TEMP 1
|
||||
#define KLINE_AKILL 2
|
||||
#define KLINE_EXCEPT 3
|
||||
#endif
|
||||
|
||||
#define isallowed(c) (char_atribs[(u_char)(c)]&ALLOW)
|
||||
#define iscntrl(c) (char_atribs[(u_char)(c)]&CNTRL)
|
||||
#define isalpha(c) (char_atribs[(u_char)(c)]&ALPHA)
|
||||
#define isspace(c) (char_atribs[(u_char)(c)]&SPACE)
|
||||
#define islower(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) > 0x5f))
|
||||
#define isupper(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) < 0x60))
|
||||
#define isdigit(c) (char_atribs[(u_char)(c)]&DIGIT)
|
||||
#define isxdigit(c) (isdigit(c) || ('a' <= (c) && (c) <= 'f') || \
|
||||
('A' <= (c) && (c) <= 'F'))
|
||||
#define isalnum(c) (char_atribs[(u_char)(c)]&(DIGIT|ALPHA))
|
||||
#define isprint(c) (char_atribs[(u_char)(c)]&PRINT)
|
||||
#define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f)
|
||||
#define isgraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32))
|
||||
#define ispunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT)))
|
||||
#define isallowed(c) (char_atribs[(u_char)(c)] & ALLOW)
|
||||
#define iscntrl(c) (char_atribs[(u_char)(c)] & CNTRL)
|
||||
#define isalpha(c) (char_atribs[(u_char)(c)] & ALPHA)
|
||||
#define isspace(c) (char_atribs[(u_char)(c)] & SPACE)
|
||||
#define islower(c) ((char_atribs[(u_char)(c)] & ALPHA) && ((u_char)(c) > 0x5f))
|
||||
#define isupper(c) ((char_atribs[(u_char)(c)] & ALPHA) && ((u_char)(c) < 0x60))
|
||||
#define isdigit(c) (char_atribs[(u_char)(c)] & DIGIT)
|
||||
#define isxdigit(c) (isdigit(c) || ('a' <= (c) && (c) <= 'f') || \
|
||||
('A' <= (c) && (c) <= 'F'))
|
||||
#define isalnum(c) (char_atribs[(u_char)(c)] & (DIGIT | ALPHA))
|
||||
#define isprint(c) (char_atribs[(u_char)(c)] & PRINT)
|
||||
#define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f)
|
||||
#define isgraph(c) ((char_atribs[(u_char)(c)] & PRINT) && ((u_char)(c) != 0x32))
|
||||
#define ispunct(c) (!(char_atribs[(u_char)(c)] & (CNTRL | ALPHA | DIGIT)))
|
||||
#define iswseperator(c) (!isalnum(c) && !((u_char)c >= 128))
|
||||
|
||||
/*
|
||||
@@ -170,11 +170,11 @@ extern MODVAR unsigned char char_atribs[];
|
||||
|
||||
/* IRCu/Hybrid/unrealircd way now :) -Stskeeps */
|
||||
|
||||
#define EXPAR1 extchmstr[0]
|
||||
#define EXPAR2 extchmstr[1]
|
||||
#define EXPAR3 extchmstr[2]
|
||||
#define EXPAR4 extchmstr[3]
|
||||
#define CHPAR1 "beI"
|
||||
#define EXPAR1 extchmstr[0]
|
||||
#define EXPAR2 extchmstr[1]
|
||||
#define EXPAR3 extchmstr[2]
|
||||
#define EXPAR4 extchmstr[3]
|
||||
#define CHPAR1 "beI"
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
@@ -184,7 +184,7 @@ extern MODVAR unsigned char char_atribs[];
|
||||
extern int DisplayString(HWND hWnd, char *InBuf, ...);
|
||||
#else
|
||||
typedef int SOCKET;
|
||||
#define INVALID_SOCKET -1
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
@@ -198,29 +198,29 @@ extern int lu_noninv, lu_inv, lu_serv, lu_oper,
|
||||
extern MODVAR time_t now;
|
||||
|
||||
#ifndef _WIN32
|
||||
#if defined(__STDC__)
|
||||
#define __const const
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#ifndef __GNUC__
|
||||
#define __inline
|
||||
#endif
|
||||
#if defined(__STDC__)
|
||||
#define __const const
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#ifndef __GNUC__
|
||||
#define __inline
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifndef __GNUC__
|
||||
#define __const
|
||||
#define __inline
|
||||
#define __signed
|
||||
#define __volatile
|
||||
#ifndef NO_ANSI_KEYWORDS
|
||||
#define const /* delete ANSI C keywords */
|
||||
#define inline
|
||||
#define signed
|
||||
#define volatile
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef __GNUC__
|
||||
#define __const
|
||||
#define __inline
|
||||
#define __signed
|
||||
#define __volatile
|
||||
#ifndef NO_ANSI_KEYWORDS
|
||||
#define const /* delete ANSI C keywords */
|
||||
#define inline
|
||||
#define signed
|
||||
#define volatile
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define inline __inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif /* __common_include__ */
|
||||
|
||||
+78
-73
@@ -19,8 +19,8 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __config_include__
|
||||
#define __config_include__
|
||||
#ifndef __config_include__
|
||||
#define __config_include__
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -44,28 +44,28 @@
|
||||
* this to determine what backend is used.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
# ifdef HAVE_EPOLL
|
||||
# define BACKEND_EPOLL
|
||||
# else
|
||||
# ifdef HAVE_KQUEUE
|
||||
# define BACKEND_KQUEUE
|
||||
# else
|
||||
# ifdef HAVE_POLL
|
||||
# define BACKEND_POLL
|
||||
# else
|
||||
# define BACKEND_SELECT
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#ifdef HAVE_EPOLL
|
||||
#define BACKEND_EPOLL
|
||||
#else
|
||||
#ifdef HAVE_KQUEUE
|
||||
#define BACKEND_KQUEUE
|
||||
#else
|
||||
#ifdef HAVE_POLL
|
||||
#define BACKEND_POLL
|
||||
#else
|
||||
#define BACKEND_SELECT
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
# define BACKEND_SELECT
|
||||
#define BACKEND_SELECT
|
||||
#endif
|
||||
|
||||
/* Define the ircd module suffix, should be .so on UNIX, and .dll on Windows. */
|
||||
#ifndef _WIN32
|
||||
# define MODULE_SUFFIX ".so"
|
||||
#define MODULE_SUFFIX ".so"
|
||||
#else
|
||||
# define MODULE_SUFFIX ".dll"
|
||||
#define MODULE_SUFFIX ".dll"
|
||||
#endif
|
||||
|
||||
/* Permit remote /rehash */
|
||||
@@ -78,10 +78,10 @@
|
||||
** HOW_MANY_FREELINKS_ALLOWED - how many freelinks allowed
|
||||
*/
|
||||
#ifndef GARBAGE_COLLECT_EVERY
|
||||
#define GARBAGE_COLLECT_EVERY 600 /* default: 600 (10 mins) */
|
||||
#define GARBAGE_COLLECT_EVERY 600 /* default: 600 (10 mins) */
|
||||
#endif
|
||||
|
||||
#define HOW_MANY_FREELINKS_ALLOWED 200 /* default: 200 */
|
||||
#define HOW_MANY_FREELINKS_ALLOWED 200 /* default: 200 */
|
||||
|
||||
/*
|
||||
* read/write are restarted after signals defining this 1, gets
|
||||
@@ -89,7 +89,7 @@
|
||||
* behaviour (apollo sr10.1/bsd4.3 needs this)
|
||||
*/
|
||||
#ifdef APOLLO
|
||||
#define RESTARTING_SYSTEMCALLS
|
||||
#define RESTARTING_SYSTEMCALLS
|
||||
#endif
|
||||
|
||||
/* DEBUGMODE: This should only be used when tracing a problem. It creates
|
||||
@@ -101,15 +101,15 @@
|
||||
/*
|
||||
* Full pathnames and defaults of irc system's support files.
|
||||
*/
|
||||
#define CPATH CONFDIR"/unrealircd.conf" /* server configuration file */
|
||||
#define MPATH CONFDIR"/ircd.motd" /* server MOTD file */
|
||||
#define SMPATH CONFDIR"/ircd.smotd" /* short MOTD file */
|
||||
#define RPATH CONFDIR"/ircd.rules" /* server rules file */
|
||||
#define OPATH CONFDIR"/oper.motd" /* Operators MOTD file */
|
||||
#define LPATH LOGDIR"/debug.log" /* Where the debug file lives, if DEBUGMODE */
|
||||
#define VPATH CONFDIR"/ircd.svsmotd" /* Services MOTD append. */
|
||||
#define BPATH CONFDIR"/bot.motd" /* Bot MOTD */
|
||||
#define IRCDTUNE PERMDATADIR"/ircd.tune" /* tuning .. */
|
||||
#define CPATH CONFDIR "/unrealircd.conf" /* server configuration file */
|
||||
#define MPATH CONFDIR "/ircd.motd" /* server MOTD file */
|
||||
#define SMPATH CONFDIR "/ircd.smotd" /* short MOTD file */
|
||||
#define RPATH CONFDIR "/ircd.rules" /* server rules file */
|
||||
#define OPATH CONFDIR "/oper.motd" /* Operators MOTD file */
|
||||
#define LPATH LOGDIR "/debug.log" /* Where the debug file lives, if DEBUGMODE */
|
||||
#define VPATH CONFDIR "/ircd.svsmotd" /* Services MOTD append. */
|
||||
#define BPATH CONFDIR "/bot.motd" /* Bot MOTD */
|
||||
#define IRCDTUNE PERMDATADIR "/ircd.tune" /* tuning .. */
|
||||
|
||||
/** FAKELAG_CONFIGURABLE makes it possible to make certain classes exempted
|
||||
* from 'fake lag' (that is, the artificial delay that is added by the ircd
|
||||
@@ -126,9 +126,9 @@
|
||||
//#undef FAKELAG_CONFIGURABLE
|
||||
|
||||
/* The default value for class::sendq */
|
||||
#define DEFAULT_SENDQ 3000000
|
||||
#define DEFAULT_SENDQ 3000000
|
||||
/* The default value for class::recvq */
|
||||
#define DEFAULT_RECVQ 8000
|
||||
#define DEFAULT_RECVQ 8000
|
||||
|
||||
/* STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP STOP */
|
||||
|
||||
@@ -144,11 +144,11 @@
|
||||
* 2004-10-13: 1024 -> 4096
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define MAXCONNECTIONS 10240
|
||||
#define MAXCONNECTIONS 10240
|
||||
#else
|
||||
/* Non-Windows: */
|
||||
#if (!defined(MAXCONNECTIONS_REQUEST) || (MAXCONNECTIONS_REQUEST < 1)) && \
|
||||
(defined(HAVE_POLL) || defined(HAVE_EPOLL) || defined(HAVE_KQUEUE))
|
||||
(defined(HAVE_POLL) || defined(HAVE_EPOLL) || defined(HAVE_KQUEUE))
|
||||
/* Have poll/epoll/kqueue and either no --with-maxconnections or
|
||||
* --with-maxconnections=0, either of which indicates 'automatic' mode.
|
||||
* At the time of writing we will try a limit of 16384.
|
||||
@@ -182,7 +182,7 @@
|
||||
* chasing possible for mode and kick.
|
||||
*/
|
||||
#ifndef NICKNAMEHISTORYLENGTH
|
||||
#define NICKNAMEHISTORYLENGTH 2000
|
||||
#define NICKNAMEHISTORYLENGTH 2000
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -201,7 +201,7 @@
|
||||
* This can't be in the configuration file, as we need it while
|
||||
* fetching the configuration file.. ;)
|
||||
*/
|
||||
#define DOWNLOAD_CONNECT_TIMEOUT 15
|
||||
#define DOWNLOAD_CONNECT_TIMEOUT 15
|
||||
#define DOWNLOAD_TRANSFER_TIMEOUT 45
|
||||
|
||||
/* Maximum number of HTTP redirects to follow.
|
||||
@@ -235,7 +235,7 @@
|
||||
* This is kinda experimental, and requires getrusage.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
#define SPAMFILTER_DETECTSLOW
|
||||
#define SPAMFILTER_DETECTSLOW
|
||||
#endif
|
||||
|
||||
/* Limits for PCRE2 regex matching (eg. spamfilter, badwords). A regex that
|
||||
@@ -245,8 +245,8 @@
|
||||
* We use the same defaults that PHP has been using for a long time (which is
|
||||
* actually 10 times lower than PCRE2 defaults, as of 2026).
|
||||
*/
|
||||
#define UNREAL_PCRE2_MATCH_LIMIT 1000000
|
||||
#define UNREAL_PCRE2_DEPTH_LIMIT 100000
|
||||
#define UNREAL_PCRE2_MATCH_LIMIT 1000000
|
||||
#define UNREAL_PCRE2_DEPTH_LIMIT 100000
|
||||
|
||||
/* Maximum number of ModData objects that may be attached to an object */
|
||||
/* UnrealIRCd 4.0.0: 8, 8, 4, 4
|
||||
@@ -255,13 +255,13 @@
|
||||
* UnrealIRCd 6.0.0: 24, 12, 8, 4, 4, 500, 500
|
||||
* UnrealIRCd 6.1.2: 24, 24, 8, 4, 4, 500, 500
|
||||
*/
|
||||
#define MODDATA_MAX_CLIENT 24
|
||||
#define MODDATA_MAX_LOCAL_CLIENT 24
|
||||
#define MODDATA_MAX_CHANNEL 8
|
||||
#define MODDATA_MAX_MEMBER 4
|
||||
#define MODDATA_MAX_MEMBERSHIP 4
|
||||
#define MODDATA_MAX_LOCAL_VARIABLE 500
|
||||
#define MODDATA_MAX_GLOBAL_VARIABLE 500
|
||||
#define MODDATA_MAX_CLIENT 24
|
||||
#define MODDATA_MAX_LOCAL_CLIENT 24
|
||||
#define MODDATA_MAX_CHANNEL 8
|
||||
#define MODDATA_MAX_MEMBER 4
|
||||
#define MODDATA_MAX_MEMBERSHIP 4
|
||||
#define MODDATA_MAX_LOCAL_VARIABLE 500
|
||||
#define MODDATA_MAX_GLOBAL_VARIABLE 500
|
||||
|
||||
/** Size of the member modes buffer, so can be max this-1 modes
|
||||
* assigned to an individual user (and thus max prefixes as well).
|
||||
@@ -269,7 +269,7 @@
|
||||
* It allows for vhoaq (5) and then 2 additional ones from 3rd
|
||||
* party modules.
|
||||
*/
|
||||
#define MEMBERMODESLEN 8
|
||||
#define MEMBERMODESLEN 8
|
||||
|
||||
/* If EXPERIMENTAL is #define'd then all users will receive a notice about
|
||||
* this when they connect, along with a pointer to bugs.unrealircd.org where
|
||||
@@ -294,27 +294,27 @@
|
||||
* UNREALIRCD_DEFAULT_TLS_GROUPS_SECONDARY requires OpenSSL 1.1.0
|
||||
* UNREALIRCD_DEFAULT_TLS_GROUPS_TERTIARY is the last fallback option
|
||||
*/
|
||||
#define UNREALIRCD_DEFAULT_TLS_GROUPS_PRIMARY "X25519MLKEM768/X25519:secp521r1:secp384r1:prime256v1"
|
||||
#define UNREALIRCD_DEFAULT_TLS_GROUPS_PRIMARY "X25519MLKEM768/X25519:secp521r1:secp384r1:prime256v1"
|
||||
#define UNREALIRCD_DEFAULT_TLS_GROUPS_SECONDARY "X25519:secp521r1:secp384r1:prime256v1"
|
||||
#define UNREALIRCD_DEFAULT_TLS_GROUPS_TERTIARY "secp521r1:secp384r1:prime256v1"
|
||||
#define UNREALIRCD_DEFAULT_TLS_GROUPS_TERTIARY "secp521r1:secp384r1:prime256v1"
|
||||
|
||||
/* These can be changed via set::central-spamfilter::url and ::feed */
|
||||
#define DEFAULT_CENTRAL_SPAMFILTER_URL_OPEN_ACCESS "https://spamfilter.unrealircd.org/spamfilter/v6/$feed/central_spamfilter.conf"
|
||||
#define DEFAULT_CENTRAL_SPAMFILTER_URL_OPEN_ACCESS "https://spamfilter.unrealircd.org/spamfilter/v6/$feed/central_spamfilter.conf"
|
||||
#define DEFAULT_CENTRAL_SPAMFILTER_URL_RESTRICTED_ACCESS "https://spamfilter.unrealircd-api.org/spamfilter/v6/$feed/central_spamfilter.conf"
|
||||
#define DEFAULT_CENTRAL_SPAMFILTER_FEED "standard"
|
||||
#define DEFAULT_CENTRAL_SPAMFILTER_FEED "standard"
|
||||
|
||||
/* These are just defaults, which you can override via set::dns */
|
||||
#define DNS_DEFAULT_CLIENT_TIMEOUT 1500
|
||||
#define DNS_DEFAULT_CLIENT_RETRIES 2
|
||||
#define DNS_DEFAULT_DNSBL_TIMEOUT 3000
|
||||
#define DNS_DEFAULT_DNSBL_RETRIES 2
|
||||
#define DNS_DEFAULT_DNSBL_TIMEOUT 3000
|
||||
#define DNS_DEFAULT_DNSBL_RETRIES 2
|
||||
|
||||
/* ------------------------- END CONFIGURATION SECTION -------------------- */
|
||||
#define MOTD MPATH
|
||||
#define RULES RPATH
|
||||
#define MYNAME BINDIR "/unrealircd"
|
||||
#define CONFIGFILE CPATH
|
||||
#define IRCD_PIDFILE PIDFILE
|
||||
#define MOTD MPATH
|
||||
#define RULES RPATH
|
||||
#define MYNAME BINDIR "/unrealircd"
|
||||
#define CONFIGFILE CPATH
|
||||
#define IRCD_PIDFILE PIDFILE
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
#define LOGFILE LPATH
|
||||
@@ -323,14 +323,14 @@
|
||||
#endif
|
||||
|
||||
#if defined(DEFAULT_RECVQ)
|
||||
# if (DEFAULT_RECVQ < 512)
|
||||
error DEFAULT_RECVQ needs redefining.
|
||||
# endif
|
||||
#if (DEFAULT_RECVQ < 512)
|
||||
error DEFAULT_RECVQ needs redefining.
|
||||
#endif
|
||||
#else
|
||||
error DEFAULT_RECVQ undefined
|
||||
error DEFAULT_RECVQ undefined
|
||||
#endif
|
||||
#if (NICKNAMEHISTORYLENGTH < 100)
|
||||
# define NICKNAMEHISTORYLENGTH 100
|
||||
#define NICKNAMEHISTORYLENGTH 100
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \
|
||||
@@ -338,25 +338,30 @@
|
||||
!defined(__cplusplus)
|
||||
#define GCC_TYPECHECKING
|
||||
|
||||
/* copied from cURL: */
|
||||
/* copied from cURL: */
|
||||
|
||||
#define _UNREAL_WARNING(id, message) \
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) \
|
||||
{ \
|
||||
__asm__(""); \
|
||||
}
|
||||
|
||||
#define _UNREAL_ERROR(id, message) \
|
||||
static void __attribute__((__error__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
static void __attribute__((__error__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) \
|
||||
{ \
|
||||
__asm__(""); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||
#endif
|
||||
#ifndef __has_extension
|
||||
#define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
|
||||
#endif
|
||||
|
||||
#endif /* __config_include__ */
|
||||
|
||||
#endif /* __config_include__ */
|
||||
|
||||
+9
-9
@@ -40,7 +40,7 @@
|
||||
* 2nd page. Note that there is no need to provide room for malloc
|
||||
* overhead as we use mempools.
|
||||
*/
|
||||
#define DBUF_BLOCK_SIZE (4072+4096)
|
||||
#define DBUF_BLOCK_SIZE (4072 + 4096)
|
||||
|
||||
/*
|
||||
** dbuf is a collection of functions which can be used to
|
||||
@@ -58,8 +58,8 @@
|
||||
** interface.
|
||||
*/
|
||||
typedef struct dbuf {
|
||||
u_int length; /* Current number of bytes stored */
|
||||
// u_int offset; /* Offset to the first byte */
|
||||
u_int length; /* Current number of bytes stored */
|
||||
// u_int offset; /* Offset to the first byte */
|
||||
struct list_head dbuf_list;
|
||||
} dbuf;
|
||||
|
||||
@@ -83,13 +83,13 @@ typedef struct dbufbuf {
|
||||
** from users buffer.
|
||||
*/
|
||||
void dbuf_put(dbuf *, const char *, size_t);
|
||||
/* Dynamic buffer header */
|
||||
/* Pointer to data to be stored */
|
||||
/* Number of bytes to store */
|
||||
/* Dynamic buffer header */
|
||||
/* Pointer to data to be stored */
|
||||
/* Number of bytes to store */
|
||||
|
||||
void dbuf_delete(dbuf *, size_t);
|
||||
/* Dynamic buffer header */
|
||||
/* Number of bytes to delete */
|
||||
/* Dynamic buffer header */
|
||||
/* Number of bytes to delete */
|
||||
|
||||
/*
|
||||
** DBufLength
|
||||
@@ -104,7 +104,7 @@ void dbuf_delete(dbuf *, size_t);
|
||||
** Scratch the current content of the buffer. Release all
|
||||
** allocated buffers and make it empty.
|
||||
*/
|
||||
#define DBufClear(dyn) dbuf_delete((dyn),DBufLength(dyn))
|
||||
#define DBufClear(dyn) dbuf_delete((dyn), DBufLength(dyn))
|
||||
|
||||
extern int dbuf_getmsg(dbuf *, char *);
|
||||
extern int dbuf_get(dbuf *dyn, char **buf);
|
||||
|
||||
+14
-15
@@ -14,22 +14,22 @@ typedef struct DNSReq DNSReq;
|
||||
*/
|
||||
struct DNSReq {
|
||||
DNSReq *prev, *next;
|
||||
char *name; /**< Name being resolved (only for DNSREQ_LINKCONF and DNSREQ_CONNECT) */
|
||||
char ipv6; /**< Resolving for ipv6 or ipv4? */
|
||||
DNSReqType type; /**< DNS Request type (DNSREQ_*) */
|
||||
Client *client; /**< Client the request is for, NULL if client died OR unavailable */
|
||||
ConfigItem_link *linkblock; /**< Linkblock */
|
||||
char *name; /**< Name being resolved (only for DNSREQ_LINKCONF and DNSREQ_CONNECT) */
|
||||
char ipv6; /**< Resolving for ipv6 or ipv4? */
|
||||
DNSReqType type; /**< DNS Request type (DNSREQ_*) */
|
||||
Client *client; /**< Client the request is for, NULL if client died OR unavailable */
|
||||
ConfigItem_link *linkblock; /**< Linkblock */
|
||||
};
|
||||
|
||||
typedef struct DNSCache DNSCache;
|
||||
|
||||
/** DNS Cache entry - used in src/dns.c */
|
||||
struct DNSCache {
|
||||
DNSCache *prev, *next; /**< Previous and next in linked list */
|
||||
DNSCache *hprev, *hnext; /**< Previous and next in hash list */
|
||||
char *name; /**< The hostname */
|
||||
char *ip; /**< The IP address */
|
||||
time_t expires; /**< When record expires */
|
||||
DNSCache *prev, *next; /**< Previous and next in linked list */
|
||||
DNSCache *hprev, *hnext; /**< Previous and next in hash list */
|
||||
char *name; /**< The hostname */
|
||||
char *ip; /**< The IP address */
|
||||
time_t expires; /**< When record expires */
|
||||
};
|
||||
|
||||
typedef struct DNSStats DNSStats;
|
||||
@@ -41,11 +41,11 @@ struct DNSStats {
|
||||
};
|
||||
|
||||
/** Time to keep cache records. */
|
||||
#define DNS_CACHE_TTL 600
|
||||
#define DNS_NEGCACHE_TTL 60
|
||||
#define DNS_CACHE_TTL 600
|
||||
#define DNS_NEGCACHE_TTL 60
|
||||
|
||||
/** Size of the DNS cache hash table. */
|
||||
#define DNS_HASH_SIZE 4096
|
||||
#define DNS_HASH_SIZE 4096
|
||||
|
||||
/** Max # of entries we want in our cache.
|
||||
* This:
|
||||
@@ -58,7 +58,7 @@ struct DNSStats {
|
||||
* Note that in most situations there will be far
|
||||
* fewer items, as the TTL is rather short.
|
||||
*/
|
||||
#define DNS_MAX_ENTRIES DNS_HASH_SIZE
|
||||
#define DNS_MAX_ENTRIES DNS_HASH_SIZE
|
||||
|
||||
extern ares_channel resolver_channel_client;
|
||||
extern ares_channel resolver_channel_https;
|
||||
@@ -69,4 +69,3 @@ extern void init_resolver(int);
|
||||
struct hostent *unrealdns_doclient(Client *cptr);
|
||||
|
||||
extern void unreal_gethostbyname_api(const char *name, int family, const char *callbackname, void *arg);
|
||||
|
||||
|
||||
+208
-176
@@ -35,13 +35,18 @@ struct FloodSettings {
|
||||
typedef struct LogThrottleConfig LogThrottleConfig;
|
||||
struct LogThrottleConfig {
|
||||
LogThrottleConfig *prev, *next;
|
||||
char *event_id; /**< the event_id this policy applies to */
|
||||
int threshold; /**< per-window cap */
|
||||
int period; /**< window length in seconds */
|
||||
int unlimited; /**< if set, never throttle */
|
||||
char *event_id; /**< the event_id this policy applies to */
|
||||
int threshold; /**< per-window cap */
|
||||
int period; /**< window length in seconds */
|
||||
int unlimited; /**< if set, never throttle */
|
||||
};
|
||||
|
||||
enum UHAllowed { UHALLOW_ALWAYS, UHALLOW_NOCHANS, UHALLOW_REJOIN, UHALLOW_NEVER };
|
||||
enum UHAllowed {
|
||||
UHALLOW_ALWAYS,
|
||||
UHALLOW_NOCHANS,
|
||||
UHALLOW_REJOIN,
|
||||
UHALLOW_NEVER
|
||||
};
|
||||
|
||||
struct ChMode {
|
||||
long mode;
|
||||
@@ -54,35 +59,62 @@ typedef struct OperStat {
|
||||
char *flag;
|
||||
} OperStat;
|
||||
|
||||
typedef enum BroadcastChannelMessagesOption { BROADCAST_CHANNEL_MESSAGES_AUTO=1, BROADCAST_CHANNEL_MESSAGES_ALWAYS=2, BROADCAST_CHANNEL_MESSAGES_NEVER=3 } BroadcastChannelMessagesOption;
|
||||
typedef enum BroadcastChannelMessagesOption {
|
||||
BROADCAST_CHANNEL_MESSAGES_AUTO = 1,
|
||||
BROADCAST_CHANNEL_MESSAGES_ALWAYS = 2,
|
||||
BROADCAST_CHANNEL_MESSAGES_NEVER = 3
|
||||
} BroadcastChannelMessagesOption;
|
||||
|
||||
typedef enum AllowedChannelChars { ALLOWED_CHANNELCHARS_ANY=1, ALLOWED_CHANNELCHARS_ASCII=2, ALLOWED_CHANNELCHARS_UTF8=3 } AllowedChannelChars;
|
||||
typedef enum AllowedChannelChars {
|
||||
ALLOWED_CHANNELCHARS_ANY = 1,
|
||||
ALLOWED_CHANNELCHARS_ASCII = 2,
|
||||
ALLOWED_CHANNELCHARS_UTF8 = 3
|
||||
} AllowedChannelChars;
|
||||
|
||||
typedef enum BanTarget { BAN_TARGET_IP=1, BAN_TARGET_USERIP=2, BAN_TARGET_HOST=3, BAN_TARGET_USERHOST=4, BAN_TARGET_ACCOUNT=5, BAN_TARGET_CERTFP=6 } BanTarget;
|
||||
typedef enum BanTarget {
|
||||
BAN_TARGET_IP = 1,
|
||||
BAN_TARGET_USERIP = 2,
|
||||
BAN_TARGET_HOST = 3,
|
||||
BAN_TARGET_USERHOST = 4,
|
||||
BAN_TARGET_ACCOUNT = 5,
|
||||
BAN_TARGET_CERTFP = 6
|
||||
} BanTarget;
|
||||
|
||||
typedef enum HideIdleTimePolicy { HIDE_IDLE_TIME_NEVER=1, HIDE_IDLE_TIME_ALWAYS=2, HIDE_IDLE_TIME_USERMODE=3, HIDE_IDLE_TIME_OPER_USERMODE=4 } HideIdleTimePolicy;
|
||||
typedef enum HideIdleTimePolicy {
|
||||
HIDE_IDLE_TIME_NEVER = 1,
|
||||
HIDE_IDLE_TIME_ALWAYS = 2,
|
||||
HIDE_IDLE_TIME_USERMODE = 3,
|
||||
HIDE_IDLE_TIME_OPER_USERMODE = 4
|
||||
} HideIdleTimePolicy;
|
||||
|
||||
typedef enum LimitSVSCMDS { LIMIT_SVSCMDS_SERVERS=0, LIMIT_SVSCMDS_ULINES=1 } LimitSVSCMDS;
|
||||
typedef enum LimitSVSCMDS {
|
||||
LIMIT_SVSCMDS_SERVERS = 0,
|
||||
LIMIT_SVSCMDS_ULINES = 1
|
||||
} LimitSVSCMDS;
|
||||
|
||||
typedef enum HideBanReasonOption { HIDE_BAN_REASON_NO=0, HIDE_BAN_REASON_YES=1, HIDE_BAN_REASON_AUTO=2 } HideBanReasonOption;
|
||||
typedef enum HideBanReasonOption {
|
||||
HIDE_BAN_REASON_NO = 0,
|
||||
HIDE_BAN_REASON_YES = 1,
|
||||
HIDE_BAN_REASON_AUTO = 2
|
||||
} HideBanReasonOption;
|
||||
|
||||
/** The set { } block configuration */
|
||||
typedef struct Configuration Configuration;
|
||||
struct Configuration {
|
||||
unsigned show_opermotd:1;
|
||||
unsigned hide_ulines:1;
|
||||
unsigned flat_map:1;
|
||||
unsigned ident_check:1;
|
||||
unsigned fail_oper_warn:1;
|
||||
unsigned show_connect_info:1;
|
||||
unsigned no_connect_tls_info:1;
|
||||
unsigned dont_resolve:1;
|
||||
unsigned use_ban_version:1;
|
||||
unsigned mkpasswd_for_everyone:1;
|
||||
unsigned show_opermotd : 1;
|
||||
unsigned hide_ulines : 1;
|
||||
unsigned flat_map : 1;
|
||||
unsigned ident_check : 1;
|
||||
unsigned fail_oper_warn : 1;
|
||||
unsigned show_connect_info : 1;
|
||||
unsigned no_connect_tls_info : 1;
|
||||
unsigned dont_resolve : 1;
|
||||
unsigned use_ban_version : 1;
|
||||
unsigned mkpasswd_for_everyone : 1;
|
||||
unsigned allow_insane_bans;
|
||||
unsigned allow_part_if_shunned:1;
|
||||
unsigned disable_cap:1;
|
||||
unsigned check_target_nick_bans:1;
|
||||
unsigned allow_part_if_shunned : 1;
|
||||
unsigned disable_cap : 1;
|
||||
unsigned check_target_nick_bans : 1;
|
||||
HideBanReasonOption hide_ban_reason;
|
||||
int hide_killed_by;
|
||||
char *link_bindip;
|
||||
@@ -100,9 +132,9 @@ struct Configuration {
|
||||
int maxdccallow;
|
||||
int anti_spam_quit_message_time;
|
||||
TLSOptions *tls_options;
|
||||
TLSOptions *server_linking_tls_options; /**< set::server-linking::tls-options, NULL if not configured */
|
||||
int server_linking_mixed_certificates; /**< set::server-linking::mixed-certificates: suppress the s2s cert mismatch warning */
|
||||
int server_linking_allow_ca_certificate; /**< set::server-linking::allow-ca-certificate: suppress the "CA cert used for linking" advice */
|
||||
TLSOptions *server_linking_tls_options; /**< set::server-linking::tls-options, NULL if not configured */
|
||||
int server_linking_mixed_certificates; /**< set::server-linking::mixed-certificates: suppress the s2s cert mismatch warning */
|
||||
int server_linking_allow_ca_certificate; /**< set::server-linking::allow-ca-certificate: suppress the "CA cert used for linking" advice */
|
||||
Policy plaintext_policy_user;
|
||||
MultiLine *plaintext_policy_user_message;
|
||||
Policy plaintext_policy_oper;
|
||||
@@ -185,7 +217,7 @@ struct Configuration {
|
||||
BroadcastChannelMessagesOption broadcast_channel_messages;
|
||||
AllowedChannelChars allowed_channelchars;
|
||||
HideIdleTimePolicy hide_idle_time;
|
||||
unsigned inah:1;
|
||||
unsigned inah : 1;
|
||||
char *network_name;
|
||||
char *network_name_005;
|
||||
char *default_server;
|
||||
@@ -218,160 +250,160 @@ extern MODVAR int ipv6_disabled;
|
||||
*/
|
||||
typedef struct BestPractices BestPractices;
|
||||
struct BestPractices {
|
||||
int hashed_passwords; /**< Use hashed passwords */
|
||||
int hashed_passwords_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int trusted_cert; /**< Uses a SSL cert issued by a CA */
|
||||
int trusted_cert_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int trusted_cert_valid_hostname; /**< Uses a SSL cert issued by a CA that is valid for me::name */
|
||||
int trusted_cert_valid_hostname_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int listen_tls_only; /**< listen { } blocks only with tls */
|
||||
int listen_nontls_port; /**< first non-tls port found */
|
||||
int listen_nontls_port_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int hashed_passwords; /**< Use hashed passwords */
|
||||
int hashed_passwords_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int trusted_cert; /**< Uses a SSL cert issued by a CA */
|
||||
int trusted_cert_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int trusted_cert_valid_hostname; /**< Uses a SSL cert issued by a CA that is valid for me::name */
|
||||
int trusted_cert_valid_hostname_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
int listen_tls_only; /**< listen { } blocks only with tls */
|
||||
int listen_nontls_port; /**< first non-tls port found */
|
||||
int listen_nontls_port_hits; /**< - How many times advice has been given (like 'warnings' but it is advice) */
|
||||
};
|
||||
extern MODVAR BestPractices bestpractices;
|
||||
|
||||
#define KLINE_ADDRESS iConf.kline_address
|
||||
#define GLINE_ADDRESS iConf.gline_address
|
||||
#define OPER_MODES iConf.oper_modes
|
||||
#define OPER_SNOMASK iConf.oper_snomask
|
||||
#define SHOWOPERMOTD iConf.show_opermotd
|
||||
#define HIDE_ULINES iConf.hide_ulines
|
||||
#define FLAT_MAP iConf.flat_map
|
||||
#define ALLOW_CHATOPS iConf.allow_chatops
|
||||
#define PINGWARNING iConf.ping_warning
|
||||
#define MAXDCCALLOW iConf.maxdccallow
|
||||
#define DONT_RESOLVE iConf.dont_resolve
|
||||
#define OPER_AUTO_JOIN_CHANS iConf.oper_auto_join_chans
|
||||
#define LINK_BINDIP iConf.link_bindip
|
||||
#define IDENT_CHECK iConf.ident_check
|
||||
#define FAILOPER_WARN iConf.fail_oper_warn
|
||||
#define SHOWCONNECTINFO iConf.show_connect_info
|
||||
#define NOCONNECTTLSLINFO iConf.no_connect_tls_info
|
||||
#define ALLOW_USER_STATS iConf.allow_user_stats
|
||||
#define ANTI_SPAM_QUIT_MSG_TIME iConf.anti_spam_quit_message_time
|
||||
#define NETWORK_NAME iConf.network_name
|
||||
#define NETWORK_NAME_005 iConf.network_name_005
|
||||
#define DEFAULT_SERVER iConf.default_server
|
||||
#define SERVICES_NAME iConf.services_name
|
||||
#define CLOAK_PREFIX iConf.cloak_prefix
|
||||
#define HELP_CHANNEL iConf.helpchan
|
||||
#define STATS_SERVER iConf.stats_server
|
||||
#define SASL_SERVER iConf.sasl_server
|
||||
#define iNAH iConf.inah
|
||||
#define PREFIX_QUIT iConf.prefix_quit
|
||||
#define UHOST_ALLOWED iConf.userhost_allowed
|
||||
#define RESTRICT_CHANNELMODES iConf.restrict_channelmodes
|
||||
#define THROTTLING_PERIOD iConf.throttle_period
|
||||
#define THROTTLING_COUNT iConf.throttle_count
|
||||
#define USE_BAN_VERSION iConf.use_ban_version
|
||||
#define MODES_ON_JOIN iConf.modes_on_join.extmodes
|
||||
#define LEVEL_ON_JOIN iConf.level_on_join
|
||||
#define IDENT_CONNECT_TIMEOUT iConf.ident_connect_timeout
|
||||
#define IDENT_READ_TIMEOUT iConf.ident_read_timeout
|
||||
#define MKPASSWD_FOR_EVERYONE iConf.mkpasswd_for_everyone
|
||||
#define HIDE_BAN_REASON iConf.hide_ban_reason
|
||||
#define ALLOW_INSANE_BANS iConf.allow_insane_bans
|
||||
#define CHANCMDPFX iConf.channel_command_prefix
|
||||
#define DEFAULT_BANTIME iConf.default_bantime
|
||||
#define WHOLIMIT iConf.who_limit
|
||||
#define ALLOW_PART_IF_SHUNNED iConf.allow_part_if_shunned
|
||||
#define DISABLE_CAP iConf.disable_cap
|
||||
#define DISABLE_IPV6 ipv6_disabled
|
||||
#define BAN_VERSION_TKL_TIME iConf.ban_version_tkl_time
|
||||
#define SILENCE_LIMIT (iConf.silence_limit ? iConf.silence_limit : 15)
|
||||
#define SPAMFILTER_BAN_TIME iConf.spamfilter_ban_time
|
||||
#define SPAMFILTER_BAN_REASON iConf.spamfilter_ban_reason
|
||||
#define SPAMFILTER_VIRUSCHAN iConf.spamfilter_virus_help_channel
|
||||
#define SPAMFILTER_VIRUSCHANDENY iConf.spamfilter_vchan_deny
|
||||
#define SPAMFILTER_EXCEPT iConf.spamexcept_line
|
||||
#define SPAMFILTER_DETECTSLOW_WARN iConf.spamfilter_detectslow_warn
|
||||
#define SPAMFILTER_DETECTSLOW_FATAL iConf.spamfilter_detectslow_fatal
|
||||
#define SPAMFILTER_STOP_ON_FIRST_MATCH iConf.spamfilter_stop_on_first_match
|
||||
#define CHECK_TARGET_NICK_BANS iConf.check_target_nick_bans
|
||||
#define MAXBANS iConf.maxbans
|
||||
#define WATCH_AWAY_NOTIFICATION iConf.watch_away_notification
|
||||
#define UHNAMES_ENABLED iConf.uhnames
|
||||
#define UTF8ONLY iConf.utf8_only
|
||||
#define NETWORK_ICON iConf.network_icon
|
||||
#define KLINE_ADDRESS iConf.kline_address
|
||||
#define GLINE_ADDRESS iConf.gline_address
|
||||
#define OPER_MODES iConf.oper_modes
|
||||
#define OPER_SNOMASK iConf.oper_snomask
|
||||
#define SHOWOPERMOTD iConf.show_opermotd
|
||||
#define HIDE_ULINES iConf.hide_ulines
|
||||
#define FLAT_MAP iConf.flat_map
|
||||
#define ALLOW_CHATOPS iConf.allow_chatops
|
||||
#define PINGWARNING iConf.ping_warning
|
||||
#define MAXDCCALLOW iConf.maxdccallow
|
||||
#define DONT_RESOLVE iConf.dont_resolve
|
||||
#define OPER_AUTO_JOIN_CHANS iConf.oper_auto_join_chans
|
||||
#define LINK_BINDIP iConf.link_bindip
|
||||
#define IDENT_CHECK iConf.ident_check
|
||||
#define FAILOPER_WARN iConf.fail_oper_warn
|
||||
#define SHOWCONNECTINFO iConf.show_connect_info
|
||||
#define NOCONNECTTLSLINFO iConf.no_connect_tls_info
|
||||
#define ALLOW_USER_STATS iConf.allow_user_stats
|
||||
#define ANTI_SPAM_QUIT_MSG_TIME iConf.anti_spam_quit_message_time
|
||||
#define NETWORK_NAME iConf.network_name
|
||||
#define NETWORK_NAME_005 iConf.network_name_005
|
||||
#define DEFAULT_SERVER iConf.default_server
|
||||
#define SERVICES_NAME iConf.services_name
|
||||
#define CLOAK_PREFIX iConf.cloak_prefix
|
||||
#define HELP_CHANNEL iConf.helpchan
|
||||
#define STATS_SERVER iConf.stats_server
|
||||
#define SASL_SERVER iConf.sasl_server
|
||||
#define iNAH iConf.inah
|
||||
#define PREFIX_QUIT iConf.prefix_quit
|
||||
#define UHOST_ALLOWED iConf.userhost_allowed
|
||||
#define RESTRICT_CHANNELMODES iConf.restrict_channelmodes
|
||||
#define THROTTLING_PERIOD iConf.throttle_period
|
||||
#define THROTTLING_COUNT iConf.throttle_count
|
||||
#define USE_BAN_VERSION iConf.use_ban_version
|
||||
#define MODES_ON_JOIN iConf.modes_on_join.extmodes
|
||||
#define LEVEL_ON_JOIN iConf.level_on_join
|
||||
#define IDENT_CONNECT_TIMEOUT iConf.ident_connect_timeout
|
||||
#define IDENT_READ_TIMEOUT iConf.ident_read_timeout
|
||||
#define MKPASSWD_FOR_EVERYONE iConf.mkpasswd_for_everyone
|
||||
#define HIDE_BAN_REASON iConf.hide_ban_reason
|
||||
#define ALLOW_INSANE_BANS iConf.allow_insane_bans
|
||||
#define CHANCMDPFX iConf.channel_command_prefix
|
||||
#define DEFAULT_BANTIME iConf.default_bantime
|
||||
#define WHOLIMIT iConf.who_limit
|
||||
#define ALLOW_PART_IF_SHUNNED iConf.allow_part_if_shunned
|
||||
#define DISABLE_CAP iConf.disable_cap
|
||||
#define DISABLE_IPV6 ipv6_disabled
|
||||
#define BAN_VERSION_TKL_TIME iConf.ban_version_tkl_time
|
||||
#define SILENCE_LIMIT (iConf.silence_limit ? iConf.silence_limit : 15)
|
||||
#define SPAMFILTER_BAN_TIME iConf.spamfilter_ban_time
|
||||
#define SPAMFILTER_BAN_REASON iConf.spamfilter_ban_reason
|
||||
#define SPAMFILTER_VIRUSCHAN iConf.spamfilter_virus_help_channel
|
||||
#define SPAMFILTER_VIRUSCHANDENY iConf.spamfilter_vchan_deny
|
||||
#define SPAMFILTER_EXCEPT iConf.spamexcept_line
|
||||
#define SPAMFILTER_DETECTSLOW_WARN iConf.spamfilter_detectslow_warn
|
||||
#define SPAMFILTER_DETECTSLOW_FATAL iConf.spamfilter_detectslow_fatal
|
||||
#define SPAMFILTER_STOP_ON_FIRST_MATCH iConf.spamfilter_stop_on_first_match
|
||||
#define CHECK_TARGET_NICK_BANS iConf.check_target_nick_bans
|
||||
#define MAXBANS iConf.maxbans
|
||||
#define WATCH_AWAY_NOTIFICATION iConf.watch_away_notification
|
||||
#define UHNAMES_ENABLED iConf.uhnames
|
||||
#define UTF8ONLY iConf.utf8_only
|
||||
#define NETWORK_ICON iConf.network_icon
|
||||
|
||||
/** Used for testing the set { } block configuration.
|
||||
* It tests if a setting is present and is also used for duplicate checking.
|
||||
*/
|
||||
struct SetCheck {
|
||||
unsigned has_show_opermotd:1;
|
||||
unsigned has_hide_ulines:1;
|
||||
unsigned has_flat_map:1;
|
||||
unsigned has_allow_chatops:1;
|
||||
unsigned has_ident_check:1;
|
||||
unsigned has_fail_oper_warn:1;
|
||||
unsigned has_show_connect_info:1;
|
||||
unsigned has_dont_resolve:1;
|
||||
unsigned has_mkpasswd_for_everyone:1;
|
||||
unsigned has_allow_part_if_shunned:1;
|
||||
unsigned has_tls_server_cipher_list :1;
|
||||
unsigned has_tls_protocols :1;
|
||||
unsigned has_dns_bind_ip:1;
|
||||
unsigned has_link_bind_ip:1;
|
||||
unsigned has_throttle_period:1;
|
||||
unsigned has_throttle_connections:1;
|
||||
unsigned has_kline_address:1;
|
||||
unsigned has_gline_address:1;
|
||||
unsigned has_modes_on_oper:1;
|
||||
unsigned has_snomask_on_connect:1;
|
||||
unsigned has_snomask_on_oper:1;
|
||||
unsigned has_oper_auto_join:1;
|
||||
unsigned has_check_target_nick_bans:1;
|
||||
unsigned has_watch_away_notification:1;
|
||||
unsigned has_uhnames:1;
|
||||
unsigned has_allow_user_stats:1;
|
||||
unsigned has_ping_warning:1;
|
||||
unsigned has_maxdccallow:1;
|
||||
unsigned has_anti_spam_quit_message_time:1;
|
||||
unsigned has_allow_userhost_change:1;
|
||||
unsigned has_allow_setident:1;
|
||||
unsigned has_allow_setname:1;
|
||||
unsigned has_restrict_channelmodes:1;
|
||||
unsigned has_channel_command_prefix:1;
|
||||
unsigned has_modes_on_join:1;
|
||||
unsigned has_level_on_join:1;
|
||||
unsigned has_ident_connect_timeout:1;
|
||||
unsigned has_ident_read_timeout:1;
|
||||
unsigned has_default_bantime:1;
|
||||
unsigned has_who_limit:1;
|
||||
unsigned has_maxbans:1;
|
||||
unsigned has_silence_limit:1;
|
||||
unsigned has_ban_version_tkl_time:1;
|
||||
unsigned has_spamfilter_ban_time:1;
|
||||
unsigned has_spamfilter_ban_reason:1;
|
||||
unsigned has_spamfilter_virus_help_channel:1;
|
||||
unsigned has_spamfilter_virus_help_channel_deny:1;
|
||||
unsigned has_spamfilter_except:1;
|
||||
unsigned has_network_name:1;
|
||||
unsigned has_network_icon:1;
|
||||
unsigned has_default_server:1;
|
||||
unsigned has_services_server:1;
|
||||
unsigned has_sasl_server:1;
|
||||
unsigned has_hiddenhost_prefix:1;
|
||||
unsigned has_prefix_quit:1;
|
||||
unsigned has_help_channel:1;
|
||||
unsigned has_stats_server:1;
|
||||
unsigned has_cloak_keys:1;
|
||||
unsigned has_options_hide_ulines:1;
|
||||
unsigned has_options_flat_map:1;
|
||||
unsigned has_options_show_opermotd:1;
|
||||
unsigned has_options_identd_check:1;
|
||||
unsigned has_options_fail_oper_warn:1;
|
||||
unsigned has_options_dont_resolve:1;
|
||||
unsigned has_options_show_connect_info:1;
|
||||
unsigned has_options_no_connect_tls_info:1;
|
||||
unsigned has_options_mkpasswd_for_everyone:1;
|
||||
unsigned has_options_allow_insane_bans:1;
|
||||
unsigned has_options_allow_part_if_shunned:1;
|
||||
unsigned has_options_disable_cap:1;
|
||||
unsigned has_options_disable_ipv6:1;
|
||||
unsigned has_ping_cookie:1;
|
||||
unsigned has_min_nick_length:1;
|
||||
unsigned has_nick_length:1;
|
||||
unsigned has_hide_ban_reason:1;
|
||||
unsigned has_hide_killed_by:1;
|
||||
unsigned has_show_opermotd : 1;
|
||||
unsigned has_hide_ulines : 1;
|
||||
unsigned has_flat_map : 1;
|
||||
unsigned has_allow_chatops : 1;
|
||||
unsigned has_ident_check : 1;
|
||||
unsigned has_fail_oper_warn : 1;
|
||||
unsigned has_show_connect_info : 1;
|
||||
unsigned has_dont_resolve : 1;
|
||||
unsigned has_mkpasswd_for_everyone : 1;
|
||||
unsigned has_allow_part_if_shunned : 1;
|
||||
unsigned has_tls_server_cipher_list : 1;
|
||||
unsigned has_tls_protocols : 1;
|
||||
unsigned has_dns_bind_ip : 1;
|
||||
unsigned has_link_bind_ip : 1;
|
||||
unsigned has_throttle_period : 1;
|
||||
unsigned has_throttle_connections : 1;
|
||||
unsigned has_kline_address : 1;
|
||||
unsigned has_gline_address : 1;
|
||||
unsigned has_modes_on_oper : 1;
|
||||
unsigned has_snomask_on_connect : 1;
|
||||
unsigned has_snomask_on_oper : 1;
|
||||
unsigned has_oper_auto_join : 1;
|
||||
unsigned has_check_target_nick_bans : 1;
|
||||
unsigned has_watch_away_notification : 1;
|
||||
unsigned has_uhnames : 1;
|
||||
unsigned has_allow_user_stats : 1;
|
||||
unsigned has_ping_warning : 1;
|
||||
unsigned has_maxdccallow : 1;
|
||||
unsigned has_anti_spam_quit_message_time : 1;
|
||||
unsigned has_allow_userhost_change : 1;
|
||||
unsigned has_allow_setident : 1;
|
||||
unsigned has_allow_setname : 1;
|
||||
unsigned has_restrict_channelmodes : 1;
|
||||
unsigned has_channel_command_prefix : 1;
|
||||
unsigned has_modes_on_join : 1;
|
||||
unsigned has_level_on_join : 1;
|
||||
unsigned has_ident_connect_timeout : 1;
|
||||
unsigned has_ident_read_timeout : 1;
|
||||
unsigned has_default_bantime : 1;
|
||||
unsigned has_who_limit : 1;
|
||||
unsigned has_maxbans : 1;
|
||||
unsigned has_silence_limit : 1;
|
||||
unsigned has_ban_version_tkl_time : 1;
|
||||
unsigned has_spamfilter_ban_time : 1;
|
||||
unsigned has_spamfilter_ban_reason : 1;
|
||||
unsigned has_spamfilter_virus_help_channel : 1;
|
||||
unsigned has_spamfilter_virus_help_channel_deny : 1;
|
||||
unsigned has_spamfilter_except : 1;
|
||||
unsigned has_network_name : 1;
|
||||
unsigned has_network_icon : 1;
|
||||
unsigned has_default_server : 1;
|
||||
unsigned has_services_server : 1;
|
||||
unsigned has_sasl_server : 1;
|
||||
unsigned has_hiddenhost_prefix : 1;
|
||||
unsigned has_prefix_quit : 1;
|
||||
unsigned has_help_channel : 1;
|
||||
unsigned has_stats_server : 1;
|
||||
unsigned has_cloak_keys : 1;
|
||||
unsigned has_options_hide_ulines : 1;
|
||||
unsigned has_options_flat_map : 1;
|
||||
unsigned has_options_show_opermotd : 1;
|
||||
unsigned has_options_identd_check : 1;
|
||||
unsigned has_options_fail_oper_warn : 1;
|
||||
unsigned has_options_dont_resolve : 1;
|
||||
unsigned has_options_show_connect_info : 1;
|
||||
unsigned has_options_no_connect_tls_info : 1;
|
||||
unsigned has_options_mkpasswd_for_everyone : 1;
|
||||
unsigned has_options_allow_insane_bans : 1;
|
||||
unsigned has_options_allow_part_if_shunned : 1;
|
||||
unsigned has_options_disable_cap : 1;
|
||||
unsigned has_options_disable_ipv6 : 1;
|
||||
unsigned has_ping_cookie : 1;
|
||||
unsigned has_min_nick_length : 1;
|
||||
unsigned has_nick_length : 1;
|
||||
unsigned has_hide_ban_reason : 1;
|
||||
unsigned has_hide_killed_by : 1;
|
||||
};
|
||||
|
||||
+17
-10
@@ -3,11 +3,15 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#define FD_DESC_SZ (100)
|
||||
#define FD_DESC_SZ (100)
|
||||
|
||||
typedef void (*IOCallbackFunc)(int fd, int revents, void *data);
|
||||
|
||||
typedef enum FDCloseMethod { FDCLOSE_SOCKET=0, FDCLOSE_FILE=1, FDCLOSE_NONE=3 } FDCloseMethod;
|
||||
typedef enum FDCloseMethod {
|
||||
FDCLOSE_SOCKET = 0,
|
||||
FDCLOSE_FILE = 1,
|
||||
FDCLOSE_NONE = 3
|
||||
} FDCloseMethod;
|
||||
|
||||
typedef struct fd_entry {
|
||||
int fd;
|
||||
@@ -31,10 +35,12 @@ extern int fd_accept(int sockfd);
|
||||
extern void fd_desc(int fd, const char *desc);
|
||||
extern int fd_fileopen(const char *path, unsigned int flags);
|
||||
|
||||
#define FD_SELECT_READ 0x1
|
||||
#define FD_SELECT_WRITE 0x2
|
||||
#define FD_SELECT_READ 0x1
|
||||
#define FD_SELECT_WRITE 0x2
|
||||
|
||||
#define fd_setselect(fd, flags, iocb, data) do { \
|
||||
#define fd_setselect(fd, flags, iocb, data) \
|
||||
do \
|
||||
{ \
|
||||
if (fd < 0) \
|
||||
{ \
|
||||
unreal_log(ULOG_ERROR, "io", "BUG_FD_SETSELECT_NEGATIVE_FD", NULL, \
|
||||
@@ -42,13 +48,14 @@ extern int fd_fileopen(const char *path, unsigned int flags);
|
||||
log_data_string("file", __FILE__), \
|
||||
log_data_integer("line", __LINE__), \
|
||||
log_data_integer("fd", fd)); \
|
||||
} else { \
|
||||
} else \
|
||||
{ \
|
||||
fd_setselect_real(fd, flags, iocb, data); \
|
||||
} \
|
||||
} while(0)
|
||||
} while (0)
|
||||
extern void fd_setselect_real(int fd, int flags, IOCallbackFunc iocb, void *data);
|
||||
extern void fd_select(int delay); /* backend-specific */
|
||||
extern void fd_refresh(int fd); /* backend-specific */
|
||||
extern void fd_fork(); /* backend-specific */
|
||||
extern void fd_select(int delay); /* backend-specific */
|
||||
extern void fd_refresh(int fd); /* backend-specific */
|
||||
extern void fd_fork(); /* backend-specific */
|
||||
|
||||
#endif
|
||||
|
||||
+269
-141
@@ -69,7 +69,7 @@ extern MODVAR int bootopt;
|
||||
extern MODVAR time_t timeofday;
|
||||
extern MODVAR struct timeval timeofday_tv;
|
||||
extern MODVAR char cmodestring[512];
|
||||
extern MODVAR char umodestring[UMODETABLESZ+1];
|
||||
extern MODVAR char umodestring[UMODETABLESZ + 1];
|
||||
/* newconf */
|
||||
#define get_sendq(x) ((x)->local->class ? (x)->local->class->sendq : DEFAULT_SENDQ)
|
||||
/* get_recvq is only called in send.c for local connections */
|
||||
@@ -89,33 +89,33 @@ extern void preprocessor_replace_defines(char **item, ConfigEntry *ce);
|
||||
/*
|
||||
* Configuration linked lists
|
||||
*/
|
||||
extern MODVAR ConfigItem_me *conf_me;
|
||||
extern MODVAR ConfigItem_files *conf_files;
|
||||
extern MODVAR ConfigItem_class *conf_class;
|
||||
extern MODVAR ConfigItem_class *default_class;
|
||||
extern MODVAR ConfigItem_admin *conf_admin;
|
||||
extern MODVAR ConfigItem_admin *conf_admin_tail;
|
||||
extern MODVAR ConfigItem_drpass *conf_drpass;
|
||||
extern MODVAR ConfigItem_ulines *conf_ulines;
|
||||
extern MODVAR ConfigItem_tld *conf_tld;
|
||||
extern MODVAR ConfigItem_oper *conf_oper;
|
||||
extern MODVAR ConfigItem_listen *conf_listen;
|
||||
extern MODVAR ConfigItem_allow *conf_allow;
|
||||
extern MODVAR ConfigItem_link *conf_link;
|
||||
extern MODVAR ConfigItem_sni *conf_sni;
|
||||
extern MODVAR ConfigItem_ban *conf_ban;
|
||||
extern MODVAR ConfigItem_deny_channel *conf_deny_channel;
|
||||
extern MODVAR ConfigItem_me *conf_me;
|
||||
extern MODVAR ConfigItem_files *conf_files;
|
||||
extern MODVAR ConfigItem_class *conf_class;
|
||||
extern MODVAR ConfigItem_class *default_class;
|
||||
extern MODVAR ConfigItem_admin *conf_admin;
|
||||
extern MODVAR ConfigItem_admin *conf_admin_tail;
|
||||
extern MODVAR ConfigItem_drpass *conf_drpass;
|
||||
extern MODVAR ConfigItem_ulines *conf_ulines;
|
||||
extern MODVAR ConfigItem_tld *conf_tld;
|
||||
extern MODVAR ConfigItem_oper *conf_oper;
|
||||
extern MODVAR ConfigItem_listen *conf_listen;
|
||||
extern MODVAR ConfigItem_allow *conf_allow;
|
||||
extern MODVAR ConfigItem_link *conf_link;
|
||||
extern MODVAR ConfigItem_sni *conf_sni;
|
||||
extern MODVAR ConfigItem_ban *conf_ban;
|
||||
extern MODVAR ConfigItem_deny_channel *conf_deny_channel;
|
||||
extern MODVAR ConfigItem_allow_channel *conf_allow_channel;
|
||||
extern MODVAR ConfigItem_deny_version *conf_deny_version;
|
||||
extern MODVAR ConfigItem_alias *conf_alias;
|
||||
extern MODVAR ConfigItem_help *conf_help;
|
||||
extern MODVAR ConfigItem_offchans *conf_offchans;
|
||||
extern MODVAR ConfigItem_proxy *conf_proxy;
|
||||
extern void completed_connection(int, int, void *);
|
||||
extern MODVAR ConfigItem_deny_version *conf_deny_version;
|
||||
extern MODVAR ConfigItem_alias *conf_alias;
|
||||
extern MODVAR ConfigItem_help *conf_help;
|
||||
extern MODVAR ConfigItem_offchans *conf_offchans;
|
||||
extern MODVAR ConfigItem_proxy *conf_proxy;
|
||||
extern void completed_connection(int, int, void *);
|
||||
extern void clear_unknown();
|
||||
extern EVENT(e_unload_module_delayed);
|
||||
|
||||
extern void module_loadall(void);
|
||||
extern void module_loadall(void);
|
||||
extern long set_usermode(const char *umode);
|
||||
extern const char *get_usermode_string(Client *acptr);
|
||||
extern const char *get_usermode_string_r(Client *client, char *buf, size_t buflen);
|
||||
@@ -123,8 +123,8 @@ extern const char *get_usermode_string_raw(long umodes);
|
||||
extern const char *get_usermode_string_raw_r(long umodes, char *buf, size_t buflen);
|
||||
extern ConfigFile *config_parse(const char *filename, char *confdata);
|
||||
extern ConfigFile *config_parse_with_offset(const char *filename, char *confdata, unsigned int line_offset);
|
||||
extern void config_error(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2)));
|
||||
extern void config_warn(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2)));
|
||||
extern void config_error(FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 1, 2)));
|
||||
extern void config_warn(FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 1, 2)));
|
||||
extern void config_error_missing(const char *filename, int line, const char *entry);
|
||||
extern void config_error_unknown(const char *filename, int line, const char *block, const char *entry);
|
||||
extern void config_error_unknownflag(const char *filename, int line, const char *block, const char *entry);
|
||||
@@ -141,19 +141,19 @@ extern void config_entry_free_all(ConfigEntry *ce);
|
||||
extern ConfigFile *config_load(const char *filename, const char *displayname);
|
||||
extern void config_free(ConfigFile *cfptr);
|
||||
extern void ipport_seperate(const char *string, char **ip, char **port);
|
||||
extern ConfigItem_class *find_class(const char *name);
|
||||
extern ConfigItem_oper *find_oper(const char *name);
|
||||
extern ConfigItem_operclass *find_operclass(const char *name);
|
||||
extern ConfigItem_class *find_class(const char *name);
|
||||
extern ConfigItem_oper *find_oper(const char *name);
|
||||
extern ConfigItem_operclass *find_operclass(const char *name);
|
||||
extern ConfigItem_listen *find_listen(const char *ipmask, int port, SocketType socket_type);
|
||||
extern ConfigItem_sni *find_sni(const char *name);
|
||||
extern ConfigItem_ulines *find_uline(const char *host);
|
||||
extern ConfigItem_tld *find_tld(Client *cptr);
|
||||
extern ConfigItem_link *find_link(const char *servername);
|
||||
extern ConfigItem_ban *find_ban(Client *, const char *host, short type);
|
||||
extern ConfigItem_ban *find_banEx(Client *,const char *host, short type, short type2);
|
||||
extern ConfigItem_ulines *find_uline(const char *host);
|
||||
extern ConfigItem_tld *find_tld(Client *cptr);
|
||||
extern ConfigItem_link *find_link(const char *servername);
|
||||
extern ConfigItem_ban *find_ban(Client *, const char *host, short type);
|
||||
extern ConfigItem_ban *find_banEx(Client *, const char *host, short type, short type2);
|
||||
extern ConfigItem_deny_channel *find_channel_allowed(Client *cptr, const char *name);
|
||||
extern ConfigItem_alias *find_alias(const char *name);
|
||||
extern ConfigItem_help *find_Help(const char *command);
|
||||
extern ConfigItem_alias *find_alias(const char *name);
|
||||
extern ConfigItem_help *find_Help(const char *command);
|
||||
|
||||
extern OperPermission ValidatePermissionsForPath(const char *path, Client *client, Client *victim, Channel *channel, const void *extra);
|
||||
extern void OperClassValidatorDel(OperClassValidator *validator);
|
||||
@@ -164,7 +164,7 @@ extern void OperClass_freePath(OperClassACLPath *path);
|
||||
extern OperClassACL *_conf_parseACL(const char *name, ConfigEntry *ce);
|
||||
extern void free_operclass_struct(OperClass *o);
|
||||
|
||||
extern ConfigItem_ban *find_ban_ip(Client *client);
|
||||
extern ConfigItem_ban *find_ban_ip(Client *client);
|
||||
extern void add_ListItem(ListStruct *, ListStruct **);
|
||||
extern void append_ListItem(ListStruct *item, ListStruct **list);
|
||||
extern void add_ListItemPrio(ListStructPrio *, ListStructPrio **, int);
|
||||
@@ -172,13 +172,13 @@ extern void del_ListItem(ListStruct *, ListStruct **);
|
||||
extern MODVAR LoopStruct loop;
|
||||
extern int del_banid(Channel *channel, const char *banid);
|
||||
extern int del_exbanid(Channel *channel, const char *banid);
|
||||
#define REPORT_DO_DNS "NOTICE * :*** Looking up your hostname...\r\n"
|
||||
#define REPORT_FIN_DNS "NOTICE * :*** Found your hostname\r\n"
|
||||
#define REPORT_DO_DNS "NOTICE * :*** Looking up your hostname...\r\n"
|
||||
#define REPORT_FIN_DNS "NOTICE * :*** Found your hostname\r\n"
|
||||
#define REPORT_FIN_DNSC "NOTICE * :*** Found your hostname (cached)\r\n"
|
||||
#define REPORT_FAIL_DNS "NOTICE * :*** Couldn't resolve your hostname; using your IP address instead\r\n"
|
||||
#define REPORT_DO_ID "NOTICE * :*** Checking ident...\r\n"
|
||||
#define REPORT_FIN_ID "NOTICE * :*** Received identd response\r\n"
|
||||
#define REPORT_FAIL_ID "NOTICE * :*** No ident response; username prefixed with ~\r\n"
|
||||
#define REPORT_DO_ID "NOTICE * :*** Checking ident...\r\n"
|
||||
#define REPORT_FIN_ID "NOTICE * :*** Received identd response\r\n"
|
||||
#define REPORT_FAIL_ID "NOTICE * :*** No ident response; username prefixed with ~\r\n"
|
||||
extern MODVAR int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, R_do_id, R_fin_id, R_fail_id;
|
||||
extern MODVAR struct list_head client_list;
|
||||
extern MODVAR struct list_head lclient_list;
|
||||
@@ -259,7 +259,7 @@ extern MODVAR int debuglevel;
|
||||
#else
|
||||
extern int debuglevel, errno, h_errno;
|
||||
#endif
|
||||
extern MODVAR int OpenFiles; /* number of files currently open */
|
||||
extern MODVAR int OpenFiles; /* number of files currently open */
|
||||
extern MODVAR int debuglevel, portnum, debugtty, maxusersperchannel;
|
||||
extern MODVAR int readcalls, udpfd, resfd;
|
||||
extern Client *add_connection(ConfigItem_listen *, int);
|
||||
@@ -284,31 +284,31 @@ extern void set_socket_buffers(int fd, int rcvbuf, int sndbuf);
|
||||
extern int send_queued(Client *);
|
||||
extern void send_queued_cb(int fd, int revents, void *data);
|
||||
extern void sendto_serv_butone_nickcmd(Client *one, MessageTag *mtags, Client *client, const char *umodes);
|
||||
extern void sendto_message_one(Client *to, Client *from, const char *sender, const char *cmd, const char *nick, const char *msg);
|
||||
extern void sendto_message_one(Client *to, Client *from, const char *sender, const char *cmd, const char *nick, const char *msg);
|
||||
extern LineCache *linecache_init(void);
|
||||
extern void linecache_free(LineCache *cache);
|
||||
extern void sendto_prefix_one_cached(LineCache *cache, int line_opts, Client *to, Client *from,
|
||||
MessageTag *mtags,
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7)));
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 6, 7)));
|
||||
extern void sendto_channel(Channel *channel, Client *from, Client *skip,
|
||||
char *member_modes, long clicap, int sendflags,
|
||||
MessageTag *mtags,
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,8,9)));
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 8, 9)));
|
||||
extern void sendto_local_common_channels(Client *user, Client *skip,
|
||||
long clicap, MessageTag *mtags,
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,5,6)));
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 5, 6)));
|
||||
extern void quit_sendto_local_common_channels(Client *user, MessageTag *mtags, const char *reason);
|
||||
extern void sendto_match_servs(Channel *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4)));
|
||||
extern void sendto_match_servs(Channel *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 3, 4)));
|
||||
extern void sendto_match_butone(Client *, Client *, const char *, int, MessageTag *,
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7)));
|
||||
extern void sendto_all_butone(Client *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4)));
|
||||
extern void sendto_ops(FORMAT_STRING(const char *), ...) __attribute__((format(printf,1,2)));
|
||||
extern void sendto_prefix_one(Client *, Client *, MessageTag *, FORMAT_STRING(const char *), ...) __attribute__((format(printf,4,5)));
|
||||
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 6, 7)));
|
||||
extern void sendto_all_butone(Client *, Client *, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 3, 4)));
|
||||
extern void sendto_ops(FORMAT_STRING(const char *), ...) __attribute__((format(printf, 1, 2)));
|
||||
extern void sendto_prefix_one(Client *, Client *, MessageTag *, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 4, 5)));
|
||||
extern void vsendto_prefix_one(Client *to, Client *from, MessageTag *mtags, const char *pattern, va_list vl);
|
||||
extern void sendto_opers(FORMAT_STRING(const char *), ...) __attribute__((format(printf,1,2)));
|
||||
extern void sendto_umode(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3)));
|
||||
extern void sendto_umode_global(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3)));
|
||||
extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3)));
|
||||
extern void sendto_opers(FORMAT_STRING(const char *), ...) __attribute__((format(printf, 1, 2)));
|
||||
extern void sendto_umode(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 2, 3)));
|
||||
extern void sendto_umode_global(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 2, 3)));
|
||||
extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 2, 3)));
|
||||
/** Send numeric message to a client.
|
||||
* @param to The recipient
|
||||
* @param numeric The numeric, one of RPL_* or ERR_*, see include/numeric.h
|
||||
@@ -327,7 +327,7 @@ extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __at
|
||||
* @endcode
|
||||
* @ingroup SendFunctions
|
||||
*/
|
||||
#define sendnumeric(to, numeric, ...) sendtaggednumericfmt(to, NULL, numeric, STR_ ## numeric, ##__VA_ARGS__)
|
||||
#define sendnumeric(to, numeric, ...) sendtaggednumericfmt(to, NULL, numeric, STR_##numeric, ##__VA_ARGS__)
|
||||
|
||||
/** Send numeric message to a client - format to user specific needs.
|
||||
* This will ignore the numeric definition of src/numeric.c and always send ":me.name numeric clientname "
|
||||
@@ -350,11 +350,11 @@ extern void sendnotice(Client *to, FORMAT_STRING(const char *pattern), ...) __at
|
||||
* @param ... Format string parameters.
|
||||
* @note Don't forget to add a colon if you need it (eg `:%%s`), this is a common mistake.
|
||||
*/
|
||||
#define sendtaggednumeric(to, mtags, numeric, ...) sendtaggednumericfmt(to, mtags, numeric, STR_ ## numeric, ##__VA_ARGS__)
|
||||
#define sendtaggednumeric(to, mtags, numeric, ...) sendtaggednumericfmt(to, mtags, numeric, STR_##numeric, ##__VA_ARGS__)
|
||||
|
||||
extern void sendtaggednumericfmt(Client *to, MessageTag *mtags, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,4,5)));
|
||||
extern void sendtaggednumericfmt(Client *to, MessageTag *mtags, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 4, 5)));
|
||||
|
||||
extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,2,3)));
|
||||
extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 2, 3)));
|
||||
/** Build numeric message so it is ready to be sent to a client - rarely used, normally you use sendnumeric() instead.
|
||||
* This function is normally only used in eg CAN_KICK and CAN_SET_TOPIC, where
|
||||
* you need to set an 'errbuf' with a full IRC protocol line to reject the request
|
||||
@@ -367,8 +367,8 @@ extern void sendtxtnumeric(Client *to, FORMAT_STRING(const char *pattern), ...)
|
||||
* @note Be sure to provide the correct number and type of parameters that belong to the numeric. Check include/numeric.h when in doubt!
|
||||
* @ingroup SendFunctions
|
||||
*/
|
||||
#define buildnumeric(buf, buflen, to, numeric, ...) buildnumericfmt(buf, buflen, to, numeric, STR_ ## numeric, ##__VA_ARGS__)
|
||||
extern void buildnumericfmt(char *buf, size_t buflen, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,5,6)));
|
||||
#define buildnumeric(buf, buflen, to, numeric, ...) buildnumericfmt(buf, buflen, to, numeric, STR_##numeric, ##__VA_ARGS__)
|
||||
extern void buildnumericfmt(char *buf, size_t buflen, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 5, 6)));
|
||||
extern void sendto_server(Client *one, unsigned long caps, unsigned long nocaps, MessageTag *mtags, FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 5, 6)));
|
||||
extern void send_raw_direct(Client *user, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 2, 3)));
|
||||
extern MODVAR int writecalls, writeb[];
|
||||
@@ -402,7 +402,7 @@ extern int hunt_server(Client *, MessageTag *, const char *, int, int, const cha
|
||||
extern int cmd_server_estab(Client *);
|
||||
extern void umode_init(void);
|
||||
#define UMODE_GLOBAL 1
|
||||
#define UMODE_LOCAL 0
|
||||
#define UMODE_LOCAL 0
|
||||
extern int umode_allow_all(Client *client, int what);
|
||||
extern int umode_allow_unset(Client *client, int what);
|
||||
extern int umode_allow_opers(Client *client, int what);
|
||||
@@ -440,8 +440,8 @@ extern time_t expire_cache(time_t);
|
||||
extern void del_queries(const char *);
|
||||
|
||||
/* Hash stuff */
|
||||
#define NICK_HASH_TABLE_SIZE 32768
|
||||
#define CHAN_HASH_TABLE_SIZE 32768
|
||||
#define NICK_HASH_TABLE_SIZE 32768
|
||||
#define CHAN_HASH_TABLE_SIZE 32768
|
||||
#define WHOWAS_HASH_TABLE_SIZE 32768
|
||||
extern uint64_t siphash(const char *in, const char *k);
|
||||
extern uint64_t siphash_raw(const char *in, size_t len, const char *k);
|
||||
@@ -471,16 +471,16 @@ extern Client *hash_find_server(const char *, Client *);
|
||||
|
||||
/* Mode externs
|
||||
*/
|
||||
extern MODVAR long UMODE_INVISIBLE; /* makes user invisible */
|
||||
extern MODVAR long UMODE_OPER; /* Operator */
|
||||
extern MODVAR long UMODE_REGNICK; /* Nick set by services as registered */
|
||||
extern MODVAR long UMODE_SERVNOTICE;/* server notices such as kill */
|
||||
extern MODVAR long UMODE_HIDE; /* Hide from Nukes */
|
||||
extern MODVAR long UMODE_SECURE; /* User is a secure connect */
|
||||
extern MODVAR long UMODE_DEAF; /* Deaf */
|
||||
extern MODVAR long UMODE_HIDEOPER; /* Hide oper mode */
|
||||
extern MODVAR long UMODE_SETHOST; /* used sethost */
|
||||
extern MODVAR long UMODE_HIDLE; /* hides oper idle times */
|
||||
extern MODVAR long UMODE_INVISIBLE; /* makes user invisible */
|
||||
extern MODVAR long UMODE_OPER; /* Operator */
|
||||
extern MODVAR long UMODE_REGNICK; /* Nick set by services as registered */
|
||||
extern MODVAR long UMODE_SERVNOTICE; /* server notices such as kill */
|
||||
extern MODVAR long UMODE_HIDE; /* Hide from Nukes */
|
||||
extern MODVAR long UMODE_SECURE; /* User is a secure connect */
|
||||
extern MODVAR long UMODE_DEAF; /* Deaf */
|
||||
extern MODVAR long UMODE_HIDEOPER; /* Hide oper mode */
|
||||
extern MODVAR long UMODE_SETHOST; /* used sethost */
|
||||
extern MODVAR long UMODE_HIDLE; /* hides oper idle times */
|
||||
extern MODVAR long AllUmodes, SendUmodes;
|
||||
|
||||
extern MODVAR long SNO_KILLS;
|
||||
@@ -518,7 +518,7 @@ extern char *strldup(const char *src, size_t n);
|
||||
|
||||
extern void dopacket(Client *, char *, int);
|
||||
|
||||
extern void debug(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf,2,3)));
|
||||
extern void debug(int, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 2, 3)));
|
||||
#if defined(DEBUGMODE)
|
||||
extern void send_usage(Client *, const char *);
|
||||
extern void count_memory(Client *, const char *);
|
||||
@@ -551,14 +551,14 @@ extern int b64_decode(char const *src, unsigned char *target, size_t targsize);
|
||||
|
||||
extern AuthenticationType Auth_FindType(const char *hash, const char *type);
|
||||
extern void AuthBlockToAuthConfig(ConfigEntry *ce, AuthConfig **list);
|
||||
extern void Auth_FreeAuthConfig(AuthConfig *as);
|
||||
extern int Auth_Check(Client *cptr, AuthConfig *as, const char *para);
|
||||
extern const char *Auth_Hash(AuthenticationType type, const char *text);
|
||||
extern int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext);
|
||||
extern int Auth_AutoDetectHashType(const char *hash);
|
||||
extern void Auth_FreeAuthConfig(AuthConfig *as);
|
||||
extern int Auth_Check(Client *cptr, AuthConfig *as, const char *para);
|
||||
extern const char *Auth_Hash(AuthenticationType type, const char *text);
|
||||
extern int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext);
|
||||
extern int Auth_AutoDetectHashType(const char *hash);
|
||||
|
||||
extern void make_cloakedhost(Client *client, const char *curr, char *buf, size_t buflen);
|
||||
extern int channel_canjoin(Client *client, const char *name);
|
||||
extern int channel_canjoin(Client *client, const char *name);
|
||||
extern char *collapse(char *pattern);
|
||||
extern void dcc_sync(Client *client);
|
||||
extern void request_rehash(Client *client);
|
||||
@@ -568,10 +568,10 @@ extern int match_simple(const char *mask, const char *name);
|
||||
extern int match_esc(const char *mask, const char *name);
|
||||
extern int add_listener(ConfigItem_listen *conf);
|
||||
extern void link_cleanup(ConfigItem_link *link_ptr);
|
||||
extern void listen_cleanup();
|
||||
extern int numeric_collides(long numeric);
|
||||
extern void flag_add(char ch);
|
||||
extern void flag_del(char ch);
|
||||
extern void listen_cleanup();
|
||||
extern int numeric_collides(long numeric);
|
||||
extern void flag_add(char ch);
|
||||
extern void flag_del(char ch);
|
||||
extern void init_dynconf(void);
|
||||
extern int config_read_start(void);
|
||||
extern int is_config_read_finished(void);
|
||||
@@ -596,7 +596,13 @@ extern void *safe_alloc(size_t size);
|
||||
/** Free previously allocate memory pointer.
|
||||
* This also sets the pointer to NULL, since that would otherwise be common to forget.
|
||||
*/
|
||||
#define safe_free(x) do { if (x) free(x); x = NULL; } while(0)
|
||||
#define safe_free(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
free(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
/** Free previously allocated memory pointer.
|
||||
* Raw version which does not touch the pointer itself. You most likely don't
|
||||
* need this, as it's only used in 1 place in UnrealIRCd.
|
||||
@@ -607,7 +613,16 @@ extern void *safe_alloc(size_t size);
|
||||
* @param dst The current pointer and the pointer where a new copy of the string will be stored.
|
||||
* @param str The string you want to copy
|
||||
*/
|
||||
#define safe_strdup(dst,str) do { if (dst) free(dst); if ((str) == NULL) dst = NULL; else dst = our_strdup(str); } while(0)
|
||||
#define safe_strdup(dst, str) \
|
||||
do \
|
||||
{ \
|
||||
if (dst) \
|
||||
free(dst); \
|
||||
if ((str) == NULL) \
|
||||
dst = NULL; \
|
||||
else \
|
||||
dst = our_strdup(str); \
|
||||
} while (0)
|
||||
|
||||
/** Return a copy of the string. Do not free any existing memory.
|
||||
* @param str The string to duplicate
|
||||
@@ -628,7 +643,16 @@ extern void *safe_alloc(size_t size);
|
||||
* @param str The string you want to copy
|
||||
* @param sz Length limit including the NUL byte, usually sizeof(dst)
|
||||
*/
|
||||
#define safe_strldup(dst,str,sz) do { if (dst) free(dst); if (!str) dst = NULL; else dst = our_strldup(str,sz); } while(0)
|
||||
#define safe_strldup(dst, str, sz) \
|
||||
do \
|
||||
{ \
|
||||
if (dst) \
|
||||
free(dst); \
|
||||
if (!str) \
|
||||
dst = NULL; \
|
||||
else \
|
||||
dst = our_strldup(str, sz); \
|
||||
} while (0)
|
||||
|
||||
/** Return a duplicate of the specified string with a length limit. Do not free any existing memory.
|
||||
* @param str The string you want to copy
|
||||
@@ -653,7 +677,13 @@ extern void *safe_alloc_sensitive(size_t size);
|
||||
* It also sets the pointer to NULL, since that would otherwise be common to forget.
|
||||
* @note If you call this function on normally allocated memory (non-sensitive) then we will crash.
|
||||
*/
|
||||
#define safe_free_sensitive(x) do { if (x) sodium_free(x); x = NULL; } while(0)
|
||||
#define safe_free_sensitive(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
sodium_free(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
|
||||
/** Free previous memory (if any) and then save a duplicate of the specified string -
|
||||
* This is the 'sensitive' version which should only be used for HIGHLY sensitive data,
|
||||
@@ -661,12 +691,26 @@ extern void *safe_alloc_sensitive(size_t size);
|
||||
* @param dst The current pointer and the pointer where a new copy of the string will be stored.
|
||||
* @param str The string you want to copy
|
||||
*/
|
||||
#define safe_strdup_sensitive(dst,str) do { if (dst) sodium_free(dst); if (!(str)) dst = NULL; else dst = our_strdup_sensitive(str); } while(0)
|
||||
#define safe_strdup_sensitive(dst, str) \
|
||||
do \
|
||||
{ \
|
||||
if (dst) \
|
||||
sodium_free(dst); \
|
||||
if (!(str)) \
|
||||
dst = NULL; \
|
||||
else \
|
||||
dst = our_strdup_sensitive(str); \
|
||||
} while (0)
|
||||
|
||||
/** Safely destroy a string in memory (but do not free!) */
|
||||
#define destroy_string(str) sodium_memzero(str, strlen(str))
|
||||
|
||||
#define safe_json_decref(result) do { json_decref(result); result = NULL; } while(0)
|
||||
#define safe_json_decref(result) \
|
||||
do \
|
||||
{ \
|
||||
json_decref(result); \
|
||||
result = NULL; \
|
||||
} while (0)
|
||||
|
||||
/** @} */
|
||||
extern char *our_strdup(const char *str);
|
||||
@@ -674,7 +718,7 @@ extern char *our_strldup(const char *str, size_t max);
|
||||
extern char *our_strdup_sensitive(const char *str);
|
||||
|
||||
extern long config_checkval(const char *value, unsigned short flags);
|
||||
extern void config_status(FORMAT_STRING(const char *format), ...) __attribute__((format(printf,1,2)));
|
||||
extern void config_status(FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 1, 2)));
|
||||
extern void init_random();
|
||||
extern u_char getrandom8();
|
||||
extern uint16_t getrandom16();
|
||||
@@ -682,9 +726,21 @@ extern uint32_t getrandom32();
|
||||
extern void gen_random_alnum(char *buf, int numbytes);
|
||||
|
||||
/* Check config entry for empty/missing parameter */
|
||||
#define CheckNull(x) if ((!(x)->value) || (!(*((x)->value)))) { config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); errors++; continue; }
|
||||
#define CheckNull(x) \
|
||||
if ((!(x)->value) || (!(*((x)->value)))) \
|
||||
{ \
|
||||
config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); \
|
||||
errors++; \
|
||||
continue; \
|
||||
}
|
||||
/* as above, but accepting empty string */
|
||||
#define CheckNullAllowEmpty(x) if ((!(x)->value)) { config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); errors++; continue; }
|
||||
#define CheckNullAllowEmpty(x) \
|
||||
if ((!(x)->value)) \
|
||||
{ \
|
||||
config_error("%s:%i: missing parameter", (x)->file->filename, (x)->line_number); \
|
||||
errors++; \
|
||||
continue; \
|
||||
}
|
||||
|
||||
extern MODVAR char extchmstr[4][64];
|
||||
|
||||
@@ -740,8 +796,18 @@ extern void parse_ban_action_config(ConfigEntry *ce, BanAction **store_action);
|
||||
extern int test_ban_action_config(ConfigEntry *ce);
|
||||
extern void free_single_ban_action(BanAction *action);
|
||||
extern void free_all_ban_actions(BanAction *actions);
|
||||
#define safe_free_all_ban_actions(x) do { free_all_ban_actions(x); x = NULL; } while(0)
|
||||
#define safe_free_single_ban_action(x) do { free_single_ban_action(x); x = NULL; } while(0)
|
||||
#define safe_free_all_ban_actions(x) \
|
||||
do \
|
||||
{ \
|
||||
free_all_ban_actions(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
#define safe_free_single_ban_action(x) \
|
||||
do \
|
||||
{ \
|
||||
free_single_ban_action(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
BanAction *duplicate_ban_actions(BanAction *actions);
|
||||
extern int highest_ban_action(BanAction *action);
|
||||
extern BanActionValue banact_stringtoval(const char *s);
|
||||
@@ -765,7 +831,7 @@ extern void remove_oper_modes(Client *client);
|
||||
extern char *spamfilter_inttostring_long(int v);
|
||||
extern int is_invited(Client *client, Channel *channel);
|
||||
extern void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, size_t pbuf_size, Channel *channel, int hide_local_modes);
|
||||
extern int op_can_override(const char *acl, Client *client,Channel *channel,void* extra);
|
||||
extern int op_can_override(const char *acl, Client *client, Channel *channel, void *extra);
|
||||
extern Client *find_chasing(Client *client, const char *user, int *chasing);
|
||||
extern MODVAR long opermode;
|
||||
extern MODVAR long sajoinmode;
|
||||
@@ -810,7 +876,7 @@ extern MODVAR void (*join_channel)(Channel *channel, Client *client, MessageTag
|
||||
extern MODVAR int (*can_join)(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
extern MODVAR void (*do_mode)(Channel *channel, Client *client, MessageTag *mtags, int parc, const char *parv[], time_t sendts, int samode);
|
||||
extern MODVAR MultiLineMode *(*set_mode)(Channel *channel, Client *cptr, int parc, const char *parv[], u_int *pcount,
|
||||
char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]);
|
||||
char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]);
|
||||
extern MODVAR void (*set_channel_mode)(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters);
|
||||
extern MODVAR void (*set_channel_topic)(Client *client, Channel *channel, MessageTag *recv_mtags, const char *topic, const char *set_by, time_t set_at);
|
||||
extern MODVAR void (*cmd_umode)(ClientContext *, Client *, MessageTag *, int, const char **);
|
||||
@@ -828,7 +894,7 @@ extern MODVAR TKL *(*tkl_add_banexception)(int type, const char *usermask, const
|
||||
const char *reason, const char *set_by,
|
||||
time_t expire_at, time_t set_at, int soft, const char *bantypes, int flags);
|
||||
extern MODVAR TKL *(*tkl_add_nameban)(int type, const char *name, int hold, const char *reason, const char *setby,
|
||||
time_t expire_at, time_t set_at, int flags);
|
||||
time_t expire_at, time_t set_at, int flags);
|
||||
extern MODVAR TKL *(*tkl_add_spamfilter)(int type, const char *id, unsigned short target, BanAction *action,
|
||||
Match *match, const char *rule, SecurityGroup *except,
|
||||
const char *setby,
|
||||
@@ -928,7 +994,7 @@ extern MODVAR void (*webserver_close_client)(Client *client);
|
||||
extern MODVAR int (*webserver_handle_body)(Client *client, WebRequest *web, const char *readbuf, int length);
|
||||
extern MODVAR void (*rpc_response)(Client *client, json_t *request, json_t *result);
|
||||
extern MODVAR void (*rpc_error)(Client *client, json_t *request, JsonRpcError error_code, const char *error_message);
|
||||
extern MODVAR void (*rpc_error_fmt)(Client *client, json_t *request, JsonRpcError error_code, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf,4,5)));
|
||||
extern MODVAR void (*rpc_error_fmt)(Client *client, json_t *request, JsonRpcError error_code, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf, 4, 5)));
|
||||
extern MODVAR void (*rpc_send_request_to_remote)(Client *source, Client *target, json_t *request);
|
||||
extern MODVAR void (*rpc_send_response_to_remote)(Client *source, Client *target, json_t *request);
|
||||
extern MODVAR int (*rrpc_supported_simple)(Client *target, char **problem_server);
|
||||
@@ -944,7 +1010,12 @@ extern MODVAR int (*spamreport)(Client *client, const char *ip, NameValuePrioLis
|
||||
extern MODVAR int (*crule_test)(const char *rule);
|
||||
extern MODVAR CRuleNode *(*crule_parse)(const char *rule);
|
||||
extern MODVAR int (*crule_eval)(crule_context *context, CRuleNode *rule);
|
||||
#define safe_crule_free(x) do { if (x) crule_free(&x); } while(0)
|
||||
#define safe_crule_free(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
crule_free(&x); \
|
||||
} while (0)
|
||||
extern MODVAR void (*crule_free)(CRuleNode **);
|
||||
extern MODVAR const char *(*crule_errstring)(int errcode);
|
||||
extern MODVAR void (*ban_act_set_reputation)(Client *client, BanAction *action);
|
||||
@@ -974,7 +1045,7 @@ extern MODVAR void (*channel_flood_expand_json)(json_t *root, Client *client);
|
||||
/* TLS functions */
|
||||
extern int early_init_tls();
|
||||
extern int init_tls();
|
||||
extern int ssl_handshake(Client *); /* Handshake the accpeted con.*/
|
||||
extern int ssl_handshake(Client *); /* Handshake the accpeted con.*/
|
||||
extern int ssl_client_handshake(Client *, ConfigItem_link *); /* and the initiated con.*/
|
||||
extern int unreal_tls_accept(Client *acptr, int fd);
|
||||
extern int unreal_tls_connect(Client *acptr, int fd);
|
||||
@@ -1226,13 +1297,19 @@ extern int is_handshake_finished(Client *client);
|
||||
extern void SetCapability(Client *acptr, const char *token);
|
||||
extern void ClearCapability(Client *acptr, const char *token);
|
||||
extern void new_message(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list);
|
||||
extern void new_message_special(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,4,5)));
|
||||
extern void new_message_special(Client *sender, MessageTag *recv_mtags, MessageTag **mtag_list, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 4, 5)));
|
||||
extern void generate_batch_id(char *str);
|
||||
extern MessageTag *find_mtag(MessageTag *mtags, const char *token);
|
||||
extern MessageTag *duplicate_mtag(MessageTag *mtag);
|
||||
extern MessageTag *duplicate_mtags(MessageTag *mtags);
|
||||
extern MessageTag *duplicate_mtags_for_subsequent_lines(MessageTag *mtags);
|
||||
#define safe_free_message_tags(x) do { if (x) free_message_tags(x); x = NULL; } while(0)
|
||||
#define safe_free_message_tags(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
free_message_tags(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
extern void free_message_tags(MessageTag *m);
|
||||
extern int history_set_limit(const char *object, int max_lines, long max_t);
|
||||
extern int history_add(const char *object, MessageTag *mtags, const char *line);
|
||||
@@ -1274,7 +1351,13 @@ extern int is_extended_ban(const char *str);
|
||||
extern int is_extended_server_ban(const char *str);
|
||||
extern int empty_mode(const char *m);
|
||||
extern void free_multilinemode(MultiLineMode *m);
|
||||
#define safe_free_multilinemode(m) do { if (m) free_multilinemode(m); m = NULL; } while(0)
|
||||
#define safe_free_multilinemode(m) \
|
||||
do \
|
||||
{ \
|
||||
if (m) \
|
||||
free_multilinemode(m); \
|
||||
m = NULL; \
|
||||
} while (0)
|
||||
extern ExtbanType mode_letter_to_extbantype(char c);
|
||||
extern ExtbanType listmode_sjoin_prefix_to_extbantype(char c);
|
||||
extern int valid_sid(const char *name);
|
||||
@@ -1286,7 +1369,13 @@ extern char *filename_add_suffix(const char *fname, const char *suffix);
|
||||
extern int filename_has_suffix(const char *fname, const char *suffix);
|
||||
extern void addmultiline(MultiLine **l, const char *line);
|
||||
extern void freemultiline(MultiLine *l);
|
||||
#define safe_free_multiline(x) do { if (x) freemultiline(x); x = NULL; } while(0)
|
||||
#define safe_free_multiline(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
freemultiline(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
extern MultiLine *line2multiline(const char *str);
|
||||
extern void sendnotice_multiline(Client *client, MultiLine *m);
|
||||
extern void unreal_del_quotes(char *i);
|
||||
@@ -1299,12 +1388,12 @@ extern void lost_server_link(Client *serv, const char *tls_error_string);
|
||||
extern const char *sendtype_to_cmd(SendType sendtype);
|
||||
extern MODVAR MessageTagHandler *mtaghandlers;
|
||||
extern MODVAR RPCHandler *rpchandlers;
|
||||
#define nv_find_by_name(stru, name) do_nv_find_by_name(stru, name, ARRAY_SIZEOF((stru)))
|
||||
#define nv_find_by_name(stru, name) do_nv_find_by_name(stru, name, ARRAY_SIZEOF((stru)))
|
||||
extern long do_nv_find_by_name(NameValue *table, const char *cmd, int numelements);
|
||||
#define nv_find_by_value(stru, value) do_nv_find_by_value(stru, value, ARRAY_SIZEOF((stru)))
|
||||
#define nv_find_by_value(stru, value) do_nv_find_by_value(stru, value, ARRAY_SIZEOF((stru)))
|
||||
extern const char *do_nv_find_by_value(NameValue *table, long value, int numelements);
|
||||
extern NameValuePrioList *add_nvplist(NameValuePrioList **lst, int priority, const char *name, const char *value);
|
||||
extern void add_fmt_nvplist(NameValuePrioList **lst, int priority, const char *name, FORMAT_STRING(const char *format), ...) __attribute__((format(printf,4,5)));
|
||||
extern void add_fmt_nvplist(NameValuePrioList **lst, int priority, const char *name, FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 4, 5)));
|
||||
/** Combination of add_nvplist() and buildnumeric() for convenience - only used in WHOIS response functions.
|
||||
* @param lst The NameValuePrioList &head
|
||||
* @param priority The priority of the item being added
|
||||
@@ -1314,12 +1403,17 @@ extern void add_fmt_nvplist(NameValuePrioList **lst, int priority, const char *n
|
||||
* @param ... The parameters for the numeric
|
||||
* @note Be sure to provide the correct number and type of parameters that belong to the numeric. Check include/numeric.h when in doubt!
|
||||
*/
|
||||
#define add_nvplist_numeric(lst, priority, name, to, numeric, ...) add_nvplist_numeric_fmt(lst, priority, name, to, numeric, STR_ ## numeric, ##__VA_ARGS__)
|
||||
extern void add_nvplist_numeric_fmt(NameValuePrioList **lst, int priority, const char *name, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7)));
|
||||
#define add_nvplist_numeric(lst, priority, name, to, numeric, ...) add_nvplist_numeric_fmt(lst, priority, name, to, numeric, STR_##numeric, ##__VA_ARGS__)
|
||||
extern void add_nvplist_numeric_fmt(NameValuePrioList **lst, int priority, const char *name, Client *to, int numeric, FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf, 6, 7)));
|
||||
extern NameValuePrioList *find_nvplist(NameValuePrioList *list, const char *name);
|
||||
extern const char *get_nvplist(NameValuePrioList *list, const char *name);
|
||||
extern void free_nvplist(NameValuePrioList *lst);
|
||||
#define safe_free_nvplist(x) do { free_nvplist(x); x = NULL; } while(0)
|
||||
#define safe_free_nvplist(x) \
|
||||
do \
|
||||
{ \
|
||||
free_nvplist(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
extern void del_nvplist_entry(NameValuePrioList *nvp, NameValuePrioList **lst);
|
||||
extern NameValuePrioList *duplicate_nvplist(NameValuePrioList *e);
|
||||
extern NameValuePrioList *duplicate_nvplist_append(NameValuePrioList *e, NameValuePrioList **list);
|
||||
@@ -1375,7 +1469,15 @@ extern int security_group_exists(const char *name);
|
||||
extern SecurityGroup *add_security_group(const char *name, int order);
|
||||
extern SecurityGroup *find_security_group(const char *name);
|
||||
extern void free_security_group(SecurityGroup *s);
|
||||
#define safe_free_security_group(x) do { if (x) { free_security_group(x); x = NULL; } } while(0)
|
||||
#define safe_free_security_group(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
{ \
|
||||
free_security_group(x); \
|
||||
x = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
extern SecurityGroup *duplicate_security_group(SecurityGroup *s);
|
||||
extern void set_security_group_defaults(void);
|
||||
extern int user_allowed_by_security_group(Client *client, SecurityGroup *s);
|
||||
@@ -1436,7 +1538,7 @@ extern const char *log_level_terminal_color(LogLevel loglevel);
|
||||
extern LogType log_type_stringtoval(const char *str);
|
||||
extern const char *log_type_valtostring(LogType v);
|
||||
#ifdef DEBUGMODE
|
||||
/* In debug mode we include file/linenumber. We put this arg at the end, however
|
||||
/* In debug mode we include file/linenumber. We put this arg at the end, however
|
||||
* there is an issue if unreal_log() is used with a parameter like xyz ? log_data_string("zzz") : NULL,
|
||||
* since then our log_data_source() would be beyond NULL and thus would never be freed,
|
||||
* so we allocate and handle that differently. File/line would still be lost but at
|
||||
@@ -1444,31 +1546,41 @@ extern const char *log_type_valtostring(LogType v);
|
||||
* parameters explicitly, put log_data_source() at the beginning of the argument list
|
||||
* and then use non-portable ## __VA_ARGS__ for the remainder.
|
||||
*/
|
||||
#define unreal_log(level, sys, id, ...) do { \
|
||||
if (!log_throttled((sys), (id))) { \
|
||||
LogData *lds = log_data_source(__FILE__, __LINE__, __FUNCTION__); \
|
||||
do_unreal_log((level), (sys), (id), __VA_ARGS__, lds, NULL); \
|
||||
log_data_free(lds); \
|
||||
} \
|
||||
} while(0)
|
||||
#define unreal_log_raw(level, sys, id, ...) do { \
|
||||
if (!log_throttled((sys), (id))) { \
|
||||
LogData *lds = log_data_source(__FILE__, __LINE__, __FUNCTION__); \
|
||||
do_unreal_log_raw((level), (sys), (id), __VA_ARGS__, lds, NULL); \
|
||||
log_data_free(lds); \
|
||||
} \
|
||||
} while(0)
|
||||
#define unreal_log(level, sys, id, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
{ \
|
||||
LogData *lds = log_data_source(__FILE__, __LINE__, __FUNCTION__); \
|
||||
do_unreal_log((level), (sys), (id), __VA_ARGS__, lds, NULL); \
|
||||
log_data_free(lds); \
|
||||
} \
|
||||
} while (0)
|
||||
#define unreal_log_raw(level, sys, id, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
{ \
|
||||
LogData *lds = log_data_source(__FILE__, __LINE__, __FUNCTION__); \
|
||||
do_unreal_log_raw((level), (sys), (id), __VA_ARGS__, lds, NULL); \
|
||||
log_data_free(lds); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define unreal_log(level, sys, id, ...) do { \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
do_unreal_log((level), (sys), (id), __VA_ARGS__, NULL); \
|
||||
} while(0)
|
||||
#define unreal_log_raw(level, sys, id, ...) do { \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
do_unreal_log_raw((level), (sys), (id), __VA_ARGS__, NULL); \
|
||||
} while(0)
|
||||
#define unreal_log(level, sys, id, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
do_unreal_log((level), (sys), (id), __VA_ARGS__, NULL); \
|
||||
} while (0)
|
||||
#define unreal_log_raw(level, sys, id, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (!log_throttled((sys), (id))) \
|
||||
do_unreal_log_raw((level), (sys), (id), __VA_ARGS__, NULL); \
|
||||
} while (0)
|
||||
#endif
|
||||
extern void do_unreal_log(LogLevel loglevel, const char *subsystem, const char *event_id, Client *client, const char *msg, ...) __attribute__((format(printf,5,0)));
|
||||
extern void do_unreal_log(LogLevel loglevel, const char *subsystem, const char *event_id, Client *client, const char *msg, ...) __attribute__((format(printf, 5, 0)));
|
||||
extern void do_unreal_log_raw(LogLevel loglevel, const char *subsystem, const char *event_id, Client *client, const char *msg, ...);
|
||||
extern void do_unreal_log_internal_from_remote(LogLevel loglevel, const char *subsystem, const char *event_id, MultiLine *msg, json_t *json, const char *json_serialized, Client *from_server);
|
||||
extern LogData *log_data_string(const char *key, const char *str);
|
||||
@@ -1542,7 +1654,7 @@ extern int downloads_in_progress(void);
|
||||
/* end of url stuff */
|
||||
extern char *collapse(char *pattern);
|
||||
extern void clear_scache_hash_table(void);
|
||||
extern void sendto_one(Client *, MessageTag *mtags, FORMAT_STRING(const char *), ...) __attribute__((format(printf,3,4)));
|
||||
extern void sendto_one(Client *, MessageTag *mtags, FORMAT_STRING(const char *), ...) __attribute__((format(printf, 3, 4)));
|
||||
extern void vsendto_one(Client *to, MessageTag *mtags, const char *pattern, va_list vl);
|
||||
extern void mark_data_to_send(Client *to);
|
||||
extern EVENT(garbage_collect);
|
||||
@@ -1596,7 +1708,15 @@ extern MODVAR DynamicSetBlock unknown_users_set;
|
||||
extern MODVAR DynamicSetBlock dynamic_set;
|
||||
extern void start_dns_and_ident_lookup(Client *client);
|
||||
extern void free_webserver(WebServer *webserver);
|
||||
#define safe_free_webserver(x) do { if (x) { free_webserver(x); x = NULL; } } while(0)
|
||||
#define safe_free_webserver(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
{ \
|
||||
free_webserver(x); \
|
||||
x = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
extern Tag *find_tag(Client *client, const char *name);
|
||||
extern Tag *add_tag(Client *client, const char *name, int value);
|
||||
extern void free_all_tags(Client *client);
|
||||
@@ -1612,7 +1732,15 @@ extern int highest_channel_member_count(Client *client);
|
||||
extern MODVAR long long central_spamfilter_last_download;
|
||||
extern int valid_operclass_character(char c);
|
||||
extern int valid_operclass_name(const char *str);
|
||||
#define safe_free_outgoingwebrequest(x) do { if (x) { free_outgoingwebrequest(x); x = NULL; } } while(0)
|
||||
#define safe_free_outgoingwebrequest(x) \
|
||||
do \
|
||||
{ \
|
||||
if (x) \
|
||||
{ \
|
||||
free_outgoingwebrequest(x); \
|
||||
x = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
extern void free_outgoingwebrequest(OutgoingWebRequest *r);
|
||||
extern OutgoingWebRequest *duplicate_outgoingwebrequest(OutgoingWebRequest *orig);
|
||||
extern void url_callback(OutgoingWebRequest *r, const char *file, const char *memory, long long memory_len, const char *errorbuf, int cached, void *ptr);
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
/* ugly hack GRR, for both attribute and FORMAT_STRING */
|
||||
#if !defined(__GNUC__) && !defined(__common_include__)
|
||||
#define __attribute__(x) /* nothing */
|
||||
#define __attribute__(x) /* nothing */
|
||||
#endif
|
||||
#ifndef FORMAT_STRING
|
||||
# define FORMAT_STRING(p) p
|
||||
#define FORMAT_STRING(p) p
|
||||
#endif
|
||||
|
||||
extern char *ircvsnprintf(char *str, size_t size, const char *format, va_list) __attribute__((format(printf,3,0)));
|
||||
extern char *ircsnprintf(char *str, size_t size, FORMAT_STRING(const char *format), ...) __attribute__((format(printf,3,4)));
|
||||
extern char *ircvsnprintf(char *str, size_t size, const char *format, va_list) __attribute__((format(printf, 3, 0)));
|
||||
extern char *ircsnprintf(char *str, size_t size, FORMAT_STRING(const char *format), ...) __attribute__((format(printf, 3, 4)));
|
||||
|
||||
#endif
|
||||
|
||||
+20
-20
@@ -26,24 +26,24 @@
|
||||
|
||||
|
||||
char *gnulicense[] = {
|
||||
" \2UnrealIRCd License\2",
|
||||
"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.",
|
||||
"",
|
||||
"To see the UnrealIRCd License, please point your browser",
|
||||
"to https://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
|
||||
"or look at the LICENSE file in the UnrealIRCd distribution.",
|
||||
NULL,
|
||||
" \2UnrealIRCd License\2",
|
||||
"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.",
|
||||
"",
|
||||
"To see the UnrealIRCd License, please point your browser",
|
||||
"to https://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
|
||||
"or look at the LICENSE file in the UnrealIRCd distribution.",
|
||||
NULL,
|
||||
};
|
||||
|
||||
+62
-59
@@ -10,13 +10,13 @@
|
||||
#include "common.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#define SINLINE static inline
|
||||
#define SINLINE static inline
|
||||
#else
|
||||
#define SINLINE static
|
||||
#define SINLINE static
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define typeof(x) Client
|
||||
#define typeof(x) Client
|
||||
/* ^ FIXME if/when Microsoft supports this.
|
||||
* All functions use Client at the moment, with the exception of CAP, which has
|
||||
* to use list_for_each_entry2 because of it
|
||||
@@ -33,7 +33,7 @@
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)( (char *)ptr - offsetof(type, member) ))
|
||||
((type *)((char *)ptr - offsetof(type, member)))
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
@@ -49,7 +49,7 @@ struct list_head {
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
#define LIST_HEAD_INIT(name) {&(name), &(name)}
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
@@ -67,8 +67,8 @@ SINLINE void INIT_LIST_HEAD(struct list_head *list)
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
SINLINE void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
@@ -110,7 +110,7 @@ SINLINE void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
SINLINE void __list_del(struct list_head * prev, struct list_head * next)
|
||||
SINLINE void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
@@ -141,7 +141,7 @@ SINLINE void list_del(struct list_head *entry)
|
||||
* If @old was empty, it will be overwritten.
|
||||
*/
|
||||
SINLINE void list_replace(struct list_head *old,
|
||||
struct list_head *new)
|
||||
struct list_head *new)
|
||||
{
|
||||
new->next = old->next;
|
||||
new->next->prev = new;
|
||||
@@ -150,7 +150,7 @@ SINLINE void list_replace(struct list_head *old,
|
||||
}
|
||||
|
||||
SINLINE void list_replace_init(struct list_head *old,
|
||||
struct list_head *new)
|
||||
struct list_head *new)
|
||||
{
|
||||
list_replace(old, new);
|
||||
INIT_LIST_HEAD(old);
|
||||
@@ -183,7 +183,7 @@ SINLINE void list_move(struct list_head *list, struct list_head *head)
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
SINLINE void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del_entry(list);
|
||||
list_add_tail(list, head);
|
||||
@@ -195,7 +195,7 @@ SINLINE void list_move_tail(struct list_head *list,
|
||||
* @head: the head of the list
|
||||
*/
|
||||
SINLINE int list_is_last(const struct list_head *list,
|
||||
const struct list_head *head)
|
||||
const struct list_head *head)
|
||||
{
|
||||
return list->next == head;
|
||||
}
|
||||
@@ -236,7 +236,8 @@ SINLINE void list_rotate_left(struct list_head *head)
|
||||
{
|
||||
struct list_head *first;
|
||||
|
||||
if (!list_empty(head)) {
|
||||
if (!list_empty(head))
|
||||
{
|
||||
first = head->next;
|
||||
list_move_tail(first, head);
|
||||
}
|
||||
@@ -252,7 +253,7 @@ SINLINE int list_is_singular(const struct list_head *head)
|
||||
}
|
||||
|
||||
SINLINE void __list_cut_position(struct list_head *list,
|
||||
struct list_head *head, struct list_head *entry)
|
||||
struct list_head *head, struct list_head *entry)
|
||||
{
|
||||
struct list_head *new_first = entry->next;
|
||||
list->next = head->next;
|
||||
@@ -278,12 +279,12 @@ SINLINE void __list_cut_position(struct list_head *list,
|
||||
*
|
||||
*/
|
||||
SINLINE void list_cut_position(struct list_head *list,
|
||||
struct list_head *head, struct list_head *entry)
|
||||
struct list_head *head, struct list_head *entry)
|
||||
{
|
||||
if (list_empty(head))
|
||||
return;
|
||||
if (list_is_singular(head) &&
|
||||
(head->next != entry && head != entry))
|
||||
(head->next != entry && head != entry))
|
||||
return;
|
||||
if (entry == head)
|
||||
INIT_LIST_HEAD(list);
|
||||
@@ -292,8 +293,8 @@ SINLINE void list_cut_position(struct list_head *list,
|
||||
}
|
||||
|
||||
SINLINE void __list_splice(const struct list_head *list,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
@@ -311,7 +312,7 @@ SINLINE void __list_splice(const struct list_head *list,
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
SINLINE void list_splice(const struct list_head *list,
|
||||
struct list_head *head)
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head, head->next);
|
||||
@@ -323,7 +324,7 @@ SINLINE void list_splice(const struct list_head *list,
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
SINLINE void list_splice_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head->prev, head);
|
||||
@@ -337,9 +338,10 @@ SINLINE void list_splice_tail(struct list_head *list,
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
SINLINE void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
if (!list_empty(list))
|
||||
{
|
||||
__list_splice(list, head, head->next);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
@@ -354,9 +356,10 @@ SINLINE void list_splice_init(struct list_head *list,
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
if (!list_empty(list))
|
||||
{
|
||||
__list_splice(list, head->prev, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
@@ -417,7 +420,7 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
|
||||
@@ -487,9 +490,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
@@ -498,9 +501,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry2(pos, tpe, head, member) \
|
||||
for (pos = list_entry((head)->next, tpe, member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry2(pos, tpe, head, member) \
|
||||
for (pos = list_entry((head)->next, tpe, member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, tpe, member))
|
||||
|
||||
/**
|
||||
@@ -509,9 +512,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
@@ -523,7 +526,7 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Prepares a pos entry for use as a start point in list_for_each_entry_continue().
|
||||
*/
|
||||
#define list_prepare_entry(pos, head, member) \
|
||||
((pos) ? : list_entry(head, typeof(*pos), member))
|
||||
((pos) ?: list_entry(head, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_continue - continue iteration over list of given type
|
||||
@@ -534,9 +537,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Continue to iterate over list of given type, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_continue(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
@@ -548,9 +551,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Start to iterate over list of given type backwards, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue_reverse(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_continue_reverse(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
@@ -561,8 +564,8 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
*
|
||||
* Iterate over list of given type, continuing from current position.
|
||||
*/
|
||||
#define list_for_each_entry_from(pos, head, member) \
|
||||
for (; &pos->member != (head); \
|
||||
#define list_for_each_entry_from(pos, head, member) \
|
||||
for (; &pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/** Walk through client lists - special 'safe' version.
|
||||
@@ -576,10 +579,10 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* @param member The name of the list_struct within the struct.
|
||||
* @ingroup ListFunctions
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
@@ -592,10 +595,10 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate over list of given type, continuing after current point,
|
||||
* safe against removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_continue(pos, n, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_safe_continue(pos, n, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
@@ -608,9 +611,9 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate over list of given type from current point, safe against
|
||||
* removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_from(pos, n, head, member) \
|
||||
for (n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_safe_from(pos, n, head, member) \
|
||||
for (n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
@@ -623,10 +626,10 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* Iterate backwards over list of given type, safe against removal
|
||||
* of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
|
||||
|
||||
/**
|
||||
@@ -641,7 +644,7 @@ SINLINE void list_splice_tail_init(struct list_head *list,
|
||||
* and list_safe_reset_next is called after re-taking the lock and before
|
||||
* completing the current iteration of the loop body.
|
||||
*/
|
||||
#define list_safe_reset_next(pos, n, member) \
|
||||
#define list_safe_reset_next(pos, n, member) \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member)
|
||||
|
||||
#endif
|
||||
|
||||
+23
-23
@@ -40,7 +40,7 @@
|
||||
#define TOR_MEMPOOL_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define uint64_t unsigned __int64
|
||||
#define uint64_t unsigned __int64
|
||||
#endif
|
||||
|
||||
/** A memory pool is a context in which a large number of fixed-sized
|
||||
@@ -61,44 +61,44 @@ extern void mp_pool_garbage_collect(void *);
|
||||
#define MEMPOOL_STATS
|
||||
|
||||
struct mp_pool_t {
|
||||
/** Next pool. A pool is usually linked into the mp_allocated_pools list. */
|
||||
mp_pool_t *next;
|
||||
/** Next pool. A pool is usually linked into the mp_allocated_pools list. */
|
||||
mp_pool_t *next;
|
||||
|
||||
/** Doubly-linked list of chunks in which no items have been allocated.
|
||||
/** Doubly-linked list of chunks in which no items have been allocated.
|
||||
* The front of the list is the most recently emptied chunk. */
|
||||
struct mp_chunk_t *empty_chunks;
|
||||
struct mp_chunk_t *empty_chunks;
|
||||
|
||||
/** Doubly-linked list of chunks in which some items have been allocated,
|
||||
/** Doubly-linked list of chunks in which some items have been allocated,
|
||||
* but which are not yet full. The front of the list is the chunk that has
|
||||
* most recently been modified. */
|
||||
struct mp_chunk_t *used_chunks;
|
||||
struct mp_chunk_t *used_chunks;
|
||||
|
||||
/** Doubly-linked list of chunks in which no more items can be allocated.
|
||||
/** Doubly-linked list of chunks in which no more items can be allocated.
|
||||
* The front of the list is the chunk that has most recently become full. */
|
||||
struct mp_chunk_t *full_chunks;
|
||||
struct mp_chunk_t *full_chunks;
|
||||
|
||||
/** Length of <b>empty_chunks</b>. */
|
||||
int n_empty_chunks;
|
||||
/** Length of <b>empty_chunks</b>. */
|
||||
int n_empty_chunks;
|
||||
|
||||
/** Lowest value of <b>empty_chunks</b> since last call to
|
||||
/** Lowest value of <b>empty_chunks</b> since last call to
|
||||
* mp_pool_clean(-1). */
|
||||
int min_empty_chunks;
|
||||
int min_empty_chunks;
|
||||
|
||||
/** Size of each chunk (in items). */
|
||||
int new_chunk_capacity;
|
||||
/** Size of each chunk (in items). */
|
||||
int new_chunk_capacity;
|
||||
|
||||
/** Size to allocate for each item, including overhead and alignment
|
||||
/** Size to allocate for each item, including overhead and alignment
|
||||
* padding. */
|
||||
size_t item_alloc_size;
|
||||
size_t item_alloc_size;
|
||||
#ifdef MEMPOOL_STATS
|
||||
/** Total number of items allocated ever. */
|
||||
uint64_t total_items_allocated;
|
||||
/** Total number of items allocated ever. */
|
||||
uint64_t total_items_allocated;
|
||||
|
||||
/** Total number of chunks allocated ever. */
|
||||
uint64_t total_chunks_allocated;
|
||||
/** Total number of chunks allocated ever. */
|
||||
uint64_t total_chunks_allocated;
|
||||
|
||||
/** Total number of chunks freed ever. */
|
||||
uint64_t total_chunks_freed;
|
||||
/** Total number of chunks freed ever. */
|
||||
uint64_t total_chunks_freed;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
+18
-18
@@ -39,29 +39,29 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
/** Status/error codes returned by mmdb functions */
|
||||
typedef enum {
|
||||
MMDB_OK = 0, /**< Success */
|
||||
MMDB_ERR_OPEN, /**< Could not open or mmap the file */
|
||||
MMDB_ERR_INVALID_DB, /**< Not a valid MMDB file */
|
||||
MMDB_ERR_CORRUPT, /**< Search tree or data section corruption */
|
||||
MMDB_ERR_NODATA, /**< IP found but requested path doesn't exist */
|
||||
MMDB_ERR_TYPE, /**< Type mismatch (asked for string, got uint, etc) */
|
||||
MMDB_ERR_IPV6_IN_V4, /**< Tried to look up an IPv6 address in an IPv4-only db */
|
||||
MMDB_ERR_BADARG, /**< Invalid argument (e.g. unparseable IP address) */
|
||||
MMDB_OK = 0, /**< Success */
|
||||
MMDB_ERR_OPEN, /**< Could not open or mmap the file */
|
||||
MMDB_ERR_INVALID_DB, /**< Not a valid MMDB file */
|
||||
MMDB_ERR_CORRUPT, /**< Search tree or data section corruption */
|
||||
MMDB_ERR_NODATA, /**< IP found but requested path doesn't exist */
|
||||
MMDB_ERR_TYPE, /**< Type mismatch (asked for string, got uint, etc) */
|
||||
MMDB_ERR_IPV6_IN_V4, /**< Tried to look up an IPv6 address in an IPv4-only db */
|
||||
MMDB_ERR_BADARG, /**< Invalid argument (e.g. unparseable IP address) */
|
||||
} MMDB_Status;
|
||||
|
||||
/** Database metadata */
|
||||
typedef struct {
|
||||
uint32_t node_count; /**< Number of nodes in the search tree */
|
||||
uint16_t record_size; /**< Size of each record in bits */
|
||||
uint16_t ip_version; /**< IP version the database covers (4 or 6) */
|
||||
uint64_t build_epoch; /**< Unix timestamp when the database was built */
|
||||
char database_type[128]; /**< Database type string (e.g. "GeoLite2-Country") */
|
||||
uint32_t node_count; /**< Number of nodes in the search tree */
|
||||
uint16_t record_size; /**< Size of each record in bits */
|
||||
uint16_t ip_version; /**< IP version the database covers (4 or 6) */
|
||||
uint64_t build_epoch; /**< Unix timestamp when the database was built */
|
||||
char database_type[128]; /**< Database type string (e.g. "GeoLite2-Country") */
|
||||
} MMDB_Metadata;
|
||||
|
||||
/** Database handle */
|
||||
@@ -78,9 +78,9 @@ typedef struct {
|
||||
|
||||
/** Lookup result */
|
||||
typedef struct {
|
||||
MMDB_DB *db; /**< Database this result belongs to */
|
||||
size_t offset; /**< Offset into data section, or 0 if not found */
|
||||
int has_data; /**< 1 if IP was found and has data */
|
||||
MMDB_DB *db; /**< Database this result belongs to */
|
||||
size_t offset; /**< Offset into data section, or 0 if not found */
|
||||
int has_data; /**< 1 if IP was found and has data */
|
||||
} MMDB_Result;
|
||||
|
||||
/** Open an MMDB database file.
|
||||
|
||||
+579
-573
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#ifdef UNREALCORE
|
||||
char our_mod_version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||
char our_mod_version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||
#else
|
||||
DLLFUNC char Mod_Version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||
DLLFUNC char Mod_Version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||
#endif
|
||||
|
||||
+137
-137
@@ -21,145 +21,145 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __msg_include__
|
||||
#ifndef __msg_include__
|
||||
#define __msg_include__
|
||||
|
||||
#define MSG_PRIVATE "PRIVMSG" /* PRIV */
|
||||
#define MSG_WHOIS "WHOIS" /* WHOI */
|
||||
#define MSG_WHOWAS "WHOWAS" /* WHOW */
|
||||
#define MSG_USER "USER" /* USER */
|
||||
#define MSG_NICK "NICK" /* NICK */
|
||||
#define MSG_SERVER "SERVER" /* SERV */
|
||||
#define MSG_LIST "LIST" /* LIST */
|
||||
#define MSG_TOPIC "TOPIC" /* TOPI */
|
||||
#define MSG_INVITE "INVITE" /* INVI */
|
||||
#define MSG_VERSION "VERSION" /* VERS */
|
||||
#define MSG_QUIT "QUIT" /* QUIT */
|
||||
#define MSG_SQUIT "SQUIT" /* SQUI */
|
||||
#define MSG_KILL "KILL" /* KILL */
|
||||
#define MSG_INFO "INFO" /* INFO */
|
||||
#define MSG_LINKS "LINKS" /* LINK */
|
||||
#define MSG_SUMMON "SUMMON" /* SUMM */
|
||||
#define MSG_STATS "STATS" /* STAT */
|
||||
#define MSG_USERS "USERS" /* USER -> USRS */
|
||||
#define MSG_HELP "HELP" /* HELP */
|
||||
#define MSG_HELPOP "HELPOP" /* HELP */
|
||||
#define MSG_ERROR "ERROR" /* ERRO */
|
||||
#define MSG_AWAY "AWAY" /* AWAY */
|
||||
#define MSG_CONNECT "CONNECT" /* CONN */
|
||||
#define MSG_PING "PING" /* PING */
|
||||
#define MSG_PONG "PONG" /* PONG */
|
||||
#define MSG_OPER "OPER" /* OPER */
|
||||
#define MSG_PASS "PASS" /* PASS */
|
||||
#define MSG_TIME "TIME" /* TIME */
|
||||
#define MSG_NAMES "NAMES" /* NAME */
|
||||
#define MSG_ADMIN "ADMIN" /* ADMI */
|
||||
#define MSG_NOTICE "NOTICE" /* NOTI */
|
||||
#define MSG_JOIN "JOIN" /* JOIN */
|
||||
#define MSG_PART "PART" /* PART */
|
||||
#define MSG_LUSERS "LUSERS" /* LUSE */
|
||||
#define MSG_MOTD "MOTD" /* MOTD */
|
||||
#define MSG_MODE "MODE" /* MODE */
|
||||
#define MSG_KICK "KICK" /* KICK */
|
||||
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
|
||||
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
|
||||
#define MSG_ISON "ISON" /* ISON */
|
||||
#define MSG_REHASH "REHASH" /* REHA */
|
||||
#define MSG_RESTART "RESTART" /* REST */
|
||||
#define MSG_CLOSE "CLOSE" /* CLOS */
|
||||
#define MSG_DIE "DIE" /* DIE */
|
||||
#define MSG_HASH "HASH" /* HASH */
|
||||
#define MSG_DNS "DNS" /* DNS -> DNSS */
|
||||
#define MSG_SILENCE "SILENCE" /* SILE */
|
||||
#define MSG_AKILL "AKILL" /* AKILL */
|
||||
#define MSG_KLINE "KLINE" /* KLINE */
|
||||
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
|
||||
#define MSG_RAKILL "RAKILL" /* RAKILL */
|
||||
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
|
||||
#define MSG_GOPER "GOPER" /* GOPER */
|
||||
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
|
||||
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
|
||||
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
|
||||
#define MSG_WATCH "WATCH" /* WATCH */
|
||||
#define MSG_TRACE "TRACE" /* TRAC */
|
||||
#define MSG_SQLINE "SQLINE" /* SQLINE */
|
||||
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
|
||||
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
|
||||
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
|
||||
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
|
||||
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */
|
||||
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */
|
||||
#define MSG_NS "NS"
|
||||
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */
|
||||
#define MSG_CS "CS"
|
||||
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */
|
||||
#define MSG_OS "OS"
|
||||
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
|
||||
#define MSG_MS "MS"
|
||||
#define MSG_SERVICES "SERVICES" /* SERVICES */
|
||||
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
|
||||
#define MSG_SAMODE "SAMODE" /* SAMODE */
|
||||
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
|
||||
#define MSG_ZLINE "ZLINE" /* ZLINE */
|
||||
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
|
||||
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
|
||||
#define MSG_HS "HS"
|
||||
#define MSG_RULES "RULES" /* RULES */
|
||||
#define MSG_MAP "MAP" /* MAP */
|
||||
#define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */
|
||||
#define MSG_DALINFO "DALINFO" /* dalinfo */
|
||||
#define MSG_ADMINCHAT "ADCHAT" /* Admin chat */
|
||||
#define MSG_MKPASSWD "MKPASSWD" /* MKPASSWD */
|
||||
#define MSG_ADDLINE "ADDLINE" /* ADDLINE */
|
||||
#define MSG_GLINE "GLINE" /* The awesome g-line */
|
||||
#define MSG_SJOIN "SJOIN"
|
||||
#define MSG_SETHOST "SETHOST" /* sethost */
|
||||
#define MSG_NACHAT "NACHAT" /* netadmin chat */
|
||||
#define MSG_SETIDENT "SETIDENT"
|
||||
#define MSG_SETNAME "SETNAME" /* set GECOS */
|
||||
#define MSG_LAG "LAG" /* Lag detect */
|
||||
#define MSG_STATSERV "STATSERV" /* alias */
|
||||
#define MSG_KNOCK "KNOCK"
|
||||
#define MSG_CREDITS "CREDITS"
|
||||
#define MSG_LICENSE "LICENSE"
|
||||
#define MSG_CHGHOST "CHGHOST"
|
||||
#define MSG_NETINFO "NETINFO"
|
||||
#define MSG_SENDUMODE "SENDUMODE"
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
#define MSG_SVSMOTD "SVSMOTD"
|
||||
#define MSG_SMO "SMO"
|
||||
#define MSG_OPERMOTD "OPERMOTD"
|
||||
#define MSG_TSCTL "TSCTL"
|
||||
#define MSG_SVSJOIN "SVSJOIN"
|
||||
#define MSG_SAJOIN "SAJOIN"
|
||||
#define MSG_SVSPART "SVSPART"
|
||||
#define MSG_SAPART "SAPART"
|
||||
#define MSG_CHGIDENT "CHGIDENT"
|
||||
#define MSG_SWHOIS "SWHOIS"
|
||||
#define MSG_SVSO "SVSO"
|
||||
#define MSG_SVSFLINE "SVSFLINE"
|
||||
#define MSG_TKL "TKL"
|
||||
#define MSG_VHOST "VHOST"
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
#define MSG_REMGLINE "REMGLINE" /* remove g-line */
|
||||
#define MSG_UMODE2 "UMODE2"
|
||||
#define MSG_DCCDENY "DCCDENY"
|
||||
#define MSG_UNDCCDENY "UNDCCDENY"
|
||||
#define MSG_CHGNAME "CHGNAME"
|
||||
#define MSG_SHUN "SHUN"
|
||||
#define MSG_NEWJOIN "NEWJOIN" /* For CR Java Chat */
|
||||
#define MSG_POST "POST"
|
||||
#define MSG_INFOSERV "INFOSERV"
|
||||
#define MSG_IS "IS"
|
||||
#define MSG_BOTSERV "BOTSERV"
|
||||
#define MSG_CYCLE "CYCLE"
|
||||
#define MSG_MODULE "MODULE"
|
||||
#define MSG_SENDSNO "SENDSNO"
|
||||
#define MSG_EOS "EOS"
|
||||
#define MSG_MLOCK "MLOCK"
|
||||
#define MSG_PRIVATE "PRIVMSG" /* PRIV */
|
||||
#define MSG_WHOIS "WHOIS" /* WHOI */
|
||||
#define MSG_WHOWAS "WHOWAS" /* WHOW */
|
||||
#define MSG_USER "USER" /* USER */
|
||||
#define MSG_NICK "NICK" /* NICK */
|
||||
#define MSG_SERVER "SERVER" /* SERV */
|
||||
#define MSG_LIST "LIST" /* LIST */
|
||||
#define MSG_TOPIC "TOPIC" /* TOPI */
|
||||
#define MSG_INVITE "INVITE" /* INVI */
|
||||
#define MSG_VERSION "VERSION" /* VERS */
|
||||
#define MSG_QUIT "QUIT" /* QUIT */
|
||||
#define MSG_SQUIT "SQUIT" /* SQUI */
|
||||
#define MSG_KILL "KILL" /* KILL */
|
||||
#define MSG_INFO "INFO" /* INFO */
|
||||
#define MSG_LINKS "LINKS" /* LINK */
|
||||
#define MSG_SUMMON "SUMMON" /* SUMM */
|
||||
#define MSG_STATS "STATS" /* STAT */
|
||||
#define MSG_USERS "USERS" /* USER -> USRS */
|
||||
#define MSG_HELP "HELP" /* HELP */
|
||||
#define MSG_HELPOP "HELPOP" /* HELP */
|
||||
#define MSG_ERROR "ERROR" /* ERRO */
|
||||
#define MSG_AWAY "AWAY" /* AWAY */
|
||||
#define MSG_CONNECT "CONNECT" /* CONN */
|
||||
#define MSG_PING "PING" /* PING */
|
||||
#define MSG_PONG "PONG" /* PONG */
|
||||
#define MSG_OPER "OPER" /* OPER */
|
||||
#define MSG_PASS "PASS" /* PASS */
|
||||
#define MSG_TIME "TIME" /* TIME */
|
||||
#define MSG_NAMES "NAMES" /* NAME */
|
||||
#define MSG_ADMIN "ADMIN" /* ADMI */
|
||||
#define MSG_NOTICE "NOTICE" /* NOTI */
|
||||
#define MSG_JOIN "JOIN" /* JOIN */
|
||||
#define MSG_PART "PART" /* PART */
|
||||
#define MSG_LUSERS "LUSERS" /* LUSE */
|
||||
#define MSG_MOTD "MOTD" /* MOTD */
|
||||
#define MSG_MODE "MODE" /* MODE */
|
||||
#define MSG_KICK "KICK" /* KICK */
|
||||
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
|
||||
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
|
||||
#define MSG_ISON "ISON" /* ISON */
|
||||
#define MSG_REHASH "REHASH" /* REHA */
|
||||
#define MSG_RESTART "RESTART" /* REST */
|
||||
#define MSG_CLOSE "CLOSE" /* CLOS */
|
||||
#define MSG_DIE "DIE" /* DIE */
|
||||
#define MSG_HASH "HASH" /* HASH */
|
||||
#define MSG_DNS "DNS" /* DNS -> DNSS */
|
||||
#define MSG_SILENCE "SILENCE" /* SILE */
|
||||
#define MSG_AKILL "AKILL" /* AKILL */
|
||||
#define MSG_KLINE "KLINE" /* KLINE */
|
||||
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
|
||||
#define MSG_RAKILL "RAKILL" /* RAKILL */
|
||||
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
|
||||
#define MSG_GOPER "GOPER" /* GOPER */
|
||||
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
|
||||
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
|
||||
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
|
||||
#define MSG_WATCH "WATCH" /* WATCH */
|
||||
#define MSG_TRACE "TRACE" /* TRAC */
|
||||
#define MSG_SQLINE "SQLINE" /* SQLINE */
|
||||
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
|
||||
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
|
||||
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
|
||||
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
|
||||
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */
|
||||
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */
|
||||
#define MSG_NS "NS"
|
||||
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */
|
||||
#define MSG_CS "CS"
|
||||
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */
|
||||
#define MSG_OS "OS"
|
||||
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
|
||||
#define MSG_MS "MS"
|
||||
#define MSG_SERVICES "SERVICES" /* SERVICES */
|
||||
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
|
||||
#define MSG_SAMODE "SAMODE" /* SAMODE */
|
||||
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
|
||||
#define MSG_ZLINE "ZLINE" /* ZLINE */
|
||||
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
|
||||
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
|
||||
#define MSG_HS "HS"
|
||||
#define MSG_RULES "RULES" /* RULES */
|
||||
#define MSG_MAP "MAP" /* MAP */
|
||||
#define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */
|
||||
#define MSG_DALINFO "DALINFO" /* dalinfo */
|
||||
#define MSG_ADMINCHAT "ADCHAT" /* Admin chat */
|
||||
#define MSG_MKPASSWD "MKPASSWD" /* MKPASSWD */
|
||||
#define MSG_ADDLINE "ADDLINE" /* ADDLINE */
|
||||
#define MSG_GLINE "GLINE" /* The awesome g-line */
|
||||
#define MSG_SJOIN "SJOIN"
|
||||
#define MSG_SETHOST "SETHOST" /* sethost */
|
||||
#define MSG_NACHAT "NACHAT" /* netadmin chat */
|
||||
#define MSG_SETIDENT "SETIDENT"
|
||||
#define MSG_SETNAME "SETNAME" /* set GECOS */
|
||||
#define MSG_LAG "LAG" /* Lag detect */
|
||||
#define MSG_STATSERV "STATSERV" /* alias */
|
||||
#define MSG_KNOCK "KNOCK"
|
||||
#define MSG_CREDITS "CREDITS"
|
||||
#define MSG_LICENSE "LICENSE"
|
||||
#define MSG_CHGHOST "CHGHOST"
|
||||
#define MSG_NETINFO "NETINFO"
|
||||
#define MSG_SENDUMODE "SENDUMODE"
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
#define MSG_SVSMOTD "SVSMOTD"
|
||||
#define MSG_SMO "SMO"
|
||||
#define MSG_OPERMOTD "OPERMOTD"
|
||||
#define MSG_TSCTL "TSCTL"
|
||||
#define MSG_SVSJOIN "SVSJOIN"
|
||||
#define MSG_SAJOIN "SAJOIN"
|
||||
#define MSG_SVSPART "SVSPART"
|
||||
#define MSG_SAPART "SAPART"
|
||||
#define MSG_CHGIDENT "CHGIDENT"
|
||||
#define MSG_SWHOIS "SWHOIS"
|
||||
#define MSG_SVSO "SVSO"
|
||||
#define MSG_SVSFLINE "SVSFLINE"
|
||||
#define MSG_TKL "TKL"
|
||||
#define MSG_VHOST "VHOST"
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
#define MSG_REMGLINE "REMGLINE" /* remove g-line */
|
||||
#define MSG_UMODE2 "UMODE2"
|
||||
#define MSG_DCCDENY "DCCDENY"
|
||||
#define MSG_UNDCCDENY "UNDCCDENY"
|
||||
#define MSG_CHGNAME "CHGNAME"
|
||||
#define MSG_SHUN "SHUN"
|
||||
#define MSG_NEWJOIN "NEWJOIN" /* For CR Java Chat */
|
||||
#define MSG_POST "POST"
|
||||
#define MSG_INFOSERV "INFOSERV"
|
||||
#define MSG_IS "IS"
|
||||
#define MSG_BOTSERV "BOTSERV"
|
||||
#define MSG_CYCLE "CYCLE"
|
||||
#define MSG_MODULE "MODULE"
|
||||
#define MSG_SENDSNO "SENDSNO"
|
||||
#define MSG_EOS "EOS"
|
||||
#define MSG_MLOCK "MLOCK"
|
||||
|
||||
#define MAXPARA 30
|
||||
#define MAXPARA_USER 15
|
||||
#define MAXPARA 30
|
||||
#define MAXPARA_USER 15
|
||||
|
||||
#endif
|
||||
|
||||
+229
-229
@@ -350,232 +350,232 @@
|
||||
|
||||
/* Numeric texts */
|
||||
|
||||
#define STR_RPL_WELCOME /* 001 */ ":Welcome to the %s IRC Network %s!%s@%s"
|
||||
#define STR_RPL_YOURHOST /* 002 */ ":Your host is %s, running version %s"
|
||||
#define STR_RPL_CREATED /* 003 */ ":This server was created %s"
|
||||
#define STR_RPL_MYINFO /* 004 */ "%s %s %s %s"
|
||||
#define STR_RPL_ISUPPORT /* 005 */ "%s :are supported by this server"
|
||||
#define STR_RPL_MAP /* 006 */ ":%s%s %s | Users: %*ld (%*.2f%%)%s"
|
||||
#define STR_RPL_MAPEND /* 007 */ ":End of /MAP"
|
||||
#define STR_RPL_SNOMASK /* 008 */ "+%s :Server notice mask"
|
||||
#define STR_RPL_REDIR /* 010 */ "%s %d :Please use this Server/Port instead"
|
||||
#define STR_RPL_MAPUSERS /* 018 */ ":%d server%s and %d user%s, average %.2f users per server"
|
||||
#define STR_RPL_REMOTEISUPPORT /* 105 */ "%s :are supported by this server"
|
||||
#define STR_RPL_TRACELINK /* 200 */ "Link %s%s %s %s"
|
||||
#define STR_RPL_TRACECONNECTING /* 201 */ "Attempt %s %s"
|
||||
#define STR_RPL_TRACEHANDSHAKE /* 202 */ "Handshaking %s %s"
|
||||
#define STR_RPL_TRACEUNKNOWN /* 203 */ "???? %s %s"
|
||||
#define STR_RPL_TRACEOPERATOR /* 204 */ "Operator %s %s [%s] %lld"
|
||||
#define STR_RPL_TRACEUSER /* 205 */ "User %s %s [%s] %lld"
|
||||
#define STR_RPL_TRACESERVER /* 206 */ "Server %s %dS %dC %s %s!%s@%s %lld"
|
||||
#define STR_RPL_TRACENEWTYPE /* 208 */ "%s 0 %s"
|
||||
#define STR_RPL_TRACECLASS /* 209 */ "Class %s %d"
|
||||
#define STR_RPL_STATSHELP /* 210 */ ":%s"
|
||||
#define STR_RPL_STATSCOMMANDS /* 212 */ "%s %u %lu"
|
||||
#define STR_RPL_STATSCLINE /* 213 */ "%c %s * %s %d %d %s"
|
||||
#define STR_RPL_STATSILINE /* 215 */ "I %s %s %d %d %s %s %d"
|
||||
#define STR_RPL_STATSQLINE /* 217 */ "%c %s %lld %lld %s %lld %lld %s :%s"
|
||||
#define STR_RPL_STATSYLINE /* 218 */ "Y %s %d %d %d %d %d"
|
||||
#define STR_RPL_ENDOFSTATS /* 219 */ "%c :End of /STATS report"
|
||||
#define STR_RPL_UMODEIS /* 221 */ "%s"
|
||||
#define STR_RPL_STATSGLINE /* 223 */ "%c %s %lld %lld %s %lld %lld %s %s :%s"
|
||||
#define STR_RPL_STATSTLINE /* 224 */ "T %s %s %s"
|
||||
#define STR_RPL_STATSNLINE /* 226 */ "n %s %s"
|
||||
#define STR_RPL_STATSVLINE /* 227 */ "v %s %s %s"
|
||||
#define STR_RPL_STATSBANVER /* 228 */ "%s %s"
|
||||
#define STR_RPL_STATSSPAMF /* 229 */ "%c %s %s %s %lld %lld %lld %s %s %lld %lld %lld %lld %s :%s"
|
||||
#define STR_RPL_STATSEXCEPTTKL /* 230 */ "%s %s %lld %lld %s %s :%s"
|
||||
#define STR_RPL_RULES /* 232 */ ":- %s"
|
||||
#define STR_RPL_STATSLLINE /* 241 */ "%c %s * %s %d %d"
|
||||
#define STR_RPL_STATSUPTIME /* 242 */ ":Server Up %lld days, %lld:%02lld:%02lld"
|
||||
#define STR_RPL_STATSOLINE /* 243 */ "%c %s * %s %s %s"
|
||||
#define STR_RPL_STATSHLINE /* 244 */ "%c %s * %s %d %d"
|
||||
#define STR_RPL_STATSXLINE /* 247 */ "X %s %d"
|
||||
#define STR_RPL_STATSULINE /* 248 */ "U %s"
|
||||
#define STR_RPL_STATSDEBUG /* 249 */ ":%s"
|
||||
#define STR_RPL_STATSCONN /* 250 */ ":Highest connection count: %d (%d clients)"
|
||||
#define STR_RPL_LUSERCLIENT /* 251 */ ":There are %d users and %d invisible on %d servers"
|
||||
#define STR_RPL_LUSEROP /* 252 */ "%d :operator(s) online"
|
||||
#define STR_RPL_LUSERUNKNOWN /* 253 */ "%d :unknown connection(s)"
|
||||
#define STR_RPL_LUSERCHANNELS /* 254 */ "%d :channels formed"
|
||||
#define STR_RPL_LUSERME /* 255 */ ":I have %d clients and %d servers"
|
||||
#define STR_RPL_ADMINME /* 256 */ ":Administrative info about %s"
|
||||
#define STR_RPL_ADMINLOC1 /* 257 */ ":%s"
|
||||
#define STR_RPL_ADMINLOC2 /* 258 */ ":%s"
|
||||
#define STR_RPL_ADMINEMAIL /* 259 */ ":%s"
|
||||
#define STR_RPL_TRACELOG /* 261 */ "File %s %d"
|
||||
#define STR_RPL_TRYAGAIN /* 263 */ "%s :Flooding detected. Please wait a while and try again."
|
||||
#define STR_RPL_LOCALUSERS /* 265 */ "%d %d :Current local users %d, max %d"
|
||||
#define STR_RPL_GLOBALUSERS /* 266 */ "%d %d :Current global users %d, max %d"
|
||||
#define STR_RPL_SILELIST /* 271 */ "%s"
|
||||
#define STR_RPL_ENDOFSILELIST /* 272 */ ":End of Silence List"
|
||||
#define STR_RPL_STATSDLINE /* 275 */ "%c %s %s"
|
||||
#define STR_RPL_WHOISCERTFP /* 276 */ "%s :has client certificate fingerprint %s"
|
||||
#define STR_RPL_AWAY /* 301 */ "%s :%s"
|
||||
#define STR_RPL_USERHOST /* 302 */ ":%s %s %s %s %s"
|
||||
#define STR_RPL_ISON /* 303 */ ":"
|
||||
#define STR_RPL_UNAWAY /* 305 */ ":You are no longer marked as being away"
|
||||
#define STR_RPL_NOWAWAY /* 306 */ ":You have been marked as being away"
|
||||
#define STR_RPL_WHOISREGNICK /* 307 */ "%s :is identified for this nick"
|
||||
#define STR_RPL_RULESSTART /* 308 */ ":- %s Server Rules - "
|
||||
#define STR_RPL_ENDOFRULES /* 309 */ ":End of RULES command."
|
||||
#define STR_RPL_WHOISUSER /* 311 */ "%s %s %s * :%s"
|
||||
#define STR_RPL_WHOISSERVER /* 312 */ "%s %s :%s"
|
||||
#define STR_RPL_WHOISOPERATOR /* 313 */ "%s :is %s"
|
||||
#define STR_RPL_WHOWASUSER /* 314 */ "%s %s %s * :%s"
|
||||
#define STR_RPL_ENDOFWHO /* 315 */ "%s :End of /WHO list."
|
||||
#define STR_RPL_WHOISIDLE /* 317 */ "%s %lld %lld :seconds idle, signon time"
|
||||
#define STR_RPL_ENDOFWHOIS /* 318 */ "%s :End of /WHOIS list."
|
||||
#define STR_RPL_WHOISCHANNELS /* 319 */ "%s :%s"
|
||||
#define STR_RPL_WHOISSPECIAL /* 320 */ "%s :%s"
|
||||
#define STR_RPL_LISTSTART /* 321 */ "Channel :Users Name"
|
||||
#define STR_RPL_LIST /* 322 */ "%s %d :%s %s"
|
||||
#define STR_RPL_LISTEND /* 323 */ ":End of /LIST"
|
||||
#define STR_RPL_CHANNELMODEIS /* 324 */ "%s %s %s"
|
||||
#define STR_RPL_CREATIONTIME /* 329 */ "%s %lld"
|
||||
#define STR_RPL_WHOISLOGGEDIN /* 330 */ "%s %s :is logged in as"
|
||||
#define STR_RPL_NOTOPIC /* 331 */ "%s :No topic is set."
|
||||
#define STR_RPL_TOPIC /* 332 */ "%s :%s"
|
||||
#define STR_RPL_TOPICWHOTIME /* 333 */ "%s %s %lld"
|
||||
#define STR_RPL_LISTSYNTAX /* 334 */ ":%s"
|
||||
#define STR_RPL_WHOISBOT /* 335 */ "%s :is a \2Bot\2 on %s"
|
||||
#define STR_RPL_INVITELIST /* 336 */ ":%s"
|
||||
#define STR_RPL_ENDOFINVITELIST /* 337 */ ":End of /INVITE list."
|
||||
#define STR_RPL_USERIP /* 340 */ ":%s %s %s %s %s"
|
||||
#define STR_RPL_INVITING /* 341 */ "%s %s"
|
||||
#define STR_RPL_WHOISCOUNTRY /* 344 */ "%s %s :is connecting from %s"
|
||||
#define STR_RPL_INVEXLIST /* 346 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFINVEXLIST /* 347 */ "%s :End of Channel Invite List"
|
||||
#define STR_RPL_EXLIST /* 348 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFEXLIST /* 349 */ "%s :End of Channel Exception List"
|
||||
#define STR_RPL_VERSION /* 351 */ "%s.%s %s :%s%s%s [%s=%d]"
|
||||
#define STR_RPL_WHOREPLY /* 352 */ "%s %s %s %s %s %s :%d %s"
|
||||
#define STR_RPL_NAMREPLY /* 353 */ "%s"
|
||||
#define STR_RPL_CLOSING /* 362 */ "%s :Closed. Status = %d"
|
||||
#define STR_RPL_CLOSEEND /* 363 */ "%d: Connections Closed"
|
||||
#define STR_RPL_LINKS /* 364 */ "%s %s :%d %s"
|
||||
#define STR_RPL_ENDOFLINKS /* 365 */ "%s :End of /LINKS list."
|
||||
#define STR_RPL_ENDOFNAMES /* 366 */ "%s :End of /NAMES list."
|
||||
#define STR_RPL_BANLIST /* 367 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFBANLIST /* 368 */ "%s :End of Channel Ban List"
|
||||
#define STR_RPL_ENDOFWHOWAS /* 369 */ "%s :End of WHOWAS"
|
||||
#define STR_RPL_INFO /* 371 */ ":%s"
|
||||
#define STR_RPL_MOTD /* 372 */ ":- %s"
|
||||
#define STR_RPL_ENDOFINFO /* 374 */ ":End of /INFO list."
|
||||
#define STR_RPL_MOTDSTART /* 375 */ ":- %s Message of the Day - "
|
||||
#define STR_RPL_ENDOFMOTD /* 376 */ ":End of /MOTD command."
|
||||
#define STR_RPL_WHOISHOST /* 378 */ "%s :is connecting from %s@%s %s"
|
||||
#define STR_RPL_WHOISMODES /* 379 */ "%s :is using modes %s %s"
|
||||
#define STR_RPL_YOUREOPER /* 381 */ ":You are now an IRC Operator"
|
||||
#define STR_RPL_REHASHING /* 382 */ "%s :Rehashing"
|
||||
#define STR_RPL_QLIST /* 386 */ "%s %s"
|
||||
#define STR_RPL_ENDOFQLIST /* 387 */ "%s :End of Channel Owner List"
|
||||
#define STR_RPL_ALIST /* 388 */ "%s %s"
|
||||
#define STR_RPL_ENDOFALIST /* 389 */ "%s :End of Protected User List"
|
||||
#define STR_RPL_TIME /* 391 */ "%s :%s"
|
||||
#define STR_RPL_HOSTHIDDEN /* 396 */ "%s :is now your displayed host"
|
||||
#define STR_ERR_NOSUCHNICK /* 401 */ "%s :No such nick/channel"
|
||||
#define STR_ERR_NOSUCHSERVER /* 402 */ "%s :No such server"
|
||||
#define STR_ERR_NOSUCHCHANNEL /* 403 */ "%s :No such channel"
|
||||
#define STR_ERR_CANNOTSENDTOCHAN /* 404 */ "%s :%s (%s)"
|
||||
#define STR_ERR_TOOMANYCHANNELS /* 405 */ "%s :You have joined too many channels"
|
||||
#define STR_ERR_WASNOSUCHNICK /* 406 */ "%s :There was no such nickname"
|
||||
#define STR_ERR_TOOMANYTARGETS /* 407 */ "%s :Too many targets. The maximum is %d for %s."
|
||||
#define STR_ERR_NOORIGIN /* 409 */ ":No origin specified"
|
||||
#define STR_ERR_INVALIDCAPCMD /* 410 */ "%s :Invalid CAP subcommand"
|
||||
#define STR_ERR_NORECIPIENT /* 411 */ ":No recipient given (%s)"
|
||||
#define STR_ERR_NOTEXTTOSEND /* 412 */ ":No text to send"
|
||||
#define STR_ERR_TOOMANYMATCHES /* 416 */ "%s :%s"
|
||||
#define STR_ERR_INPUTTOOLONG /* 417 */ ":Input line was too long"
|
||||
#define STR_ERR_UNKNOWNCOMMAND /* 421 */ "%s :Unknown command"
|
||||
#define STR_ERR_NOMOTD /* 422 */ ":MOTD File is missing"
|
||||
#define STR_ERR_NOADMININFO /* 423 */ "%s :No administrative info available"
|
||||
#define STR_ERR_NOOPERMOTD /* 425 */ ":OPERMOTD File is missing"
|
||||
#define STR_ERR_TOOMANYAWAY /* 429 */ ":Too Many aways - Flood Protection activated"
|
||||
#define STR_ERR_NONICKNAMEGIVEN /* 431 */ ":No nickname given"
|
||||
#define STR_ERR_ERRONEUSNICKNAME /* 432 */ "%s :Nickname is unavailable: %s"
|
||||
#define STR_ERR_NICKNAMEINUSE /* 433 */ "%s :Nickname is already in use."
|
||||
#define STR_ERR_NORULES /* 434 */ ":RULES File is missing"
|
||||
#define STR_ERR_BANNICKCHANGE /* 437 */ "%s :Cannot change nickname while banned on channel"
|
||||
#define STR_ERR_NCHANGETOOFAST /* 438 */ "%s :Nick change too fast. Please try again later."
|
||||
#define STR_ERR_TARGETTOOFAST /* 439 */ "%s :Message target change too fast. Please wait %lld seconds"
|
||||
#define STR_ERR_SERVICESDOWN /* 440 */ "%s :Services are currently down. Please try again later."
|
||||
#define STR_ERR_USERNOTINCHANNEL /* 441 */ "%s %s :They aren't on that channel"
|
||||
#define STR_ERR_NOTONCHANNEL /* 442 */ "%s :You're not on that channel"
|
||||
#define STR_ERR_USERONCHANNEL /* 443 */ "%s %s :is already on channel"
|
||||
#define STR_ERR_NONICKCHANGE /* 447 */ ":Can not change nickname while on %s (+N)"
|
||||
#define STR_ERR_FORBIDDENCHANNEL /* 448 */ "%s :Cannot join channel: %s"
|
||||
#define STR_ERR_NOTREGISTERED /* 451 */ ":You have not registered"
|
||||
#define STR_ERR_NOTFORHALFOPS /* 460 */ ":Halfops cannot set mode %c"
|
||||
#define STR_ERR_NEEDMOREPARAMS /* 461 */ "%s :Not enough parameters"
|
||||
#define STR_ERR_ALREADYREGISTRED /* 462 */ ":You may not reregister"
|
||||
#define STR_ERR_PASSWDMISMATCH /* 464 */ ":Password Incorrect"
|
||||
#define STR_ERR_YOUREBANNEDCREEP /* 465 */ ":%s"
|
||||
#define STR_ERR_ONLYSERVERSCANCHANGE /* 468 */ "%s :Only servers can change that mode"
|
||||
#define STR_ERR_LINKCHANNEL /* 470 */ "%s %s :[Link] %s has become full, so you are automatically being transferred to the linked channel %s"
|
||||
#define STR_ERR_CHANNELISFULL /* 471 */ "%s :Cannot join channel (+l)"
|
||||
#define STR_ERR_UNKNOWNMODE /* 472 */ "%c :is unknown mode char to me"
|
||||
#define STR_ERR_INVITEONLYCHAN /* 473 */ "%s :Cannot join channel (+i)"
|
||||
#define STR_ERR_BANNEDFROMCHAN /* 474 */ "%s :Cannot join channel (+b)"
|
||||
#define STR_ERR_BADCHANNELKEY /* 475 */ "%s :Cannot join channel (+k)"
|
||||
#define STR_ERR_NEEDREGGEDNICK /* 477 */ "%s :You need a registered nick to join that channel."
|
||||
#define STR_ERR_BANLISTFULL /* 478 */ "%s %s :Channel ban/ignore list is full"
|
||||
#define STR_ERR_CANNOTKNOCK /* 480 */ ":Cannot knock on %s (%s)"
|
||||
#define STR_ERR_NOPRIVILEGES /* 481 */ ":Permission Denied- You do not have the correct IRC operator privileges"
|
||||
#define STR_ERR_CHANOPRIVSNEEDED /* 482 */ "%s :You're not channel operator"
|
||||
#define STR_ERR_KILLDENY /* 485 */ ":Cannot kill protected user %s."
|
||||
#define STR_ERR_NOTFORUSERS /* 487 */ ":%s is a server only command"
|
||||
#define STR_ERR_SECUREONLYCHAN /* 489 */ "%s :Cannot join channel (Secure connection is required)"
|
||||
#define STR_ERR_NOOPERHOST /* 491 */ ":No O-lines for your host"
|
||||
#define STR_ERR_CHANOWNPRIVNEEDED /* 499 */ "%s :You're not a channel owner"
|
||||
#define STR_ERR_TOOMANYJOINS /* 500 */ "%s :Too many join requests. Please wait a while and try again."
|
||||
#define STR_ERR_UMODEUNKNOWNFLAG /* 501 */ ":Unknown MODE flag"
|
||||
#define STR_ERR_USERSDONTMATCH /* 502 */ ":Cant change mode for other users"
|
||||
#define STR_ERR_SILELISTFULL /* 511 */ "%s :Your silence list is full"
|
||||
#define STR_ERR_TOOMANYWATCH /* 512 */ "%s :Maximum size for WATCH-list is 128 entries"
|
||||
#define STR_ERR_TOOMANYDCC /* 514 */ "%s :Your dcc allow list is full. Maximum size is %d entries"
|
||||
#define STR_ERR_DISABLED /* 517 */ "%s :%s" /* ircu */
|
||||
#define STR_ERR_NOINVITE /* 518 */ ":Cannot invite (+V) at channel %s"
|
||||
#define STR_ERR_OPERONLY /* 520 */ ":Cannot join channel %s (IRCops only)"
|
||||
#define STR_ERR_LISTSYNTAX /* 521 */ ":Bad list syntax, type /quote list ? or /raw list ?"
|
||||
#define STR_ERR_WHOLIMEXCEED /* 523 */ ":Error, /who limit of %d exceeded. Please narrow your search down and try again"
|
||||
#define STR_ERR_OPERSPVERIFY /* 524 */ "%s :Trying to join +s or +p channel as an oper. Please invite yourself first."
|
||||
#define STR_ERR_CANTSENDTOUSER /* 531 */ "%s :%s"
|
||||
#define STR_RPL_WHOISASN /* 569 */ "%u :%s [%s]"
|
||||
#define STR_RPL_REAWAY /* 597 */ "%s %s %s %lld :%s"
|
||||
#define STR_RPL_GONEAWAY /* 598 */ "%s %s %s %lld :%s"
|
||||
#define STR_RPL_NOTAWAY /* 599 */ "%s %s %s %lld :is no longer away"
|
||||
#define STR_RPL_LOGON /* 600 */ "%s %s %s %lld :logged online"
|
||||
#define STR_RPL_LOGOFF /* 601 */ "%s %s %s %lld :logged offline"
|
||||
#define STR_RPL_WATCHOFF /* 602 */ "%s %s %s %lld :stopped watching"
|
||||
#define STR_RPL_WATCHSTAT /* 603 */ ":You have %d and are on %d WATCH entries"
|
||||
#define STR_RPL_NOWON /* 604 */ "%s %s %s %lld :is online"
|
||||
#define STR_RPL_NOWOFF /* 605 */ "%s %s %s %lld :is offline"
|
||||
#define STR_RPL_WATCHLIST /* 606 */ ":%s"
|
||||
#define STR_RPL_ENDOFWATCHLIST /* 607 */ ":End of WATCH %c"
|
||||
#define STR_RPL_NOWISAWAY /* 609 */ "%s %s %s %lld :is away"
|
||||
#define STR_RPL_MAPMORE /* 610 */ ":%s%-*s --> *more*"
|
||||
#define STR_RPL_DCCSTATUS /* 617 */ ":%s has been %s your DCC allow list"
|
||||
#define STR_RPL_DCCLIST /* 618 */ ":%s"
|
||||
#define STR_RPL_ENDOFDCCLIST /* 619 */ ":End of DCCALLOW %s"
|
||||
#define STR_RPL_DCCINFO /* 620 */ ":%s"
|
||||
#define STR_RPL_SPAMCMDFWD /* 659 */ "%s :Command processed, but a copy has been sent to ircops for evaluation (anti-spam) purposes. [%s]"
|
||||
#define STR_RPL_STARTTLS /* 670 */ ":STARTTLS successful, go ahead with TLS handshake" /* kineircd */
|
||||
#define STR_RPL_WHOISSECURE /* 671 */ "%s :%s" /* our variation on the kineircd numeric */
|
||||
#define STR_ERR_STARTTLS /* 691 */ ":%s"
|
||||
#define STR_ERR_INVALIDMODEPARAM /* 696 */ "%s %c %s :%s"
|
||||
#define STR_RPL_MONONLINE /* 730 */ ":%s!%s@%s"
|
||||
#define STR_RPL_MONOFFLINE /* 731 */ ":%s"
|
||||
#define STR_RPL_MONLIST /* 732 */ ":%s"
|
||||
#define STR_RPL_ENDOFMONLIST /* 733 */ ":End of MONITOR list"
|
||||
#define STR_ERR_MONLISTFULL /* 734 */ "%d %s :Monitor list is full."
|
||||
#define STR_ERR_MLOCKRESTRICTED /* 742 */ "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy"
|
||||
#define STR_RPL_LOGGEDIN /* 900 */ "%s!%s@%s %s :You are now logged in as %s."
|
||||
#define STR_RPL_LOGGEDOUT /* 901 */ "%s!%s@%s :You are now logged out."
|
||||
#define STR_RPL_SASLSUCCESS /* 903 */ ":SASL authentication successful"
|
||||
#define STR_ERR_SASLFAIL /* 904 */ ":SASL authentication failed"
|
||||
#define STR_ERR_SASLTOOLONG /* 905 */ ":SASL message too long"
|
||||
#define STR_ERR_SASLABORTED /* 906 */ ":SASL authentication aborted"
|
||||
#define STR_RPL_SASLMECHS /* 908 */ "%s :are available SASL mechanisms"
|
||||
#define STR_ERR_CANNOTDOCOMMAND /* 972 */ "%s :%s"
|
||||
#define STR_ERR_CANNOTCHANGECHANMODE /* 974 */ "%c :%s"
|
||||
#define STR_RPL_WELCOME /* 001 */ ":Welcome to the %s IRC Network %s!%s@%s"
|
||||
#define STR_RPL_YOURHOST /* 002 */ ":Your host is %s, running version %s"
|
||||
#define STR_RPL_CREATED /* 003 */ ":This server was created %s"
|
||||
#define STR_RPL_MYINFO /* 004 */ "%s %s %s %s"
|
||||
#define STR_RPL_ISUPPORT /* 005 */ "%s :are supported by this server"
|
||||
#define STR_RPL_MAP /* 006 */ ":%s%s %s | Users: %*ld (%*.2f%%)%s"
|
||||
#define STR_RPL_MAPEND /* 007 */ ":End of /MAP"
|
||||
#define STR_RPL_SNOMASK /* 008 */ "+%s :Server notice mask"
|
||||
#define STR_RPL_REDIR /* 010 */ "%s %d :Please use this Server/Port instead"
|
||||
#define STR_RPL_MAPUSERS /* 018 */ ":%d server%s and %d user%s, average %.2f users per server"
|
||||
#define STR_RPL_REMOTEISUPPORT /* 105 */ "%s :are supported by this server"
|
||||
#define STR_RPL_TRACELINK /* 200 */ "Link %s%s %s %s"
|
||||
#define STR_RPL_TRACECONNECTING /* 201 */ "Attempt %s %s"
|
||||
#define STR_RPL_TRACEHANDSHAKE /* 202 */ "Handshaking %s %s"
|
||||
#define STR_RPL_TRACEUNKNOWN /* 203 */ "???? %s %s"
|
||||
#define STR_RPL_TRACEOPERATOR /* 204 */ "Operator %s %s [%s] %lld"
|
||||
#define STR_RPL_TRACEUSER /* 205 */ "User %s %s [%s] %lld"
|
||||
#define STR_RPL_TRACESERVER /* 206 */ "Server %s %dS %dC %s %s!%s@%s %lld"
|
||||
#define STR_RPL_TRACENEWTYPE /* 208 */ "%s 0 %s"
|
||||
#define STR_RPL_TRACECLASS /* 209 */ "Class %s %d"
|
||||
#define STR_RPL_STATSHELP /* 210 */ ":%s"
|
||||
#define STR_RPL_STATSCOMMANDS /* 212 */ "%s %u %lu"
|
||||
#define STR_RPL_STATSCLINE /* 213 */ "%c %s * %s %d %d %s"
|
||||
#define STR_RPL_STATSILINE /* 215 */ "I %s %s %d %d %s %s %d"
|
||||
#define STR_RPL_STATSQLINE /* 217 */ "%c %s %lld %lld %s %lld %lld %s :%s"
|
||||
#define STR_RPL_STATSYLINE /* 218 */ "Y %s %d %d %d %d %d"
|
||||
#define STR_RPL_ENDOFSTATS /* 219 */ "%c :End of /STATS report"
|
||||
#define STR_RPL_UMODEIS /* 221 */ "%s"
|
||||
#define STR_RPL_STATSGLINE /* 223 */ "%c %s %lld %lld %s %lld %lld %s %s :%s"
|
||||
#define STR_RPL_STATSTLINE /* 224 */ "T %s %s %s"
|
||||
#define STR_RPL_STATSNLINE /* 226 */ "n %s %s"
|
||||
#define STR_RPL_STATSVLINE /* 227 */ "v %s %s %s"
|
||||
#define STR_RPL_STATSBANVER /* 228 */ "%s %s"
|
||||
#define STR_RPL_STATSSPAMF /* 229 */ "%c %s %s %s %lld %lld %lld %s %s %lld %lld %lld %lld %s :%s"
|
||||
#define STR_RPL_STATSEXCEPTTKL /* 230 */ "%s %s %lld %lld %s %s :%s"
|
||||
#define STR_RPL_RULES /* 232 */ ":- %s"
|
||||
#define STR_RPL_STATSLLINE /* 241 */ "%c %s * %s %d %d"
|
||||
#define STR_RPL_STATSUPTIME /* 242 */ ":Server Up %lld days, %lld:%02lld:%02lld"
|
||||
#define STR_RPL_STATSOLINE /* 243 */ "%c %s * %s %s %s"
|
||||
#define STR_RPL_STATSHLINE /* 244 */ "%c %s * %s %d %d"
|
||||
#define STR_RPL_STATSXLINE /* 247 */ "X %s %d"
|
||||
#define STR_RPL_STATSULINE /* 248 */ "U %s"
|
||||
#define STR_RPL_STATSDEBUG /* 249 */ ":%s"
|
||||
#define STR_RPL_STATSCONN /* 250 */ ":Highest connection count: %d (%d clients)"
|
||||
#define STR_RPL_LUSERCLIENT /* 251 */ ":There are %d users and %d invisible on %d servers"
|
||||
#define STR_RPL_LUSEROP /* 252 */ "%d :operator(s) online"
|
||||
#define STR_RPL_LUSERUNKNOWN /* 253 */ "%d :unknown connection(s)"
|
||||
#define STR_RPL_LUSERCHANNELS /* 254 */ "%d :channels formed"
|
||||
#define STR_RPL_LUSERME /* 255 */ ":I have %d clients and %d servers"
|
||||
#define STR_RPL_ADMINME /* 256 */ ":Administrative info about %s"
|
||||
#define STR_RPL_ADMINLOC1 /* 257 */ ":%s"
|
||||
#define STR_RPL_ADMINLOC2 /* 258 */ ":%s"
|
||||
#define STR_RPL_ADMINEMAIL /* 259 */ ":%s"
|
||||
#define STR_RPL_TRACELOG /* 261 */ "File %s %d"
|
||||
#define STR_RPL_TRYAGAIN /* 263 */ "%s :Flooding detected. Please wait a while and try again."
|
||||
#define STR_RPL_LOCALUSERS /* 265 */ "%d %d :Current local users %d, max %d"
|
||||
#define STR_RPL_GLOBALUSERS /* 266 */ "%d %d :Current global users %d, max %d"
|
||||
#define STR_RPL_SILELIST /* 271 */ "%s"
|
||||
#define STR_RPL_ENDOFSILELIST /* 272 */ ":End of Silence List"
|
||||
#define STR_RPL_STATSDLINE /* 275 */ "%c %s %s"
|
||||
#define STR_RPL_WHOISCERTFP /* 276 */ "%s :has client certificate fingerprint %s"
|
||||
#define STR_RPL_AWAY /* 301 */ "%s :%s"
|
||||
#define STR_RPL_USERHOST /* 302 */ ":%s %s %s %s %s"
|
||||
#define STR_RPL_ISON /* 303 */ ":"
|
||||
#define STR_RPL_UNAWAY /* 305 */ ":You are no longer marked as being away"
|
||||
#define STR_RPL_NOWAWAY /* 306 */ ":You have been marked as being away"
|
||||
#define STR_RPL_WHOISREGNICK /* 307 */ "%s :is identified for this nick"
|
||||
#define STR_RPL_RULESSTART /* 308 */ ":- %s Server Rules - "
|
||||
#define STR_RPL_ENDOFRULES /* 309 */ ":End of RULES command."
|
||||
#define STR_RPL_WHOISUSER /* 311 */ "%s %s %s * :%s"
|
||||
#define STR_RPL_WHOISSERVER /* 312 */ "%s %s :%s"
|
||||
#define STR_RPL_WHOISOPERATOR /* 313 */ "%s :is %s"
|
||||
#define STR_RPL_WHOWASUSER /* 314 */ "%s %s %s * :%s"
|
||||
#define STR_RPL_ENDOFWHO /* 315 */ "%s :End of /WHO list."
|
||||
#define STR_RPL_WHOISIDLE /* 317 */ "%s %lld %lld :seconds idle, signon time"
|
||||
#define STR_RPL_ENDOFWHOIS /* 318 */ "%s :End of /WHOIS list."
|
||||
#define STR_RPL_WHOISCHANNELS /* 319 */ "%s :%s"
|
||||
#define STR_RPL_WHOISSPECIAL /* 320 */ "%s :%s"
|
||||
#define STR_RPL_LISTSTART /* 321 */ "Channel :Users Name"
|
||||
#define STR_RPL_LIST /* 322 */ "%s %d :%s %s"
|
||||
#define STR_RPL_LISTEND /* 323 */ ":End of /LIST"
|
||||
#define STR_RPL_CHANNELMODEIS /* 324 */ "%s %s %s"
|
||||
#define STR_RPL_CREATIONTIME /* 329 */ "%s %lld"
|
||||
#define STR_RPL_WHOISLOGGEDIN /* 330 */ "%s %s :is logged in as"
|
||||
#define STR_RPL_NOTOPIC /* 331 */ "%s :No topic is set."
|
||||
#define STR_RPL_TOPIC /* 332 */ "%s :%s"
|
||||
#define STR_RPL_TOPICWHOTIME /* 333 */ "%s %s %lld"
|
||||
#define STR_RPL_LISTSYNTAX /* 334 */ ":%s"
|
||||
#define STR_RPL_WHOISBOT /* 335 */ "%s :is a \2Bot\2 on %s"
|
||||
#define STR_RPL_INVITELIST /* 336 */ ":%s"
|
||||
#define STR_RPL_ENDOFINVITELIST /* 337 */ ":End of /INVITE list."
|
||||
#define STR_RPL_USERIP /* 340 */ ":%s %s %s %s %s"
|
||||
#define STR_RPL_INVITING /* 341 */ "%s %s"
|
||||
#define STR_RPL_WHOISCOUNTRY /* 344 */ "%s %s :is connecting from %s"
|
||||
#define STR_RPL_INVEXLIST /* 346 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFINVEXLIST /* 347 */ "%s :End of Channel Invite List"
|
||||
#define STR_RPL_EXLIST /* 348 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFEXLIST /* 349 */ "%s :End of Channel Exception List"
|
||||
#define STR_RPL_VERSION /* 351 */ "%s.%s %s :%s%s%s [%s=%d]"
|
||||
#define STR_RPL_WHOREPLY /* 352 */ "%s %s %s %s %s %s :%d %s"
|
||||
#define STR_RPL_NAMREPLY /* 353 */ "%s"
|
||||
#define STR_RPL_CLOSING /* 362 */ "%s :Closed. Status = %d"
|
||||
#define STR_RPL_CLOSEEND /* 363 */ "%d: Connections Closed"
|
||||
#define STR_RPL_LINKS /* 364 */ "%s %s :%d %s"
|
||||
#define STR_RPL_ENDOFLINKS /* 365 */ "%s :End of /LINKS list."
|
||||
#define STR_RPL_ENDOFNAMES /* 366 */ "%s :End of /NAMES list."
|
||||
#define STR_RPL_BANLIST /* 367 */ "%s %s %s %lld"
|
||||
#define STR_RPL_ENDOFBANLIST /* 368 */ "%s :End of Channel Ban List"
|
||||
#define STR_RPL_ENDOFWHOWAS /* 369 */ "%s :End of WHOWAS"
|
||||
#define STR_RPL_INFO /* 371 */ ":%s"
|
||||
#define STR_RPL_MOTD /* 372 */ ":- %s"
|
||||
#define STR_RPL_ENDOFINFO /* 374 */ ":End of /INFO list."
|
||||
#define STR_RPL_MOTDSTART /* 375 */ ":- %s Message of the Day - "
|
||||
#define STR_RPL_ENDOFMOTD /* 376 */ ":End of /MOTD command."
|
||||
#define STR_RPL_WHOISHOST /* 378 */ "%s :is connecting from %s@%s %s"
|
||||
#define STR_RPL_WHOISMODES /* 379 */ "%s :is using modes %s %s"
|
||||
#define STR_RPL_YOUREOPER /* 381 */ ":You are now an IRC Operator"
|
||||
#define STR_RPL_REHASHING /* 382 */ "%s :Rehashing"
|
||||
#define STR_RPL_QLIST /* 386 */ "%s %s"
|
||||
#define STR_RPL_ENDOFQLIST /* 387 */ "%s :End of Channel Owner List"
|
||||
#define STR_RPL_ALIST /* 388 */ "%s %s"
|
||||
#define STR_RPL_ENDOFALIST /* 389 */ "%s :End of Protected User List"
|
||||
#define STR_RPL_TIME /* 391 */ "%s :%s"
|
||||
#define STR_RPL_HOSTHIDDEN /* 396 */ "%s :is now your displayed host"
|
||||
#define STR_ERR_NOSUCHNICK /* 401 */ "%s :No such nick/channel"
|
||||
#define STR_ERR_NOSUCHSERVER /* 402 */ "%s :No such server"
|
||||
#define STR_ERR_NOSUCHCHANNEL /* 403 */ "%s :No such channel"
|
||||
#define STR_ERR_CANNOTSENDTOCHAN /* 404 */ "%s :%s (%s)"
|
||||
#define STR_ERR_TOOMANYCHANNELS /* 405 */ "%s :You have joined too many channels"
|
||||
#define STR_ERR_WASNOSUCHNICK /* 406 */ "%s :There was no such nickname"
|
||||
#define STR_ERR_TOOMANYTARGETS /* 407 */ "%s :Too many targets. The maximum is %d for %s."
|
||||
#define STR_ERR_NOORIGIN /* 409 */ ":No origin specified"
|
||||
#define STR_ERR_INVALIDCAPCMD /* 410 */ "%s :Invalid CAP subcommand"
|
||||
#define STR_ERR_NORECIPIENT /* 411 */ ":No recipient given (%s)"
|
||||
#define STR_ERR_NOTEXTTOSEND /* 412 */ ":No text to send"
|
||||
#define STR_ERR_TOOMANYMATCHES /* 416 */ "%s :%s"
|
||||
#define STR_ERR_INPUTTOOLONG /* 417 */ ":Input line was too long"
|
||||
#define STR_ERR_UNKNOWNCOMMAND /* 421 */ "%s :Unknown command"
|
||||
#define STR_ERR_NOMOTD /* 422 */ ":MOTD File is missing"
|
||||
#define STR_ERR_NOADMININFO /* 423 */ "%s :No administrative info available"
|
||||
#define STR_ERR_NOOPERMOTD /* 425 */ ":OPERMOTD File is missing"
|
||||
#define STR_ERR_TOOMANYAWAY /* 429 */ ":Too Many aways - Flood Protection activated"
|
||||
#define STR_ERR_NONICKNAMEGIVEN /* 431 */ ":No nickname given"
|
||||
#define STR_ERR_ERRONEUSNICKNAME /* 432 */ "%s :Nickname is unavailable: %s"
|
||||
#define STR_ERR_NICKNAMEINUSE /* 433 */ "%s :Nickname is already in use."
|
||||
#define STR_ERR_NORULES /* 434 */ ":RULES File is missing"
|
||||
#define STR_ERR_BANNICKCHANGE /* 437 */ "%s :Cannot change nickname while banned on channel"
|
||||
#define STR_ERR_NCHANGETOOFAST /* 438 */ "%s :Nick change too fast. Please try again later."
|
||||
#define STR_ERR_TARGETTOOFAST /* 439 */ "%s :Message target change too fast. Please wait %lld seconds"
|
||||
#define STR_ERR_SERVICESDOWN /* 440 */ "%s :Services are currently down. Please try again later."
|
||||
#define STR_ERR_USERNOTINCHANNEL /* 441 */ "%s %s :They aren't on that channel"
|
||||
#define STR_ERR_NOTONCHANNEL /* 442 */ "%s :You're not on that channel"
|
||||
#define STR_ERR_USERONCHANNEL /* 443 */ "%s %s :is already on channel"
|
||||
#define STR_ERR_NONICKCHANGE /* 447 */ ":Can not change nickname while on %s (+N)"
|
||||
#define STR_ERR_FORBIDDENCHANNEL /* 448 */ "%s :Cannot join channel: %s"
|
||||
#define STR_ERR_NOTREGISTERED /* 451 */ ":You have not registered"
|
||||
#define STR_ERR_NOTFORHALFOPS /* 460 */ ":Halfops cannot set mode %c"
|
||||
#define STR_ERR_NEEDMOREPARAMS /* 461 */ "%s :Not enough parameters"
|
||||
#define STR_ERR_ALREADYREGISTRED /* 462 */ ":You may not reregister"
|
||||
#define STR_ERR_PASSWDMISMATCH /* 464 */ ":Password Incorrect"
|
||||
#define STR_ERR_YOUREBANNEDCREEP /* 465 */ ":%s"
|
||||
#define STR_ERR_ONLYSERVERSCANCHANGE /* 468 */ "%s :Only servers can change that mode"
|
||||
#define STR_ERR_LINKCHANNEL /* 470 */ "%s %s :[Link] %s has become full, so you are automatically being transferred to the linked channel %s"
|
||||
#define STR_ERR_CHANNELISFULL /* 471 */ "%s :Cannot join channel (+l)"
|
||||
#define STR_ERR_UNKNOWNMODE /* 472 */ "%c :is unknown mode char to me"
|
||||
#define STR_ERR_INVITEONLYCHAN /* 473 */ "%s :Cannot join channel (+i)"
|
||||
#define STR_ERR_BANNEDFROMCHAN /* 474 */ "%s :Cannot join channel (+b)"
|
||||
#define STR_ERR_BADCHANNELKEY /* 475 */ "%s :Cannot join channel (+k)"
|
||||
#define STR_ERR_NEEDREGGEDNICK /* 477 */ "%s :You need a registered nick to join that channel."
|
||||
#define STR_ERR_BANLISTFULL /* 478 */ "%s %s :Channel ban/ignore list is full"
|
||||
#define STR_ERR_CANNOTKNOCK /* 480 */ ":Cannot knock on %s (%s)"
|
||||
#define STR_ERR_NOPRIVILEGES /* 481 */ ":Permission Denied- You do not have the correct IRC operator privileges"
|
||||
#define STR_ERR_CHANOPRIVSNEEDED /* 482 */ "%s :You're not channel operator"
|
||||
#define STR_ERR_KILLDENY /* 485 */ ":Cannot kill protected user %s."
|
||||
#define STR_ERR_NOTFORUSERS /* 487 */ ":%s is a server only command"
|
||||
#define STR_ERR_SECUREONLYCHAN /* 489 */ "%s :Cannot join channel (Secure connection is required)"
|
||||
#define STR_ERR_NOOPERHOST /* 491 */ ":No O-lines for your host"
|
||||
#define STR_ERR_CHANOWNPRIVNEEDED /* 499 */ "%s :You're not a channel owner"
|
||||
#define STR_ERR_TOOMANYJOINS /* 500 */ "%s :Too many join requests. Please wait a while and try again."
|
||||
#define STR_ERR_UMODEUNKNOWNFLAG /* 501 */ ":Unknown MODE flag"
|
||||
#define STR_ERR_USERSDONTMATCH /* 502 */ ":Cant change mode for other users"
|
||||
#define STR_ERR_SILELISTFULL /* 511 */ "%s :Your silence list is full"
|
||||
#define STR_ERR_TOOMANYWATCH /* 512 */ "%s :Maximum size for WATCH-list is 128 entries"
|
||||
#define STR_ERR_TOOMANYDCC /* 514 */ "%s :Your dcc allow list is full. Maximum size is %d entries"
|
||||
#define STR_ERR_DISABLED /* 517 */ "%s :%s" /* ircu */
|
||||
#define STR_ERR_NOINVITE /* 518 */ ":Cannot invite (+V) at channel %s"
|
||||
#define STR_ERR_OPERONLY /* 520 */ ":Cannot join channel %s (IRCops only)"
|
||||
#define STR_ERR_LISTSYNTAX /* 521 */ ":Bad list syntax, type /quote list ? or /raw list ?"
|
||||
#define STR_ERR_WHOLIMEXCEED /* 523 */ ":Error, /who limit of %d exceeded. Please narrow your search down and try again"
|
||||
#define STR_ERR_OPERSPVERIFY /* 524 */ "%s :Trying to join +s or +p channel as an oper. Please invite yourself first."
|
||||
#define STR_ERR_CANTSENDTOUSER /* 531 */ "%s :%s"
|
||||
#define STR_RPL_WHOISASN /* 569 */ "%u :%s [%s]"
|
||||
#define STR_RPL_REAWAY /* 597 */ "%s %s %s %lld :%s"
|
||||
#define STR_RPL_GONEAWAY /* 598 */ "%s %s %s %lld :%s"
|
||||
#define STR_RPL_NOTAWAY /* 599 */ "%s %s %s %lld :is no longer away"
|
||||
#define STR_RPL_LOGON /* 600 */ "%s %s %s %lld :logged online"
|
||||
#define STR_RPL_LOGOFF /* 601 */ "%s %s %s %lld :logged offline"
|
||||
#define STR_RPL_WATCHOFF /* 602 */ "%s %s %s %lld :stopped watching"
|
||||
#define STR_RPL_WATCHSTAT /* 603 */ ":You have %d and are on %d WATCH entries"
|
||||
#define STR_RPL_NOWON /* 604 */ "%s %s %s %lld :is online"
|
||||
#define STR_RPL_NOWOFF /* 605 */ "%s %s %s %lld :is offline"
|
||||
#define STR_RPL_WATCHLIST /* 606 */ ":%s"
|
||||
#define STR_RPL_ENDOFWATCHLIST /* 607 */ ":End of WATCH %c"
|
||||
#define STR_RPL_NOWISAWAY /* 609 */ "%s %s %s %lld :is away"
|
||||
#define STR_RPL_MAPMORE /* 610 */ ":%s%-*s --> *more*"
|
||||
#define STR_RPL_DCCSTATUS /* 617 */ ":%s has been %s your DCC allow list"
|
||||
#define STR_RPL_DCCLIST /* 618 */ ":%s"
|
||||
#define STR_RPL_ENDOFDCCLIST /* 619 */ ":End of DCCALLOW %s"
|
||||
#define STR_RPL_DCCINFO /* 620 */ ":%s"
|
||||
#define STR_RPL_SPAMCMDFWD /* 659 */ "%s :Command processed, but a copy has been sent to ircops for evaluation (anti-spam) purposes. [%s]"
|
||||
#define STR_RPL_STARTTLS /* 670 */ ":STARTTLS successful, go ahead with TLS handshake" /* kineircd */
|
||||
#define STR_RPL_WHOISSECURE /* 671 */ "%s :%s" /* our variation on the kineircd numeric */
|
||||
#define STR_ERR_STARTTLS /* 691 */ ":%s"
|
||||
#define STR_ERR_INVALIDMODEPARAM /* 696 */ "%s %c %s :%s"
|
||||
#define STR_RPL_MONONLINE /* 730 */ ":%s!%s@%s"
|
||||
#define STR_RPL_MONOFFLINE /* 731 */ ":%s"
|
||||
#define STR_RPL_MONLIST /* 732 */ ":%s"
|
||||
#define STR_RPL_ENDOFMONLIST /* 733 */ ":End of MONITOR list"
|
||||
#define STR_ERR_MONLISTFULL /* 734 */ "%d %s :Monitor list is full."
|
||||
#define STR_ERR_MLOCKRESTRICTED /* 742 */ "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy"
|
||||
#define STR_RPL_LOGGEDIN /* 900 */ "%s!%s@%s %s :You are now logged in as %s."
|
||||
#define STR_RPL_LOGGEDOUT /* 901 */ "%s!%s@%s :You are now logged out."
|
||||
#define STR_RPL_SASLSUCCESS /* 903 */ ":SASL authentication successful"
|
||||
#define STR_ERR_SASLFAIL /* 904 */ ":SASL authentication failed"
|
||||
#define STR_ERR_SASLTOOLONG /* 905 */ ":SASL message too long"
|
||||
#define STR_ERR_SASLABORTED /* 906 */ ":SASL authentication aborted"
|
||||
#define STR_RPL_SASLMECHS /* 908 */ "%s :are available SASL mechanisms"
|
||||
#define STR_ERR_CANNOTDOCOMMAND /* 972 */ "%s :%s"
|
||||
#define STR_ERR_CANNOTCHANGECHANMODE /* 974 */ "%c :%s"
|
||||
|
||||
+51
-51
@@ -2,58 +2,58 @@
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by GENERIC.RC
|
||||
// $Id$
|
||||
#define IDC_USERID 1051
|
||||
#define IDC_REALNAME 1052
|
||||
#define IDC_PNICK 1053
|
||||
#define IDC_ANICK 1054
|
||||
#define IDC_SERVERLIST 1057
|
||||
#define IDC_NEWSERVER 1058
|
||||
#define IDC_EDITSERVER 1059
|
||||
#define IDC_IRCDCONF 1059
|
||||
#define IDC_DELSERVER 1060
|
||||
#define IDC_SHOW_GLOBOPS 1060
|
||||
#define IDC_SHOW_WALLOPS 1061
|
||||
#define IDC_SHOW_HELPOPS 1062
|
||||
#define IDC_SHOW_SERVNOTICE 1063
|
||||
#define IDC_INFOTEXT 1063
|
||||
#define IDM_OPEN 40001
|
||||
#define IDM_SAVE 40002
|
||||
#define IDM_SAVEAS 40003
|
||||
#define IDM_EXIT 40004
|
||||
#define IDM_ABOUT 40005
|
||||
#define IDM_WINDOWCHILD 40006
|
||||
#define IDM_REHASH 40007
|
||||
#define IDM_OPTIONS 40008
|
||||
#define IDM_CREDITS 40009
|
||||
#define IDM_DF 40010
|
||||
#define IDM_LICENSE 40011
|
||||
#define IDM_DBGOFF 41099
|
||||
#define IDM_DBGFATAL 41100
|
||||
#define IDM_DBGERROR 41101
|
||||
#define IDM_DBGNOTICE 41103
|
||||
#define IDM_DBGDNS 41104
|
||||
#define IDM_DBGINFO 41105
|
||||
#define IDM_DBGNUM 41106
|
||||
#define IDM_DBGSEND 41107
|
||||
#define IDM_DBGDEBUG 41108
|
||||
#define IDM_DBGMALLOC 41109
|
||||
#define IDM_DBGLIST 41110
|
||||
#define IDM_POPUP 50000
|
||||
#define IDC_STATIC -1
|
||||
#define IDM_IRCDRULES 65530
|
||||
#define IDM_IRCDMOTD 65531
|
||||
#define IDC_VERSION 65532
|
||||
#define IDM_SETUP 65536
|
||||
#define IDM_IRCDCONF 65535
|
||||
#define IDC_USERID 1051
|
||||
#define IDC_REALNAME 1052
|
||||
#define IDC_PNICK 1053
|
||||
#define IDC_ANICK 1054
|
||||
#define IDC_SERVERLIST 1057
|
||||
#define IDC_NEWSERVER 1058
|
||||
#define IDC_EDITSERVER 1059
|
||||
#define IDC_IRCDCONF 1059
|
||||
#define IDC_DELSERVER 1060
|
||||
#define IDC_SHOW_GLOBOPS 1060
|
||||
#define IDC_SHOW_WALLOPS 1061
|
||||
#define IDC_SHOW_HELPOPS 1062
|
||||
#define IDC_SHOW_SERVNOTICE 1063
|
||||
#define IDC_INFOTEXT 1063
|
||||
#define IDM_OPEN 40001
|
||||
#define IDM_SAVE 40002
|
||||
#define IDM_SAVEAS 40003
|
||||
#define IDM_EXIT 40004
|
||||
#define IDM_ABOUT 40005
|
||||
#define IDM_WINDOWCHILD 40006
|
||||
#define IDM_REHASH 40007
|
||||
#define IDM_OPTIONS 40008
|
||||
#define IDM_CREDITS 40009
|
||||
#define IDM_DF 40010
|
||||
#define IDM_LICENSE 40011
|
||||
#define IDM_DBGOFF 41099
|
||||
#define IDM_DBGFATAL 41100
|
||||
#define IDM_DBGERROR 41101
|
||||
#define IDM_DBGNOTICE 41103
|
||||
#define IDM_DBGDNS 41104
|
||||
#define IDM_DBGINFO 41105
|
||||
#define IDM_DBGNUM 41106
|
||||
#define IDM_DBGSEND 41107
|
||||
#define IDM_DBGDEBUG 41108
|
||||
#define IDM_DBGMALLOC 41109
|
||||
#define IDM_DBGLIST 41110
|
||||
#define IDM_POPUP 50000
|
||||
#define IDC_STATIC -1
|
||||
#define IDM_IRCDRULES 65530
|
||||
#define IDM_IRCDMOTD 65531
|
||||
#define IDC_VERSION 65532
|
||||
#define IDM_SETUP 65536
|
||||
#define IDM_IRCDCONF 65535
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
#define _APS_NEXT_COMMAND_VALUE 40011
|
||||
#define _APS_NEXT_CONTROL_VALUE 1064
|
||||
#define _APS_NEXT_SYMED_VALUE 104
|
||||
#endif
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 113
|
||||
#define _APS_NEXT_COMMAND_VALUE 40011
|
||||
#define _APS_NEXT_CONTROL_VALUE 1064
|
||||
#define _APS_NEXT_SYMED_VALUE 104
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1249
-1181
File diff suppressed because it is too large
Load Diff
+111
-105
@@ -19,51 +19,51 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __sys_include__
|
||||
#ifndef __sys_include__
|
||||
#define __sys_include__
|
||||
|
||||
/* PATH_MAX */
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef ISC202
|
||||
#include <net/errno.h>
|
||||
#include <net/errno.h>
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include "setup.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/param.h>
|
||||
#include <sys/param.h>
|
||||
#else
|
||||
#include <stdarg.h>
|
||||
#include <process.h>
|
||||
#include <stdarg.h>
|
||||
#include <process.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
/* get intptr_t if the system provides it -- otherwise, ./configure will define it for us */
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
#endif /* HAVE_STDINT_H */
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
#endif /* HAVE_STDINT_H */
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <arpa/inet.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <afunix.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <afunix.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TCP_INFO
|
||||
@@ -71,39 +71,39 @@
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/wait.h>
|
||||
#ifndef WEXITSTATUS
|
||||
#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
|
||||
#endif
|
||||
#ifndef WIFEXITED
|
||||
#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
|
||||
#endif
|
||||
#include <sys/wait.h>
|
||||
#ifndef WEXITSTATUS
|
||||
#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
|
||||
#endif
|
||||
#ifndef WIFEXITED
|
||||
#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Different name on NetBSD, FreeBSD, and BSDI
|
||||
*/
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(__linux__) || defined(__APPLE__)
|
||||
#define dn_skipname __dn_skipname
|
||||
#define dn_skipname __dn_skipname
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Mac OS X Tiger Support (Intel Only)
|
||||
*/
|
||||
#if defined(macosx) || defined(__APPLE__)
|
||||
#define OSXTIGER
|
||||
#define OSXTIGER
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
extern void dummy();
|
||||
#endif
|
||||
|
||||
#ifdef NO_U_TYPES
|
||||
#ifdef NO_U_TYPES
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned long u_long;
|
||||
@@ -111,12 +111,12 @@ typedef unsigned int u_int;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MYOSNAME OSName
|
||||
#define MYOSNAME OSName
|
||||
extern char OSName[256];
|
||||
#define PATH_MAX MAX_PATH
|
||||
#define getpid _getpid
|
||||
#define PATH_MAX MAX_PATH
|
||||
#define getpid _getpid
|
||||
#else
|
||||
#define MYOSNAME getosname()
|
||||
#define MYOSNAME getosname()
|
||||
#endif
|
||||
|
||||
#define MYDUMMY_SIZE 128
|
||||
@@ -125,74 +125,74 @@ extern char OSName[256];
|
||||
* Socket, File, and Error portability macros
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
#define SET_ERRNO(x) errno = x
|
||||
#define READ_SOCK(fd, buf, len) read((fd), (buf), (len))
|
||||
#define WRITE_SOCK(fd, buf, len) write((fd), (buf), (len))
|
||||
#define CLOSE_SOCK(fd) close(fd)
|
||||
#define IOCTL(x, y, z) ioctl((x), (y), (z))
|
||||
#define ERRNO errno
|
||||
#define STRERROR(x) strerror(x)
|
||||
#define SET_ERRNO(x) errno = x
|
||||
#define READ_SOCK(fd, buf, len) read((fd), (buf), (len))
|
||||
#define WRITE_SOCK(fd, buf, len) write((fd), (buf), (len))
|
||||
#define CLOSE_SOCK(fd) close(fd)
|
||||
#define IOCTL(x, y, z) ioctl((x), (y), (z))
|
||||
#define ERRNO errno
|
||||
#define STRERROR(x) strerror(x)
|
||||
|
||||
/* error constant portability */
|
||||
#define P_EMFILE EMFILE
|
||||
#define P_ENOBUFS ENOBUFS
|
||||
#define P_EWOULDBLOCK EWOULDBLOCK
|
||||
#define P_EAGAIN EAGAIN
|
||||
#define P_EINPROGRESS EINPROGRESS
|
||||
#define P_EWORKING EINPROGRESS
|
||||
#define P_EINTR EINTR
|
||||
#define P_ETIMEDOUT ETIMEDOUT
|
||||
#define P_ENOTSOCK ENOTSOCK
|
||||
#define P_EIO EIO
|
||||
#define P_ECONNABORTED ECONNABORTED
|
||||
#define P_ECONNRESET ECONNRESET
|
||||
#define P_ENOTCONN ENOTCONN
|
||||
#define P_EMSGSIZE EMSGSIZE
|
||||
/* error constant portability */
|
||||
#define P_EMFILE EMFILE
|
||||
#define P_ENOBUFS ENOBUFS
|
||||
#define P_EWOULDBLOCK EWOULDBLOCK
|
||||
#define P_EAGAIN EAGAIN
|
||||
#define P_EINPROGRESS EINPROGRESS
|
||||
#define P_EWORKING EINPROGRESS
|
||||
#define P_EINTR EINTR
|
||||
#define P_ETIMEDOUT ETIMEDOUT
|
||||
#define P_ENOTSOCK ENOTSOCK
|
||||
#define P_EIO EIO
|
||||
#define P_ECONNABORTED ECONNABORTED
|
||||
#define P_ECONNRESET ECONNRESET
|
||||
#define P_ENOTCONN ENOTCONN
|
||||
#define P_EMSGSIZE EMSGSIZE
|
||||
#else
|
||||
/* WIN32 */
|
||||
/* WIN32 */
|
||||
|
||||
#define NETDB_INTERNAL -1 /* see errno */
|
||||
#define NETDB_SUCCESS 0 /* no problem */
|
||||
#define NETDB_INTERNAL -1 /* see errno */
|
||||
#define NETDB_SUCCESS 0 /* no problem */
|
||||
|
||||
/* IO and Error portability macros */
|
||||
#define READ_SOCK(fd, buf, len) recv((fd), (buf), (len), 0)
|
||||
#define WRITE_SOCK(fd, buf, len) send((fd), (buf), (len), 0)
|
||||
#define CLOSE_SOCK(fd) closesocket(fd)
|
||||
#define IOCTL(x, y, z) ioctlsocket((x), (y), (z))
|
||||
#define ERRNO WSAGetLastError()
|
||||
#define STRERROR(x) sock_strerror(x)
|
||||
#define SET_ERRNO(x) WSASetLastError(x)
|
||||
/* Error constant portability */
|
||||
#define P_EMFILE WSAEMFILE
|
||||
#define P_ENOBUFS WSAENOBUFS
|
||||
#define P_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define P_EAGAIN WSAEWOULDBLOCK
|
||||
#define P_EINPROGRESS WSAEINPROGRESS
|
||||
#define P_EWORKING WSAEWOULDBLOCK
|
||||
#define P_EINTR WSAEINTR
|
||||
#define P_ETIMEDOUT WSAETIMEDOUT
|
||||
#define P_ENOTSOCK WSAENOTSOCK
|
||||
#define P_EIO EIO
|
||||
#define P_ECONNABORTED WSAECONNABORTED
|
||||
#define P_ECONNRESET WSAECONNRESET
|
||||
#define P_ENOTCONN WSAENOTCONN
|
||||
#define P_EMSGSIZE WSAEMSGSIZE
|
||||
/* IO and Error portability macros */
|
||||
#define READ_SOCK(fd, buf, len) recv((fd), (buf), (len), 0)
|
||||
#define WRITE_SOCK(fd, buf, len) send((fd), (buf), (len), 0)
|
||||
#define CLOSE_SOCK(fd) closesocket(fd)
|
||||
#define IOCTL(x, y, z) ioctlsocket((x), (y), (z))
|
||||
#define ERRNO WSAGetLastError()
|
||||
#define STRERROR(x) sock_strerror(x)
|
||||
#define SET_ERRNO(x) WSASetLastError(x)
|
||||
/* Error constant portability */
|
||||
#define P_EMFILE WSAEMFILE
|
||||
#define P_ENOBUFS WSAENOBUFS
|
||||
#define P_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define P_EAGAIN WSAEWOULDBLOCK
|
||||
#define P_EINPROGRESS WSAEINPROGRESS
|
||||
#define P_EWORKING WSAEWOULDBLOCK
|
||||
#define P_EINTR WSAEINTR
|
||||
#define P_ETIMEDOUT WSAETIMEDOUT
|
||||
#define P_ENOTSOCK WSAENOTSOCK
|
||||
#define P_EIO EIO
|
||||
#define P_ECONNABORTED WSAECONNABORTED
|
||||
#define P_ECONNRESET WSAECONNRESET
|
||||
#define P_ENOTCONN WSAENOTCONN
|
||||
#define P_EMSGSIZE WSAEMSGSIZE
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x) /* nothing */
|
||||
#define __attribute__(x) /* nothing */
|
||||
#endif
|
||||
|
||||
#undef FORMAT_STRING
|
||||
#if _MSC_VER >= 1400
|
||||
# include <sal.h>
|
||||
# if _MSC_VER > 1400
|
||||
# define FORMAT_STRING(p) _Printf_format_string_ p
|
||||
# else
|
||||
# define FORMAT_STRING(p) __format_string p
|
||||
# endif /* FORMAT_STRING */
|
||||
#include <sal.h>
|
||||
#if _MSC_VER > 1400
|
||||
#define FORMAT_STRING(p) _Printf_format_string_ p
|
||||
#else
|
||||
#define FORMAT_STRING(p) __format_string p
|
||||
#endif /* FORMAT_STRING */
|
||||
#else
|
||||
# define FORMAT_STRING(p) p
|
||||
#define FORMAT_STRING(p) p
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* A normal abort() on windows causes the crucial stack frame to be missing
|
||||
@@ -200,13 +200,19 @@ extern char OSName[256];
|
||||
* It's silly but this works:
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define abort() do { char *crash = NULL; *crash = 'x'; exit(1); } while(0)
|
||||
#define abort() \
|
||||
do \
|
||||
{ \
|
||||
char *crash = NULL; \
|
||||
*crash = 'x'; \
|
||||
exit(1); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef SOMAXCONN
|
||||
# define LISTEN_SIZE (5)
|
||||
#define LISTEN_SIZE (5)
|
||||
#else
|
||||
# define LISTEN_SIZE (SOMAXCONN)
|
||||
#define LISTEN_SIZE (SOMAXCONN)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -214,17 +220,17 @@ extern char OSName[256];
|
||||
* number of files allowed to be open by this process.
|
||||
*/
|
||||
#ifdef RLIMIT_FDMAX
|
||||
# define RLIMIT_FD_MAX RLIMIT_FDMAX
|
||||
#define RLIMIT_FD_MAX RLIMIT_FDMAX
|
||||
#else
|
||||
# ifdef RLIMIT_NOFILE
|
||||
# define RLIMIT_FD_MAX RLIMIT_NOFILE
|
||||
# else
|
||||
# ifdef RLIMIT_OPEN_MAX
|
||||
# define RLIMIT_FD_MAX RLIMIT_OPEN_MAX
|
||||
# else
|
||||
# undef RLIMIT_FD_MAX
|
||||
# endif
|
||||
# endif
|
||||
#ifdef RLIMIT_NOFILE
|
||||
#define RLIMIT_FD_MAX RLIMIT_NOFILE
|
||||
#else
|
||||
#ifdef RLIMIT_OPEN_MAX
|
||||
#define RLIMIT_FD_MAX RLIMIT_OPEN_MAX
|
||||
#else
|
||||
#undef RLIMIT_FD_MAX
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NATIVE_BIG_ENDIAN
|
||||
|
||||
+3
-3
@@ -20,9 +20,9 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef void (*vFP)(); /* Void function pointer */
|
||||
typedef int (*iFP)(); /* Integer function pointer */
|
||||
typedef char (*cFP)(); /* char * function pointer */
|
||||
typedef void (*vFP)(); /* Void function pointer */
|
||||
typedef int (*iFP)(); /* Integer function pointer */
|
||||
typedef char (*cFP)(); /* char * function pointer */
|
||||
|
||||
#ifndef MODVAR
|
||||
#if defined(MODULE_COMPILE) && defined(_WIN32)
|
||||
|
||||
+21
-21
@@ -14,24 +14,24 @@
|
||||
* $ info '(cpp) Stringification'
|
||||
*/
|
||||
#define _macro_to_str(n) #n
|
||||
#define macro_to_str(n) _macro_to_str(n)
|
||||
#define macro_to_str(n) _macro_to_str(n)
|
||||
|
||||
|
||||
/*
|
||||
* Mark of settings
|
||||
*/
|
||||
#ifdef DEBUGMODE
|
||||
#define DEBUGMODESET "+(debug)"
|
||||
#define DEBUGMODESET "+(debug)"
|
||||
#else
|
||||
#define DEBUGMODESET ""
|
||||
#define DEBUGMODESET ""
|
||||
#endif
|
||||
/**/
|
||||
/**/
|
||||
#ifdef DEBUG
|
||||
#define DEBUGSET "(Debug)"
|
||||
#define DEBUGSET "(Debug)"
|
||||
#else
|
||||
#define DEBUGSET ""
|
||||
#define DEBUGSET ""
|
||||
#endif
|
||||
/**/
|
||||
/**/
|
||||
#define COMPILEINFO DEBUGMODESET DEBUGSET
|
||||
|
||||
/* Version info follows
|
||||
@@ -54,20 +54,20 @@
|
||||
* Can be useful if the above 3 versionids are insufficient for you (eg: you want to support CVS).
|
||||
* This is updated automatically on the CVS server every Monday. so don't touch it.
|
||||
*/
|
||||
#define UNREAL_VERSION_TIME 202610
|
||||
#define UNREAL_VERSION_TIME 202610
|
||||
|
||||
#define UNREAL_VERSION ((UNREAL_VERSION_GENERATION << 24) + (UNREAL_VERSION_MAJOR << 16) + (UNREAL_VERSION_MINOR << 8))
|
||||
#define UnrealProtocol 6100
|
||||
#define PATCH1 macro_to_str(UNREAL_VERSION_GENERATION)
|
||||
#define PATCH2 "." macro_to_str(UNREAL_VERSION_MAJOR)
|
||||
#define PATCH3 "." macro_to_str(UNREAL_VERSION_MINOR)
|
||||
#define PATCH4 UNREAL_VERSION_SUFFIX
|
||||
#define PATCH5 ""
|
||||
#define PATCH6 ""
|
||||
#define PATCH7 ""
|
||||
#define PATCH8 COMPILEINFO
|
||||
#define PATCH9 ""
|
||||
#define UNREAL_VERSION ((UNREAL_VERSION_GENERATION << 24) + (UNREAL_VERSION_MAJOR << 16) + (UNREAL_VERSION_MINOR << 8))
|
||||
#define UnrealProtocol 6100
|
||||
#define PATCH1 macro_to_str(UNREAL_VERSION_GENERATION)
|
||||
#define PATCH2 "." macro_to_str(UNREAL_VERSION_MAJOR)
|
||||
#define PATCH3 "." macro_to_str(UNREAL_VERSION_MINOR)
|
||||
#define PATCH4 UNREAL_VERSION_SUFFIX
|
||||
#define PATCH5 ""
|
||||
#define PATCH6 ""
|
||||
#define PATCH7 ""
|
||||
#define PATCH8 COMPILEINFO
|
||||
#define PATCH9 ""
|
||||
/* release header */
|
||||
#define Rh BASE_VERSION
|
||||
#define VERSIONONLY PATCH1 PATCH2 PATCH3 PATCH4 PATCH5 PATCH6 PATCH7
|
||||
#define Rh BASE_VERSION
|
||||
#define VERSIONONLY PATCH1 PATCH2 PATCH3 PATCH4 PATCH5 PATCH6 PATCH7
|
||||
#endif /* __versioninclude */
|
||||
|
||||
+7
-7
@@ -32,16 +32,16 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __whowas_include__
|
||||
#ifndef __whowas_include__
|
||||
#define __whowas_include__
|
||||
|
||||
/* NOTE: Don't reorder values of these, as they are used in whowasdb */
|
||||
typedef enum WhoWasEvent {
|
||||
WHOWAS_EVENT_QUIT=0,
|
||||
WHOWAS_EVENT_NICK_CHANGE=1,
|
||||
WHOWAS_EVENT_SERVER_TERMINATING=2
|
||||
WHOWAS_EVENT_QUIT = 0,
|
||||
WHOWAS_EVENT_NICK_CHANGE = 1,
|
||||
WHOWAS_EVENT_SERVER_TERMINATING = 2
|
||||
} WhoWasEvent;
|
||||
#define WHOWAS_LOWEST_EVENT 0
|
||||
#define WHOWAS_LOWEST_EVENT 0
|
||||
#define WHOWAS_HIGHEST_EVENT 2
|
||||
|
||||
/*
|
||||
@@ -69,8 +69,8 @@ void off_history(Client *);
|
||||
** one found...
|
||||
*/
|
||||
Client *get_history(const char *, time_t);
|
||||
/* Nick name */
|
||||
/* Time limit in seconds */
|
||||
/* Nick name */
|
||||
/* Time limit in seconds */
|
||||
|
||||
/*
|
||||
** for debugging...counts related structures stored in whowas array.
|
||||
|
||||
+13
-13
@@ -22,25 +22,25 @@
|
||||
#ifndef __setup_include__
|
||||
#define __setup_include__
|
||||
|
||||
#undef SYSSYSLOGH
|
||||
#undef SYSSYSLOGH
|
||||
#define NOINDEX
|
||||
#undef TIMES_2
|
||||
#undef GETRUSAGE_2
|
||||
#define CONFDIR "conf"
|
||||
#define MODULESDIR "modules"
|
||||
#define LOGDIR "logs"
|
||||
#undef TIMES_2
|
||||
#undef GETRUSAGE_2
|
||||
#define CONFDIR "conf"
|
||||
#define MODULESDIR "modules"
|
||||
#define LOGDIR "logs"
|
||||
#define PERMDATADIR "data"
|
||||
#define CACHEDIR "cache"
|
||||
#define TMPDIR "tmp"
|
||||
#define PIDFILE PERMDATADIR"/unrealircd.pid"
|
||||
#define CONTROLFILE PERMDATADIR"/unrealircd.ctl"
|
||||
#define CACHEDIR "cache"
|
||||
#define TMPDIR "tmp"
|
||||
#define PIDFILE PERMDATADIR "/unrealircd.pid"
|
||||
#define CONTROLFILE PERMDATADIR "/unrealircd.ctl"
|
||||
#define NO_U_TYPES
|
||||
#define NEED_U_INT32_T
|
||||
#define strcasecmp _stricmp
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define HAVE_EXPLICIT_BZERO
|
||||
#define HAVE_STRNLEN
|
||||
#define explicit_bzero(a,b) SecureZeroMemory(a,b)
|
||||
#define explicit_bzero(a, b) SecureZeroMemory(a, b)
|
||||
#define HAS_ASN1_TIME_diff
|
||||
#define HAS_SSL_CTX_SET1_CURVES_LIST
|
||||
#define HAS_SSL_CTX_SET_MIN_PROTO_VERSION
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
/* We require Windows 7 or later */
|
||||
#define NTDDI_VERSION 0x06010000
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#define _WIN32_WINNT 0x0601
|
||||
|
||||
/* What geoip engine to use */
|
||||
#define GEOIP_ENGINE "geoip_mmdb"
|
||||
|
||||
+62
-71
@@ -20,24 +20,28 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
/* Function to return a group of tokens -- codemastr */
|
||||
void strrangetok(char *in, char *out, char tok, short first, short last) {
|
||||
void strrangetok(char *in, char *out, char tok, short first, short last)
|
||||
{
|
||||
int i = 0, tokcount = 0, j = 0;
|
||||
first--;
|
||||
last--;
|
||||
while(in[i]) {
|
||||
if (in[i] == tok) {
|
||||
while (in[i])
|
||||
{
|
||||
if (in[i] == tok)
|
||||
{
|
||||
tokcount++;
|
||||
if (tokcount == first)
|
||||
i++;
|
||||
}
|
||||
if (tokcount >= first && (tokcount <= last || last == -1)) {
|
||||
if (tokcount >= first && (tokcount <= last || last == -1))
|
||||
{
|
||||
out[j] = in[i];
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
out[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* cmd_alias is a special type of command, it has an extra argument 'cmd'. */
|
||||
static int recursive_alias = 0;
|
||||
@@ -49,13 +53,13 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
int ret;
|
||||
char request[BUFSIZE];
|
||||
|
||||
if (!(alias = find_alias(cmd)))
|
||||
if (!(alias = find_alias(cmd)))
|
||||
{
|
||||
sendto_one(client, NULL, ":%s %d %s %s :Unknown command",
|
||||
me.name, ERR_UNKNOWNCOMMAND, client->name, cmd);
|
||||
me.name, ERR_UNKNOWNCOMMAND, client->name, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* If it isn't an ALIAS_COMMAND, we require a paramter ... We check ALIAS_COMMAND LATER */
|
||||
if (alias->type != ALIAS_COMMAND && (parc < 2 || *parv[1] == '\0'))
|
||||
{
|
||||
@@ -63,48 +67,42 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
return;
|
||||
}
|
||||
|
||||
if (alias->type == ALIAS_SERVICES)
|
||||
if (alias->type == ALIAS_SERVICES)
|
||||
{
|
||||
if (SERVICES_NAME && (acptr = find_user(alias->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, parv[1], SPAMF_USERMSG, cmd, alias->nick, 0, clictx, NULL))
|
||||
return;
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s@%s :%s", client->name,
|
||||
alias->nick, SERVICES_NAME, parv[1]);
|
||||
}
|
||||
else
|
||||
alias->nick, SERVICES_NAME, parv[1]);
|
||||
} else
|
||||
sendnumeric(client, ERR_SERVICESDOWN, alias->nick);
|
||||
}
|
||||
else if (alias->type == ALIAS_STATS)
|
||||
} else if (alias->type == ALIAS_STATS)
|
||||
{
|
||||
if (STATS_SERVER && (acptr = find_user(alias->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, parv[1], SPAMF_USERMSG, cmd, alias->nick, 0, clictx, NULL))
|
||||
return;
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s@%s :%s", client->name,
|
||||
alias->nick, STATS_SERVER, parv[1]);
|
||||
}
|
||||
else
|
||||
alias->nick, STATS_SERVER, parv[1]);
|
||||
} else
|
||||
sendnumeric(client, ERR_SERVICESDOWN, alias->nick);
|
||||
}
|
||||
else if (alias->type == ALIAS_NORMAL)
|
||||
} else if (alias->type == ALIAS_NORMAL)
|
||||
{
|
||||
if ((acptr = find_user(alias->nick, NULL)))
|
||||
if ((acptr = find_user(alias->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, parv[1], SPAMF_USERMSG, cmd, alias->nick, 0, clictx, NULL))
|
||||
return;
|
||||
if (MyUser(acptr))
|
||||
sendto_one(acptr, NULL, ":%s!%s@%s PRIVMSG %s :%s", client->name,
|
||||
client->user->username, GetHost(client),
|
||||
alias->nick, parv[1]);
|
||||
sendto_one(acptr, NULL, ":%s!%s@%s PRIVMSG %s :%s", client->name,
|
||||
client->user->username, GetHost(client),
|
||||
alias->nick, parv[1]);
|
||||
else
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s :%s", client->name,
|
||||
alias->nick, parv[1]);
|
||||
}
|
||||
else
|
||||
alias->nick, parv[1]);
|
||||
} else
|
||||
sendnumeric(client, ERR_NOSUCHNICK, alias->nick);
|
||||
}
|
||||
else if (alias->type == ALIAS_CHANNEL)
|
||||
} else if (alias->type == ALIAS_CHANNEL)
|
||||
{
|
||||
Channel *channel;
|
||||
if ((channel = find_channel(alias->nick)))
|
||||
@@ -118,7 +116,7 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
{
|
||||
new_message(client, NULL, &mtags);
|
||||
sendto_channel(channel, client, client->direction,
|
||||
NULL, 0, SEND_ALL|SKIP_DEAF, mtags,
|
||||
NULL, 0, SEND_ALL | SKIP_DEAF, mtags,
|
||||
":%s PRIVMSG %s :%s",
|
||||
client->name, channel->name, parv[1]);
|
||||
free_message_tags(mtags);
|
||||
@@ -128,9 +126,8 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
if (IsDead(client))
|
||||
return;
|
||||
sendnumeric(client, ERR_CANNOTDOCOMMAND,
|
||||
cmd, "You may not use this command at this time");
|
||||
}
|
||||
else if (alias->type == ALIAS_COMMAND)
|
||||
cmd, "You may not use this command at this time");
|
||||
} else if (alias->type == ALIAS_COMMAND)
|
||||
{
|
||||
ConfigItem_alias_format *format;
|
||||
char *ptr = "";
|
||||
@@ -153,42 +150,41 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
memset(current, 0, sizeof(current));
|
||||
memset(output, 0, sizeof(output));
|
||||
|
||||
while(format->parameters[i] && j < 500)
|
||||
while (format->parameters[i] && j < 500)
|
||||
{
|
||||
k = 0;
|
||||
if (format->parameters[i] == '%')
|
||||
if (format->parameters[i] == '%')
|
||||
{
|
||||
i++;
|
||||
if (format->parameters[i] == '%')
|
||||
if (format->parameters[i] == '%')
|
||||
output[j++] = '%';
|
||||
else if (isdigit(format->parameters[i]))
|
||||
else if (isdigit(format->parameters[i]))
|
||||
{
|
||||
for(; isdigit(format->parameters[i]) && k < 2; i++, k++) {
|
||||
for (; isdigit(format->parameters[i]) && k < 2; i++, k++)
|
||||
{
|
||||
nums[k] = format->parameters[i];
|
||||
}
|
||||
nums[k] = 0;
|
||||
i--;
|
||||
if (format->parameters[i+1] == '-') {
|
||||
strrangetok(ptr, current, ' ', atoi(nums),0);
|
||||
if (format->parameters[i + 1] == '-')
|
||||
{
|
||||
strrangetok(ptr, current, ' ', atoi(nums), 0);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
strrangetok(ptr, current, ' ', atoi(nums), atoi(nums));
|
||||
if (!*current)
|
||||
continue;
|
||||
if (j + strlen(current)+1 >= 500)
|
||||
if (j + strlen(current) + 1 >= 500)
|
||||
break;
|
||||
strlcat(output, current, sizeof output);
|
||||
j += strlen(current);
|
||||
|
||||
}
|
||||
else if (format->parameters[i] == 'n' ||
|
||||
format->parameters[i] == 'N')
|
||||
|
||||
} else if (format->parameters[i] == 'n' ||
|
||||
format->parameters[i] == 'N')
|
||||
{
|
||||
strlcat(output, client->name, sizeof output);
|
||||
j += strlen(client->name);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
output[j++] = '%';
|
||||
output[j++] = format->parameters[i];
|
||||
@@ -205,47 +201,43 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
sendnumeric(client, ERR_NEEDMOREPARAMS, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (format->type == ALIAS_SERVICES)
|
||||
|
||||
if (format->type == ALIAS_SERVICES)
|
||||
{
|
||||
if (SERVICES_NAME && (acptr = find_user(format->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, output, SPAMF_USERMSG, cmd, format->nick, 0, clictx, NULL))
|
||||
return;
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s@%s :%s", client->name,
|
||||
format->nick, SERVICES_NAME, output);
|
||||
format->nick, SERVICES_NAME, output);
|
||||
} else
|
||||
sendnumeric(client, ERR_SERVICESDOWN, format->nick);
|
||||
}
|
||||
else if (format->type == ALIAS_STATS)
|
||||
} else if (format->type == ALIAS_STATS)
|
||||
{
|
||||
if (STATS_SERVER && (acptr = find_user(format->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, output, SPAMF_USERMSG, cmd, format->nick, 0, clictx, NULL))
|
||||
return;
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s@%s :%s", client->name,
|
||||
format->nick, STATS_SERVER, output);
|
||||
format->nick, STATS_SERVER, output);
|
||||
} else
|
||||
sendnumeric(client, ERR_SERVICESDOWN, format->nick);
|
||||
}
|
||||
else if (format->type == ALIAS_NORMAL)
|
||||
} else if (format->type == ALIAS_NORMAL)
|
||||
{
|
||||
if ((acptr = find_user(format->nick, NULL)))
|
||||
if ((acptr = find_user(format->nick, NULL)))
|
||||
{
|
||||
if (alias->spamfilter && match_spamfilter(client, output, SPAMF_USERMSG, cmd, format->nick, 0, clictx, NULL))
|
||||
return;
|
||||
if (MyUser(acptr))
|
||||
sendto_one(acptr, NULL, ":%s!%s@%s PRIVMSG %s :%s", client->name,
|
||||
client->user->username, IsHidden(client) ? client->user->virthost : client->user->realhost,
|
||||
format->nick, output);
|
||||
sendto_one(acptr, NULL, ":%s!%s@%s PRIVMSG %s :%s", client->name,
|
||||
client->user->username, IsHidden(client) ? client->user->virthost : client->user->realhost,
|
||||
format->nick, output);
|
||||
else
|
||||
sendto_one(acptr, NULL, ":%s PRIVMSG %s :%s", client->name,
|
||||
format->nick, output);
|
||||
}
|
||||
else
|
||||
format->nick, output);
|
||||
} else
|
||||
sendnumeric(client, ERR_NOSUCHNICK, format->nick);
|
||||
}
|
||||
else if (format->type == ALIAS_CHANNEL)
|
||||
} else if (format->type == ALIAS_CHANNEL)
|
||||
{
|
||||
Channel *channel;
|
||||
if ((channel = find_channel(format->nick)))
|
||||
@@ -255,11 +247,11 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
/* FIXME: when can_send_to_channel() gets 'int flags', pass
|
||||
* alias->spamfilter ? 0 : CAN_SEND_SKIP_SPAMFILTER
|
||||
*/
|
||||
if (can_send_to_channel(client, channel, &msg, &errmsg, 0, clictx))
|
||||
if (can_send_to_channel(client, channel, &msg, &errmsg, 0, clictx))
|
||||
{
|
||||
new_message(client, NULL, &mtags);
|
||||
sendto_channel(channel, client, client->direction,
|
||||
NULL, 0, SEND_ALL|SKIP_DEAF, mtags,
|
||||
NULL, 0, SEND_ALL | SKIP_DEAF, mtags,
|
||||
":%s PRIVMSG %s :%s",
|
||||
client->name, channel->name, parv[1]);
|
||||
free_message_tags(mtags);
|
||||
@@ -269,13 +261,12 @@ void cmd_alias(ClientContext *clictx, Client *client, MessageTag *mtags, int par
|
||||
if (IsDead(client))
|
||||
return;
|
||||
sendnumeric(client, ERR_CANNOTDOCOMMAND, cmd,
|
||||
"You may not use this command at this time");
|
||||
}
|
||||
else if (format->type == ALIAS_REAL)
|
||||
"You may not use this command at this time");
|
||||
} else if (format->type == ALIAS_REAL)
|
||||
{
|
||||
int ret;
|
||||
char mybuf[500];
|
||||
|
||||
|
||||
snprintf(mybuf, sizeof(mybuf), "%s %s", format->nick, output);
|
||||
|
||||
if (recursive_alias)
|
||||
|
||||
+10
-8
@@ -37,9 +37,9 @@ APICallback *APICallbackAdd(Module *module, APICallback *mreq)
|
||||
if (!mreq->callback_type)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "API_CALLBACK_ADD_API_ERROR", NULL,
|
||||
"APICallbackAdd() from module $module_name: "
|
||||
"Missing required fields.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"APICallbackAdd() from module $module_name: "
|
||||
"Missing required fields.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -49,12 +49,14 @@ APICallback *APICallbackAdd(Module *module, APICallback *mreq)
|
||||
if (m->unloaded)
|
||||
{
|
||||
m->unloaded = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* New API callback */
|
||||
m = safe_alloc(sizeof(APICallback));
|
||||
safe_strdup(m->name, mreq->name);
|
||||
@@ -177,9 +179,9 @@ void print_apicallbacks(void)
|
||||
{
|
||||
m_next = m->next;
|
||||
unreal_log(ULOG_DEBUG, "module", "API_CALLBACK_LIST", NULL,
|
||||
"$name ($deleted)",
|
||||
log_data_string("name", m->name),
|
||||
log_data_string("deleted", m->unloaded ? "deleted" : ""));
|
||||
"$name ($deleted)",
|
||||
log_data_string("name", m->name),
|
||||
log_data_string("deleted", m->unloaded ? "deleted" : ""));
|
||||
}
|
||||
unreal_log(ULOG_DEBUG, "module", "API_CALLBACK_LIST", NULL, "----");
|
||||
}
|
||||
|
||||
+66
-65
@@ -47,7 +47,7 @@ char extchmstr[4][64];
|
||||
static void make_cmodestr(void);
|
||||
static char previous_chanmodes[256];
|
||||
static char previous_prefix[256];
|
||||
static Cmode *ParamTable[MAXPARAMMODES+1];
|
||||
static Cmode *ParamTable[MAXPARAMMODES + 1];
|
||||
static void unload_extcmode_commit(Cmode *cmode);
|
||||
|
||||
/** Create the strings that are used for CHANMODES=a,b,c,d in numeric 005 */
|
||||
@@ -56,29 +56,29 @@ void make_extcmodestr()
|
||||
char *p;
|
||||
Cmode *cm;
|
||||
int i;
|
||||
|
||||
|
||||
extchmstr[0][0] = extchmstr[1][0] = extchmstr[2][0] = extchmstr[3][0] = '\0';
|
||||
|
||||
|
||||
/* type 1: lists (like b/e) */
|
||||
/* [NOT IMPLEMENTED IN EXTCMODES] */
|
||||
|
||||
/* type 2: 1 par to set/unset (has .unset_with_param) */
|
||||
p = extchmstr[1];
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (cm->paracount && cm->letter && cm->unset_with_param && (cm->type != CMODE_MEMBER))
|
||||
*p++ = cm->letter;
|
||||
*p = '\0';
|
||||
|
||||
/* type 3: 1 param to set, 0 params to unset (does not have .unset_with_param) */
|
||||
p = extchmstr[2];
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (cm->paracount && cm->letter && !cm->unset_with_param)
|
||||
*p++ = cm->letter;
|
||||
*p = '\0';
|
||||
|
||||
|
||||
/* type 4: paramless modes */
|
||||
p = extchmstr[3];
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (!cm->paracount && cm->letter)
|
||||
*p++ = cm->letter;
|
||||
*p = '\0';
|
||||
@@ -97,7 +97,7 @@ static void make_cmodestr(void)
|
||||
p++;
|
||||
tab++;
|
||||
}
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (cm->letter)
|
||||
*p++ = cm->letter;
|
||||
*p = '\0';
|
||||
@@ -134,9 +134,9 @@ void extcmodes_check_for_changed_channel_modes(void)
|
||||
strlcpy(previous_chanmodes, chanmodes, sizeof(previous_chanmodes));
|
||||
return; /* not booted yet. then we are done here. */
|
||||
}
|
||||
|
||||
|
||||
ISupportSetValue(isup, chanmodes);
|
||||
|
||||
|
||||
if (*previous_chanmodes && strcmp(chanmodes, previous_chanmodes))
|
||||
{
|
||||
unreal_log(ULOG_INFO, "mode", "CHANNEL_MODES_CHANGED", NULL,
|
||||
@@ -161,7 +161,7 @@ void make_prefix(char **isupport_prefix, char **isupport_statusmsg)
|
||||
|
||||
*prefix = *prefix_prefix = *prefix_modes = '\0';
|
||||
|
||||
for (n=0, cm=channelmodes; cm && n < ARRAY_SIZEOF(rank)-1; cm = cm->next)
|
||||
for (n = 0, cm = channelmodes; cm && n < ARRAY_SIZEOF(rank) - 1; cm = cm->next)
|
||||
{
|
||||
if ((cm->type == CMODE_MEMBER) && cm->letter)
|
||||
{
|
||||
@@ -176,9 +176,9 @@ void make_prefix(char **isupport_prefix, char **isupport_statusmsg)
|
||||
{
|
||||
int i, j;
|
||||
/* Now sort the damn thing */
|
||||
for (i=0; i < n; i++)
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
for (j=i+1; j < n; j++)
|
||||
for (j = i + 1; j < n; j++)
|
||||
{
|
||||
if (rank[i] < rank[j])
|
||||
{
|
||||
@@ -314,7 +314,7 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
int existing = 0;
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
{
|
||||
if (cm->letter == req.letter)
|
||||
{
|
||||
@@ -323,7 +323,8 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
cm->unloaded = 0;
|
||||
existing = 1;
|
||||
break;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
@@ -338,10 +339,10 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
|
||||
if (req.type == CMODE_NORMAL)
|
||||
{
|
||||
for (l = 1; l < ULLONG_MAX/2; l *= 2)
|
||||
for (l = 1; l < ULLONG_MAX / 2; l *= 2)
|
||||
{
|
||||
found = 0;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
{
|
||||
if (cm->mode == l)
|
||||
{
|
||||
@@ -356,7 +357,7 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
if (found)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "CHANNEL_MODE_OUT_OF_SPACE", NULL,
|
||||
"CmodeAdd: out of space!!!");
|
||||
"CmodeAdd: out of space!!!");
|
||||
if (module)
|
||||
module->errorcode = MODERR_NOSPACE;
|
||||
return NULL;
|
||||
@@ -371,15 +372,16 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
!req.unset_with_param || !req.rank)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "CMODEADD_API_ERROR", NULL,
|
||||
"CmodeAdd(): module is missing required information. "
|
||||
"Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"CmodeAdd(): module is missing required information. "
|
||||
"Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
module->errorcode = MODERR_INVALID;
|
||||
return NULL;
|
||||
}
|
||||
cm = safe_alloc(sizeof(Cmode));
|
||||
cm->letter = req.letter;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
channelmode_add_sorted(cm);
|
||||
@@ -391,8 +393,7 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
{
|
||||
/* Re-use parameter slot of the module with the same modechar that is unloading */
|
||||
paraslot = cm->param_slot;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* Allocate a new one */
|
||||
for (paraslot = 0; ParamTable[paraslot]; paraslot++)
|
||||
@@ -400,7 +401,7 @@ Cmode *CmodeAdd(Module *module, CmodeInfo req, Cmode_t *mode)
|
||||
if (paraslot == MAXPARAMMODES - 1)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "CHANNEL_MODE_OUT_OF_SPACE", NULL,
|
||||
"CmodeAdd: out of space!!! Place 2.");
|
||||
"CmodeAdd: out of space!!! Place 2.");
|
||||
if (module)
|
||||
module->errorcode = MODERR_NOSPACE;
|
||||
return NULL;
|
||||
@@ -455,8 +456,10 @@ void CmodeDel(Cmode *cmode)
|
||||
if (cmode->owner)
|
||||
{
|
||||
ModuleObject *cmodeobj;
|
||||
for (cmodeobj = cmode->owner->objects; cmodeobj; cmodeobj = cmodeobj->next) {
|
||||
if (cmodeobj->type == MOBJ_CMODE && cmodeobj->object.cmode == cmode) {
|
||||
for (cmodeobj = cmode->owner->objects; cmodeobj; cmodeobj = cmodeobj->next)
|
||||
{
|
||||
if (cmodeobj->type == MOBJ_CMODE && cmodeobj->object.cmode == cmode)
|
||||
{
|
||||
DelListItem(cmodeobj, cmode->owner->objects);
|
||||
safe_free(cmodeobj);
|
||||
break;
|
||||
@@ -468,7 +471,6 @@ void CmodeDel(Cmode *cmode)
|
||||
cmode->unloaded = 1;
|
||||
else
|
||||
unload_extcmode_commit(cmode);
|
||||
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -498,11 +500,11 @@ static void unload_extcmode_commit(Cmode *cmode)
|
||||
|
||||
new_message(&me, NULL, &mtags);
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s -%c",
|
||||
me.name, channel->name, cmode->letter);
|
||||
":%s MODE %s -%c",
|
||||
me.name, channel->name, cmode->letter);
|
||||
sendto_server(NULL, 0, 0, mtags,
|
||||
":%s MODE %s -%c 0",
|
||||
me.id, channel->name, cmode->letter);
|
||||
":%s MODE %s -%c 0",
|
||||
me.id, channel->name, cmode->letter);
|
||||
free_message_tags(mtags);
|
||||
|
||||
channel->mode.mode &= ~cmode->mode;
|
||||
@@ -522,18 +524,19 @@ static void unload_extcmode_commit(Cmode *cmode)
|
||||
{
|
||||
const char *param = cmode->get_param(GETPARASTRUCT(channel, cmode->letter));
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s -%c %s",
|
||||
me.name, channel->name, cmode->letter, param);
|
||||
":%s MODE %s -%c %s",
|
||||
me.name, channel->name, cmode->letter, param);
|
||||
sendto_server(NULL, 0, 0, mtags,
|
||||
":%s MODE %s -%c %s 0",
|
||||
me.id, channel->name, cmode->letter, param);
|
||||
} else {
|
||||
":%s MODE %s -%c %s 0",
|
||||
me.id, channel->name, cmode->letter, param);
|
||||
} else
|
||||
{
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s -%c",
|
||||
me.name, channel->name, cmode->letter);
|
||||
":%s MODE %s -%c",
|
||||
me.name, channel->name, cmode->letter);
|
||||
sendto_server(NULL, 0, 0, mtags,
|
||||
":%s MODE %s -%c 0",
|
||||
me.id, channel->name, cmode->letter);
|
||||
":%s MODE %s -%c 0",
|
||||
me.id, channel->name, cmode->letter);
|
||||
}
|
||||
free_message_tags(mtags);
|
||||
|
||||
@@ -543,8 +546,7 @@ static void unload_extcmode_commit(Cmode *cmode)
|
||||
}
|
||||
extcmode_para_delslot(cmode, cmode->param_slot);
|
||||
}
|
||||
} else
|
||||
if (cmode->type == CMODE_MEMBER)
|
||||
} else if (cmode->type == CMODE_MEMBER)
|
||||
{
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
@@ -557,11 +559,11 @@ static void unload_extcmode_commit(Cmode *cmode)
|
||||
|
||||
new_message(&me, NULL, &mtags);
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s -%c %s",
|
||||
me.name, channel->name, cmode->letter, m->client->name);
|
||||
":%s MODE %s -%c %s",
|
||||
me.name, channel->name, cmode->letter, m->client->name);
|
||||
sendto_server(NULL, 0, 0, mtags,
|
||||
":%s MODE %s -%c %s 0",
|
||||
me.id, channel->name, cmode->letter, m->client->id);
|
||||
":%s MODE %s -%c %s 0",
|
||||
me.id, channel->name, cmode->letter, m->client->id);
|
||||
free_message_tags(mtags);
|
||||
del_member_mode(m->client, channel, cmode->letter);
|
||||
}
|
||||
@@ -578,7 +580,7 @@ void unload_all_unused_extcmodes(void)
|
||||
{
|
||||
Cmode *cm, *cm_next;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm_next)
|
||||
for (cm = channelmodes; cm; cm = cm_next)
|
||||
{
|
||||
cm_next = cm->next;
|
||||
if (cm->letter && cm->unloaded)
|
||||
@@ -586,7 +588,6 @@ void unload_all_unused_extcmodes(void)
|
||||
unload_extcmode_commit(cm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @defgroup ChannelModeAPI Channel mode API
|
||||
@@ -729,7 +730,7 @@ int module_has_extcmode_param_mode(Module *mod)
|
||||
{
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->letter) && (cm->owner == mod) && (cm->paracount))
|
||||
return 1;
|
||||
|
||||
@@ -862,7 +863,7 @@ Cmode *find_channel_mode_handler(char letter)
|
||||
{
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (cm->letter == letter)
|
||||
return cm;
|
||||
return NULL;
|
||||
@@ -895,7 +896,7 @@ void addlettertomstring(char *str, char letter)
|
||||
my_rank = cm->rank;
|
||||
|
||||
n = strlen(str);
|
||||
if (n >= MEMBERMODESLEN-1)
|
||||
if (n >= MEMBERMODESLEN - 1)
|
||||
return; // panic!
|
||||
|
||||
for (p = str; *p; p++)
|
||||
@@ -907,14 +908,14 @@ void addlettertomstring(char *str, char letter)
|
||||
{
|
||||
/* We need to insert us here */
|
||||
n = strlen(p);
|
||||
memmove(p+1, p, n+1); // +1 for NUL byte
|
||||
memmove(p + 1, p, n + 1); // +1 for NUL byte
|
||||
*p = letter;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* We should be at the end */
|
||||
str[n] = letter;
|
||||
str[n+1] = '\0';
|
||||
str[n + 1] = '\0';
|
||||
}
|
||||
|
||||
void add_member_mode_fast(Member *mb, Membership *mbs, char letter)
|
||||
@@ -981,7 +982,7 @@ char sjoin_prefix_to_mode(char s)
|
||||
return 'I';
|
||||
|
||||
/* Now the dynamic ones (+vhoaq): */
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->sjoin_prefix == s) && (cm->type == CMODE_MEMBER))
|
||||
return cm->letter;
|
||||
|
||||
@@ -1006,7 +1007,7 @@ char mode_to_sjoin_prefix(char s)
|
||||
return '\'';
|
||||
|
||||
/* Now the dynamic ones (+vhoaq): */
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->letter == s) && (cm->type == CMODE_MEMBER))
|
||||
return cm->sjoin_prefix;
|
||||
|
||||
@@ -1040,7 +1041,7 @@ char mode_to_prefix(char s)
|
||||
return '\0';
|
||||
|
||||
/* Now the dynamic ones (+vhoaq): */
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->letter == s) && (cm->type == CMODE_MEMBER))
|
||||
return cm->prefix;
|
||||
|
||||
@@ -1074,7 +1075,7 @@ char prefix_to_mode(char s)
|
||||
return '\0';
|
||||
|
||||
/* Now the dynamic ones (+vhoaq): */
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->prefix == s) && (cm->type == CMODE_MEMBER))
|
||||
return cm->letter;
|
||||
|
||||
@@ -1085,7 +1086,7 @@ char prefix_to_mode(char s)
|
||||
char rank_to_mode(int rank)
|
||||
{
|
||||
Cmode *cm;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->rank == rank))
|
||||
return cm->letter;
|
||||
return '\0';
|
||||
@@ -1094,7 +1095,7 @@ char rank_to_mode(int rank)
|
||||
int mode_to_rank(char mode)
|
||||
{
|
||||
Cmode *cm;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->letter == mode))
|
||||
return cm->rank;
|
||||
return '\0';
|
||||
@@ -1103,7 +1104,7 @@ int mode_to_rank(char mode)
|
||||
int prefix_to_rank(char prefix)
|
||||
{
|
||||
Cmode *cm;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->prefix == prefix))
|
||||
return cm->rank;
|
||||
return '\0';
|
||||
@@ -1112,7 +1113,7 @@ int prefix_to_rank(char prefix)
|
||||
char rank_to_prefix(int rank)
|
||||
{
|
||||
Cmode *cm;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->rank == rank))
|
||||
return cm->prefix;
|
||||
return '\0';
|
||||
@@ -1168,9 +1169,9 @@ void channel_member_modes_generate_equal_or_greater(const char *modes, char *buf
|
||||
if (!rank)
|
||||
return; /* zero matches */
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->rank >= rank))
|
||||
strlcat_letter(buf, cm->letter, buflen);
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->type == CMODE_MEMBER) && (cm->rank >= rank))
|
||||
strlcat_letter(buf, cm->letter, buflen);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
+12
-9
@@ -27,7 +27,7 @@
|
||||
* If exceeded, the caps just won't be stored and will be re-added safely. --k4be
|
||||
*/
|
||||
|
||||
#define MAXCLICAPS ((int)(sizeof(long)*8 - 1 + ADVERTISEONLYCAPS)) /* how many cap bits will fit in `long`? */
|
||||
#define MAXCLICAPS ((int)(sizeof(long) * 8 - 1 + ADVERTISEONLYCAPS)) /* how many cap bits will fit in `long`? */
|
||||
static char *old_caps[MAXCLICAPS]; /**< List of old CAP names - used for /rehash */
|
||||
int old_caps_proto[MAXCLICAPS]; /**< List of old CAP protocol values - used for /rehash */
|
||||
|
||||
@@ -116,7 +116,7 @@ long clicap_allocate_cap(void)
|
||||
ClientCapability *clicap;
|
||||
|
||||
/* The first bit (v=1) is used by the "invert" marker */
|
||||
for (v=2; v; v <<= 1)
|
||||
for (v = 2; v; v <<= 1)
|
||||
{
|
||||
unsigned char found = 0;
|
||||
for (clicap = clicaps; clicap; clicap = clicap->next)
|
||||
@@ -172,12 +172,14 @@ ClientCapability *ClientCapabilityAdd(Module *module, ClientCapabilityInfo *clic
|
||||
if (clicap->unloaded)
|
||||
{
|
||||
clicap->unloaded = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
long v = 0;
|
||||
|
||||
/* Allocate a bit, but only if the module needs it.
|
||||
@@ -256,7 +258,6 @@ void unload_clicap_commit(ClientCapability *clicap)
|
||||
safe_free(clicap->name);
|
||||
safe_free(clicap);
|
||||
clicap_update_affecting();
|
||||
|
||||
}
|
||||
/** Remove a client capability.
|
||||
* @param clicap The client capability to remove.
|
||||
@@ -268,8 +269,10 @@ void ClientCapabilityDel(ClientCapability *clicap)
|
||||
if (clicap->owner)
|
||||
{
|
||||
ModuleObject *mobj;
|
||||
for (mobj = clicap->owner->objects; mobj; mobj = mobj->next) {
|
||||
if (mobj->type == MOBJ_CLICAP && mobj->object.clicap == clicap) {
|
||||
for (mobj = clicap->owner->objects; mobj; mobj = mobj->next)
|
||||
{
|
||||
if (mobj->type == MOBJ_CLICAP && mobj->object.clicap == clicap)
|
||||
{
|
||||
DelListItem(mobj, clicap->owner->objects);
|
||||
safe_free(mobj);
|
||||
break;
|
||||
@@ -302,13 +305,13 @@ void clicap_pre_rehash(void)
|
||||
ClientCapability *clicap;
|
||||
int i = 0;
|
||||
|
||||
for (i=0; i < MAXCLICAPS; i++)
|
||||
for (i = 0; i < MAXCLICAPS; i++)
|
||||
{
|
||||
safe_free(old_caps[i]);
|
||||
old_caps_proto[i] = 0;
|
||||
}
|
||||
|
||||
for (i=0, clicap = clicaps; clicap; clicap = clicap->next)
|
||||
for (i = 0, clicap = clicaps; clicap; clicap = clicap->next)
|
||||
{
|
||||
if (i == MAXCLICAPS)
|
||||
{
|
||||
|
||||
+9
-9
@@ -35,7 +35,7 @@ static RealCommand *add_Command_backend(const char *cmd);
|
||||
int CommandExists(const char *name)
|
||||
{
|
||||
RealCommand *p;
|
||||
|
||||
|
||||
for (p = CommandHash[toupper(*name)]; p; p = p->next)
|
||||
{
|
||||
if (!strcasecmp(p->cmd, name))
|
||||
@@ -95,7 +95,7 @@ static Command *CommandAddInternal(Module *module, const char *cmd, CmdFunc func
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (!flags)
|
||||
{
|
||||
config_error("CommandAdd(): Could not add command '%s': flags are 0", cmd);
|
||||
@@ -103,7 +103,7 @@ static Command *CommandAddInternal(Module *module, const char *cmd, CmdFunc func
|
||||
module->errorcode = MODERR_INVALID;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
c = add_Command_backend(cmd);
|
||||
c->parameters = (params > MAXPARA) ? MAXPARA : params;
|
||||
c->flags = flags;
|
||||
@@ -144,7 +144,7 @@ void CommandDelX(Command *command, RealCommand *cmd)
|
||||
{
|
||||
if (cmdobj->type == MOBJ_COMMAND && cmdobj->object.command == command)
|
||||
{
|
||||
DelListItem(cmdobj,cmd->owner->objects);
|
||||
DelListItem(cmdobj, cmd->owner->objects);
|
||||
safe_free(cmdobj);
|
||||
break;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void do_cmd(Client *client, MessageTag *mtags, const char *cmd, int parc, const
|
||||
new_message(client, NULL, &mtags);
|
||||
memset(&clictx, 0, sizeof(clictx));
|
||||
clictx.cmd = cmptr;
|
||||
(*cmptr->func) (&clictx, client, mtags, parc, parv);
|
||||
(*cmptr->func)(&clictx, client, mtags, parc, parv);
|
||||
if (gen_mtags)
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
@@ -228,11 +228,11 @@ RealCommand *CommandHash[256]; /* one per letter */
|
||||
void init_CommandHash(void)
|
||||
{
|
||||
memset(CommandHash, 0, sizeof(CommandHash));
|
||||
CommandAdd(NULL, MSG_ERROR, cmd_error, MAXPARA, CMD_UNREGISTERED|CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_VERSION, cmd_version, MAXPARA, CMD_UNREGISTERED|CMD_USER|CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_ERROR, cmd_error, MAXPARA, CMD_UNREGISTERED | CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_VERSION, cmd_version, MAXPARA, CMD_UNREGISTERED | CMD_USER | CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_INFO, cmd_info, MAXPARA, CMD_USER);
|
||||
CommandAdd(NULL, MSG_DNS, cmd_dns, MAXPARA, CMD_USER);
|
||||
CommandAdd(NULL, MSG_REHASH, cmd_rehash, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_REHASH, cmd_rehash, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
CommandAdd(NULL, MSG_RESTART, cmd_restart, 2, CMD_USER);
|
||||
CommandAdd(NULL, MSG_DIE, cmd_die, MAXPARA, CMD_USER);
|
||||
CommandAdd(NULL, MSG_CREDITS, cmd_credits, MAXPARA, CMD_USER);
|
||||
@@ -294,7 +294,7 @@ RealCommand *find_command_simple(const char *cmd)
|
||||
for (c = CommandHash[toupper(*cmd)]; c; c = c->next)
|
||||
{
|
||||
if (!strcasecmp(c->cmd, cmd))
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
+10
-11
@@ -55,10 +55,10 @@ const char *(*tkl_type_string)(TKL *tk);
|
||||
const char *(*tkl_type_config_string)(TKL *tk);
|
||||
char *(*tkl_uhost)(TKL *tkl, char *buf, size_t buflen, int options);
|
||||
TKL *(*tkl_add_serverban)(int type, const char *usermask, const char *hostmask, SecurityGroup *match,
|
||||
const char *reason, const char *setby,
|
||||
time_t expire_at, time_t set_at, int soft, int flags);
|
||||
const char *reason, const char *setby,
|
||||
time_t expire_at, time_t set_at, int soft, int flags);
|
||||
TKL *(*tkl_add_nameban)(int type, const char *name, int hold, const char *reason, const char *setby,
|
||||
time_t expire_at, time_t set_at, int flags);
|
||||
time_t expire_at, time_t set_at, int flags);
|
||||
TKL *(*tkl_add_spamfilter)(int type, const char *id, unsigned short target, BanAction *action,
|
||||
Match *match, const char *rule, SecurityGroup *except,
|
||||
const char *setby,
|
||||
@@ -77,7 +77,7 @@ void (*tkl_hit)(Client *client, TKL *tkl);
|
||||
void (*remove_config_tkls)(int flag);
|
||||
void (*config_tkl_hits_restore)(void);
|
||||
int (*find_shun)(Client *client);
|
||||
int(*find_spamfilter_user)(Client *client, int flags);
|
||||
int (*find_spamfilter_user)(Client *client, int flags);
|
||||
TKL *(*find_qline)(Client *client, const char *nick, int *ishold);
|
||||
TKL *(*find_tkline_match_zap)(Client *client);
|
||||
void (*tkl_stats)(Client *client, int type, const char *para, int *cnt);
|
||||
@@ -225,7 +225,7 @@ Efunction *EfunctionAddMain(Module *module, EfunctionType eftype, int (*func)(),
|
||||
module->errorcode = MODERR_INVALID;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
p = safe_alloc(sizeof(Efunction));
|
||||
if (func)
|
||||
p->func.intfunc = func;
|
||||
@@ -302,7 +302,7 @@ static int num_efunctions(EfunctionType eftype)
|
||||
for (e = Efunctions[eftype]; e; e = e->next)
|
||||
if (!e->willberemoved)
|
||||
cnt++;
|
||||
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@@ -310,9 +310,9 @@ static int num_efunctions(EfunctionType eftype)
|
||||
/** Ensure that all efunctions are present. */
|
||||
int efunctions_check(void)
|
||||
{
|
||||
int i, n, errors=0;
|
||||
int i, n, errors = 0;
|
||||
|
||||
for (i=0; i < MAXEFUNCTIONS; i++)
|
||||
for (i = 0; i < MAXEFUNCTIONS; i++)
|
||||
{
|
||||
if (efunction_table[i].name)
|
||||
{
|
||||
@@ -328,8 +328,7 @@ int efunctions_check(void)
|
||||
"load all required modules! (hint: see modules.default.conf)",
|
||||
efunction_table[i].name);
|
||||
errors++;
|
||||
} else
|
||||
if (n > 1)
|
||||
} else if (n > 1)
|
||||
{
|
||||
config_error("ERROR: efunction '%s' was found %d times, perhaps you "
|
||||
"loaded a module multiple times??",
|
||||
@@ -362,7 +361,7 @@ void efunctions_switchover(void)
|
||||
* as 'willberemoved' if needed.
|
||||
*/
|
||||
|
||||
for (i=0; i < MAXEFUNCTIONS; i++)
|
||||
for (i = 0; i < MAXEFUNCTIONS; i++)
|
||||
{
|
||||
int found = 0;
|
||||
for (e = Efunctions[i]; e; e = e->next)
|
||||
|
||||
+1
-2
@@ -62,7 +62,7 @@ Event *EventAdd(Module *module, const char *name, vFP event, void *data, long ev
|
||||
newevent->last_run.tv_sec = timeofday_tv.tv_sec;
|
||||
newevent->last_run.tv_usec = timeofday_tv.tv_usec;
|
||||
newevent->owner = module;
|
||||
AddListItem(newevent,events);
|
||||
AddListItem(newevent, events);
|
||||
if (module)
|
||||
{
|
||||
ModuleObject *eventobj = safe_alloc(sizeof(ModuleObject));
|
||||
@@ -72,7 +72,6 @@ Event *EventAdd(Module *module, const char *name, vFP event, void *data, long ev
|
||||
module->errorcode = MODERR_NOERROR;
|
||||
}
|
||||
return newevent;
|
||||
|
||||
}
|
||||
|
||||
/** Mark the Event for deletion.
|
||||
|
||||
+18
-21
@@ -42,7 +42,7 @@ Extban *findmod_by_bantype_raw(const char *str, int ban_name_length)
|
||||
{
|
||||
Extban *e;
|
||||
|
||||
for (e=extbans; e; e = e->next)
|
||||
for (e = extbans; e; e = e->next)
|
||||
{
|
||||
if ((ban_name_length == 1) && (e->letter == str[0]))
|
||||
return e;
|
||||
@@ -54,7 +54,7 @@ Extban *findmod_by_bantype_raw(const char *str, int ban_name_length)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Extban *findmod_by_bantype(const char *str, const char **remainder)
|
||||
@@ -69,10 +69,10 @@ Extban *findmod_by_bantype(const char *str, const char **remainder)
|
||||
return NULL;
|
||||
}
|
||||
if (remainder)
|
||||
*remainder = p+1;
|
||||
*remainder = p + 1;
|
||||
|
||||
ban_name_length = p - str - 1;
|
||||
return findmod_by_bantype_raw(str+1, ban_name_length);
|
||||
return findmod_by_bantype_raw(str + 1, ban_name_length);
|
||||
}
|
||||
|
||||
/* Check if this is a valid extended ban name */
|
||||
@@ -141,8 +141,8 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
|
||||
{
|
||||
module->errorcode = MODERR_INVALID;
|
||||
unreal_log(ULOG_ERROR, "module", "EXTBANADD_API_ERROR", NULL,
|
||||
"ExtbanAdd(): name must be specified for ban (new in U6). Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"ExtbanAdd(): name must be specified for ban (new in U6). Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -150,9 +150,9 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
|
||||
{
|
||||
module->errorcode = MODERR_INVALID;
|
||||
unreal_log(ULOG_ERROR, "module", "EXTBANADD_API_ERROR", NULL,
|
||||
"ExtbanAdd(): module must indicate via .is_banned_events on which BANCHK_* "
|
||||
"events to listen on (new in U6). Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"ExtbanAdd(): module must indicate via .is_banned_events on which BANCHK_* "
|
||||
"events to listen on (new in U6). Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -181,12 +181,12 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
|
||||
{
|
||||
module->errorcode = MODERR_INVALID;
|
||||
unreal_log(ULOG_ERROR, "module", "EXTBANADD_API_ERROR", NULL,
|
||||
"ExtbanAdd(): conv_param event missing. Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"ExtbanAdd(): conv_param event missing. Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (e=extbans; e; e = e->next)
|
||||
for (e = extbans; e; e = e->next)
|
||||
{
|
||||
if (e->letter == req.letter)
|
||||
{
|
||||
@@ -196,8 +196,7 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
|
||||
e->unloaded = 0;
|
||||
existing = 1;
|
||||
break;
|
||||
} else
|
||||
if ((module->flags == MODFLAG_TESTING) && e->preregistered)
|
||||
} else if ((module->flags == MODFLAG_TESTING) && e->preregistered)
|
||||
{
|
||||
/* We are in MOD_INIT (yeah confusing, isn't it?)
|
||||
* and the extban already exists and it was preregistered.
|
||||
@@ -206,8 +205,7 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
|
||||
e->preregistered = 0;
|
||||
existing = 1;
|
||||
break;
|
||||
} else
|
||||
if (module->flags == MODFLAG_NONE)
|
||||
} else if (module->flags == MODFLAG_NONE)
|
||||
{
|
||||
/* Better don't touch it, as we may still fail at this stage
|
||||
* and if we would set .conv_param etc to this and the new module
|
||||
@@ -274,7 +272,7 @@ void unload_all_unused_extbans(void)
|
||||
{
|
||||
Extban *e, *e_next;
|
||||
|
||||
for (e=extbans; e; e = e_next)
|
||||
for (e = extbans; e; e = e_next)
|
||||
{
|
||||
e_next = e->next;
|
||||
if (e->letter && e->unloaded)
|
||||
@@ -282,7 +280,6 @@ void unload_all_unused_extbans(void)
|
||||
unload_extban_commit(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Delete an extended ban.
|
||||
@@ -411,9 +408,9 @@ const char *extban_conv_param_nuh_or_extban(BanContext *b, Extban *self_extban)
|
||||
#if (NICKLEN + USERLEN + HOSTLEN + 32) > MAXBANLEN
|
||||
#error "MAXBANLEN is not sufficient to hold n!u@h plus some extra for extban prefixes. wtf?"
|
||||
#endif
|
||||
static char retbuf[MAXBANLEN+1];
|
||||
static char retbuf[MAXBANLEN + 1];
|
||||
char *mask;
|
||||
char tmpbuf[MAXBANLEN+1];
|
||||
char tmpbuf[MAXBANLEN + 1];
|
||||
const char *ret = NULL;
|
||||
const char *nextbanstr;
|
||||
Extban *extban = NULL;
|
||||
@@ -428,7 +425,7 @@ const char *extban_conv_param_nuh_or_extban(BanContext *b, Extban *self_extban)
|
||||
* 2) The second item may never be an action modifier, nor have the
|
||||
* EXTBOPT_NOSTACKCHILD letter set (for things like a textban).
|
||||
*/
|
||||
|
||||
|
||||
/* Rule #1. Yes the recursion check is also in extban_is_ok_nuh_extban,
|
||||
* but it's possible to get here without the is_ok() function ever
|
||||
* being called (think: non-local client). And no, don't delete it
|
||||
|
||||
+17
-12
@@ -67,8 +67,8 @@ HistoryBackend *HistoryBackendAdd(Module *module, HistoryBackendInfo *mreq)
|
||||
{
|
||||
module->errorcode = MODERR_INVALID;
|
||||
unreal_log(ULOG_ERROR, "module", "HISTORYBACKENDADD_API_ERROR", NULL,
|
||||
"HistoryBackendAdd(): missing a handler for add/del/request/destroy/set_limit. Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"HistoryBackendAdd(): missing a handler for add/del/request/destroy/set_limit. Module: $module_name",
|
||||
log_data_string("module_name", module->header->name));
|
||||
return NULL;
|
||||
}
|
||||
m = HistoryBackendFind(mreq->name);
|
||||
@@ -78,11 +78,13 @@ HistoryBackend *HistoryBackendAdd(Module *module, HistoryBackendInfo *mreq)
|
||||
if (m->unloaded)
|
||||
{
|
||||
m->unloaded = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* New history backend */
|
||||
m = safe_alloc(sizeof(HistoryBackend));
|
||||
safe_strdup(m->name, mreq->name);
|
||||
@@ -127,7 +129,8 @@ void HistoryBackendDel(HistoryBackend *m)
|
||||
if (m->owner)
|
||||
{
|
||||
ModuleObject *mobj;
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next) {
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next)
|
||||
{
|
||||
if (mobj->type == MOBJ_HISTORY_BACKEND && mobj->object.history_backend == m)
|
||||
{
|
||||
DelListItem(mobj, m->owner->objects);
|
||||
@@ -160,7 +163,7 @@ int history_add(const char *object, MessageTag *mtags, const char *line)
|
||||
{
|
||||
HistoryBackend *hb;
|
||||
|
||||
for (hb = historybackends; hb; hb=hb->next)
|
||||
for (hb = historybackends; hb; hb = hb->next)
|
||||
hb->history_add(object, mtags, line);
|
||||
|
||||
return 1;
|
||||
@@ -226,7 +229,7 @@ int history_destroy(const char *object)
|
||||
{
|
||||
HistoryBackend *hb;
|
||||
|
||||
for (hb = historybackends; hb; hb=hb->next)
|
||||
for (hb = historybackends; hb; hb = hb->next)
|
||||
hb->history_destroy(object);
|
||||
|
||||
return 1;
|
||||
@@ -236,7 +239,7 @@ int history_set_limit(const char *object, int max_lines, long max_t)
|
||||
{
|
||||
HistoryBackend *hb;
|
||||
|
||||
for (hb = historybackends; hb; hb=hb->next)
|
||||
for (hb = historybackends; hb; hb = hb->next)
|
||||
hb->history_set_limit(object, max_lines, max_t);
|
||||
|
||||
return 1;
|
||||
@@ -282,7 +285,8 @@ static void history_send_result_line(Client *client, HistoryLogLine *l, const ch
|
||||
if (BadPtr(batchid))
|
||||
{
|
||||
sendto_one(client, l->mtags, "%s", l->line);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
MessageTag *m = safe_alloc(sizeof(MessageTag));
|
||||
safe_strdup(m->name, "batch");
|
||||
safe_strdup(m->value, batchid);
|
||||
@@ -299,7 +303,7 @@ static void history_send_result_line(Client *client, HistoryLogLine *l, const ch
|
||||
static void history_send_result_multiline(Client *client, HistoryLogLine *head,
|
||||
const char *outer_batch, const char *object)
|
||||
{
|
||||
char inner_batch[BATCHLEN+1];
|
||||
char inner_batch[BATCHLEN + 1];
|
||||
HistoryLogLine *l;
|
||||
MessageTag *m;
|
||||
|
||||
@@ -376,7 +380,7 @@ static void history_send_result_multiline_fallback(Client *client, HistoryLogLin
|
||||
*/
|
||||
void history_send_result(Client *client, HistoryResult *r, int end_of_pagination)
|
||||
{
|
||||
char batch[BATCHLEN+1];
|
||||
char batch[BATCHLEN + 1];
|
||||
HistoryLogLine *l;
|
||||
int has_multiline;
|
||||
MessageTag *batch_open_mtags = NULL;
|
||||
@@ -409,7 +413,8 @@ void history_send_result(Client *client, HistoryResult *r, int end_of_pagination
|
||||
history_send_result_multiline(client, l, batch, r->object);
|
||||
else
|
||||
history_send_result_multiline_fallback(client, l, batch);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
history_send_result_line(client, l, batch);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -28,7 +28,7 @@ ISupport *ISupports = NULL; /* List of ISUPPORT (005) tokens */
|
||||
ISupport *ISupports_old = NULL; /* see isupport_snapshot() and isupport_check_for_changes() */
|
||||
#define MAXISUPPORTLINES 10
|
||||
|
||||
MODVAR char *ISupportStrings[MAXISUPPORTLINES+1];
|
||||
MODVAR char *ISupportStrings[MAXISUPPORTLINES + 1];
|
||||
|
||||
void isupport_add_sorted(ISupport *is);
|
||||
void make_isupportstrings(void);
|
||||
@@ -125,7 +125,7 @@ void isupport_init(void)
|
||||
ISupportSet(NULL, "draft/ICON", iConf.network_icon);
|
||||
else
|
||||
ISupportDelByName("draft/ICON");
|
||||
|
||||
|
||||
set_isupport_extban(); /* EXTBAN=xyz */
|
||||
set_isupport_targmax(); /* TARGMAX=... */
|
||||
}
|
||||
@@ -201,7 +201,7 @@ ISupport *ISupportAdd(Module *module, const char *token, const char *value)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!token || !*token || c-token > 20)
|
||||
if (!token || !*token || c - token > 20)
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_INVALID;
|
||||
@@ -279,7 +279,7 @@ void make_isupportstrings(void)
|
||||
safe_free(ISupportStrings[i]);
|
||||
|
||||
i = 0;
|
||||
ISupportStrings[i] = safe_alloc(bufsize+1);
|
||||
ISupportStrings[i] = safe_alloc(bufsize + 1);
|
||||
|
||||
for (isupport = ISupports; isupport; isupport = isupport->next)
|
||||
{
|
||||
@@ -292,7 +292,7 @@ void make_isupportstrings(void)
|
||||
if ((strlen(ISupportStrings[i]) + strlen(tmp) + 1 >= ISUPPORTLEN) || (tokcnt == 13))
|
||||
{
|
||||
/* No room or max tokens reached: start a new buffer */
|
||||
ISupportStrings[++i] = safe_alloc(bufsize+1);
|
||||
ISupportStrings[++i] = safe_alloc(bufsize + 1);
|
||||
tokcnt = 1;
|
||||
if (i == MAXISUPPORTLINES)
|
||||
abort(); /* should never happen anyway */
|
||||
|
||||
+13
-10
@@ -53,17 +53,17 @@ MessageTagHandler *MessageTagHandlerAdd(Module *module, MessageTagHandlerInfo *m
|
||||
if ((mreq->flags & MTAG_HANDLER_FLAGS_NO_CAP_NEEDED) && mreq->clicap_handler)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "MESSAGETAGHANDLERADD_API_ERROR", NULL,
|
||||
"MessageTagHandlerAdd() from module $module_name: "
|
||||
".flags is set to MTAG_HANDLER_FLAGS_NO_CAP_NEEDED "
|
||||
"but a .clicap_handler is passed as well. These options are mutually "
|
||||
"exclusive, choose one or the other.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"MessageTagHandlerAdd() from module $module_name: "
|
||||
".flags is set to MTAG_HANDLER_FLAGS_NO_CAP_NEEDED "
|
||||
"but a .clicap_handler is passed as well. These options are mutually "
|
||||
"exclusive, choose one or the other.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
abort();
|
||||
} else if (!(mreq->flags & MTAG_HANDLER_FLAGS_NO_CAP_NEEDED) && !mreq->clicap_handler)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "MESSAGETAGHANDLERADD_API_ERROR", NULL,
|
||||
"MessageTagHandlerAdd() from module $module_name: "
|
||||
"no .clicap_handler is passed. If the "
|
||||
"MessageTagHandlerAdd() from module $module_name: "
|
||||
"no .clicap_handler is passed. If the "
|
||||
"message tag really does not require a cap then you must "
|
||||
"set .flags to MTAG_HANDLER_FLAGS_NO_CAP_NEEDED",
|
||||
log_data_string("module_name", module->header->name));
|
||||
@@ -76,12 +76,14 @@ MessageTagHandler *MessageTagHandlerAdd(Module *module, MessageTagHandlerInfo *m
|
||||
if (m->unloaded)
|
||||
{
|
||||
m->unloaded = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* New message tag handler */
|
||||
m = safe_alloc(sizeof(MessageTagHandler));
|
||||
safe_strdup(m->name, mreq->name);
|
||||
@@ -137,7 +139,8 @@ void MessageTagHandlerDel(MessageTagHandler *m)
|
||||
if (m->owner)
|
||||
{
|
||||
ModuleObject *mobj;
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next) {
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next)
|
||||
{
|
||||
if (mobj->type == MOBJ_MTAG && mobj->object.mtag == m)
|
||||
{
|
||||
DelListItem(mobj, m->owner->objects);
|
||||
|
||||
+35
-37
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
MODVAR ModDataInfo *MDInfo[HIGHESTMODDATATYPE+1] = { NULL };
|
||||
MODVAR ModDataInfo *MDInfo[HIGHESTMODDATATYPE + 1] = {NULL};
|
||||
|
||||
MODVAR ModData local_variable_moddata[MODDATA_MAX_LOCAL_VARIABLE];
|
||||
MODVAR ModData global_variable_moddata[MODDATA_MAX_GLOBAL_VARIABLE];
|
||||
@@ -35,14 +35,14 @@ struct moddatatypelimit {
|
||||
};
|
||||
|
||||
struct moddatatypelimit moddatatypelimits[] = {
|
||||
{ MODDATATYPE_LOCAL_VARIABLE, "MODDATATYPE_LOCAL_VARIABLE", MODDATA_MAX_LOCAL_VARIABLE, "MODDATA_MAX_LOCAL_VARIABLE" },
|
||||
{ MODDATATYPE_GLOBAL_VARIABLE, "MODDATATYPE_GLOBAL_VARIABLE", MODDATA_MAX_GLOBAL_VARIABLE, "MODDATA_MAX_GLOBAL_VARIABLE" },
|
||||
{ MODDATATYPE_CLIENT, "MODDATATYPE_CLIENT", MODDATA_MAX_CLIENT, "MODDATA_MAX_CLIENT" },
|
||||
{ MODDATATYPE_LOCAL_CLIENT, "MODDATATYPE_LOCAL_CLIENT", MODDATA_MAX_LOCAL_CLIENT, "MODDATA_MAX_LOCAL_CLIENT" },
|
||||
{ MODDATATYPE_CHANNEL, "MODDATATYPE_CHANNEL", MODDATA_MAX_CHANNEL, "MODDATA_MAX_CHANNEL" },
|
||||
{ MODDATATYPE_MEMBER, "MODDATATYPE_MEMBER", MODDATA_MAX_MEMBER, "MODDATA_MAX_MEMBER" },
|
||||
{ MODDATATYPE_MEMBERSHIP, "MODDATATYPE_MEMBERSHIP", MODDATATYPE_MEMBERSHIP, "MODDATATYPE_MAX_MEMBERSHIP" },
|
||||
{ 0, NULL, 0, NULL },
|
||||
{MODDATATYPE_LOCAL_VARIABLE, "MODDATATYPE_LOCAL_VARIABLE", MODDATA_MAX_LOCAL_VARIABLE, "MODDATA_MAX_LOCAL_VARIABLE"},
|
||||
{MODDATATYPE_GLOBAL_VARIABLE, "MODDATATYPE_GLOBAL_VARIABLE", MODDATA_MAX_GLOBAL_VARIABLE, "MODDATA_MAX_GLOBAL_VARIABLE"},
|
||||
{MODDATATYPE_CLIENT, "MODDATATYPE_CLIENT", MODDATA_MAX_CLIENT, "MODDATA_MAX_CLIENT"},
|
||||
{MODDATATYPE_LOCAL_CLIENT, "MODDATATYPE_LOCAL_CLIENT", MODDATA_MAX_LOCAL_CLIENT, "MODDATA_MAX_LOCAL_CLIENT"},
|
||||
{MODDATATYPE_CHANNEL, "MODDATATYPE_CHANNEL", MODDATA_MAX_CHANNEL, "MODDATA_MAX_CHANNEL"},
|
||||
{MODDATATYPE_MEMBER, "MODDATATYPE_MEMBER", MODDATA_MAX_MEMBER, "MODDATA_MAX_MEMBER"},
|
||||
{MODDATATYPE_MEMBERSHIP, "MODDATATYPE_MEMBERSHIP", MODDATATYPE_MEMBERSHIP, "MODDATATYPE_MAX_MEMBERSHIP"},
|
||||
{0, NULL, 0, NULL},
|
||||
};
|
||||
|
||||
int exceeds_moddatatype_limit(int type, int slot)
|
||||
@@ -56,15 +56,15 @@ int exceeds_moddatatype_limit(int type, int slot)
|
||||
if (slot >= moddatatypelimits[i].limit)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "MOD_DATA_OUT_OF_SPACE", NULL,
|
||||
"ModDataAdd: out of space! Your $mod_data_type limit of $limit is reached. "
|
||||
"Perhaps you have many third party modules loaded?\n"
|
||||
"If you need more space then you could open include/config.h and "
|
||||
"raise $mod_data_type_limit_name. You may also want to raise the other limits "
|
||||
"there, just to be sure. After changing that file, you will have to "
|
||||
"recompile (make clean; make install) and restart the IRCd.",
|
||||
log_data_string("mod_data_type", moddatatypelimits[i].type_name),
|
||||
log_data_string("mod_data_type_limit_name", moddatatypelimits[i].limit_name),
|
||||
log_data_integer("limit", moddatatypelimits[i].limit));
|
||||
"ModDataAdd: out of space! Your $mod_data_type limit of $limit is reached. "
|
||||
"Perhaps you have many third party modules loaded?\n"
|
||||
"If you need more space then you could open include/config.h and "
|
||||
"raise $mod_data_type_limit_name. You may also want to raise the other limits "
|
||||
"there, just to be sure. After changing that file, you will have to "
|
||||
"recompile (make clean; make install) and restart the IRCd.",
|
||||
log_data_string("mod_data_type", moddatatypelimits[i].type_name),
|
||||
log_data_string("mod_data_type_limit_name", moddatatypelimits[i].limit_name),
|
||||
log_data_integer("limit", moddatatypelimits[i].limit));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -90,7 +90,7 @@ void moddatatype_dump(Client *client)
|
||||
#ifdef DEBUGMODE
|
||||
sendtxtnumeric(client, "=== %s ===", moddatatypelimits[i].type_name);
|
||||
#endif
|
||||
for (position = 0, m = MDInfo[moddatatypelimits[i].type]; m ; m = m->next, position++)
|
||||
for (position = 0, m = MDInfo[moddatatypelimits[i].type]; m; m = m->next, position++)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
sendtxtnumeric(client, "Position %d: %s",
|
||||
@@ -121,7 +121,7 @@ ModDataInfo *ModDataAdd(Module *module, ModDataInfo req)
|
||||
abort();
|
||||
|
||||
/* Hunt for highest available slot */
|
||||
for (m = MDInfo[req.type]; m ; m = m->next)
|
||||
for (m = MDInfo[req.type]; m; m = m->next)
|
||||
{
|
||||
/* Does an entry already exist with this name? */
|
||||
if (!strcmp(m->name, req.name))
|
||||
@@ -139,7 +139,7 @@ ModDataInfo *ModDataAdd(Module *module, ModDataInfo req)
|
||||
return NULL;
|
||||
}
|
||||
/* Update next available slot */
|
||||
slotav = MAX(slotav, m->slot+1);
|
||||
slotav = MAX(slotav, m->slot + 1);
|
||||
}
|
||||
|
||||
if (exceeds_moddatatype_limit(req.type, slotav))
|
||||
@@ -163,7 +163,7 @@ moddataadd_isok:
|
||||
m->self_write = req.self_write;
|
||||
m->owner = module;
|
||||
m->priority = req.priority;
|
||||
|
||||
|
||||
if (new_struct)
|
||||
AddListItemPrio(m, MDInfo[req.type], m->priority);
|
||||
|
||||
@@ -175,7 +175,7 @@ moddataadd_isok:
|
||||
AddListItem(mobj, module->objects);
|
||||
module->errorcode = MODERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ void moddata_free_membership(Membership *m)
|
||||
/** Actually free all the ModData from all objects */
|
||||
void unload_moddata_commit(ModDataInfo *md)
|
||||
{
|
||||
switch(md->type)
|
||||
switch (md->type)
|
||||
{
|
||||
case MODDATATYPE_LOCAL_VARIABLE:
|
||||
if (md->free && moddata_local_variable(md).ptr)
|
||||
@@ -286,7 +286,7 @@ void unload_moddata_commit(ModDataInfo *md)
|
||||
case MODDATATYPE_CHANNEL:
|
||||
{
|
||||
Channel *channel;
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
if (md->free && moddata_channel(channel, md).ptr)
|
||||
md->free(&moddata_channel(channel, md));
|
||||
@@ -298,7 +298,7 @@ void unload_moddata_commit(ModDataInfo *md)
|
||||
{
|
||||
Channel *channel;
|
||||
Member *m;
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
for (m = channel->members; m; m = m->next)
|
||||
{
|
||||
@@ -327,7 +327,7 @@ void unload_moddata_commit(ModDataInfo *md)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DelListItem(md, MDInfo[md->type]);
|
||||
safe_free(md->name);
|
||||
safe_free(md);
|
||||
@@ -364,7 +364,8 @@ void ModDataDel(ModDataInfo *md)
|
||||
md->serialize = NULL;
|
||||
md->unserialize = NULL;
|
||||
md->unloaded = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* We need the free function and the like,
|
||||
* and then completely destroy 'md'.
|
||||
*/
|
||||
@@ -387,7 +388,8 @@ void unload_all_unused_moddata(void)
|
||||
//config_status("UNLOADING: md %s (owner %p, type %d, slot %d)",
|
||||
// md->name, md->owner, md->type, md->slot);
|
||||
unload_moddata_commit(md);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
//config_status("loaded: md %s (owner %p, type %d, slot %d)",
|
||||
// md->name, md->owner, md->type, md->slot);
|
||||
}
|
||||
@@ -433,8 +435,7 @@ int moddata_client_set(Client *client, const char *varname, const char *value)
|
||||
{
|
||||
/* SET */
|
||||
md->unserialize(value, &moddata_client(client, md));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* UNSET */
|
||||
md->free(&moddata_client(client, md));
|
||||
@@ -493,8 +494,7 @@ int moddata_local_client_set(Client *client, const char *varname, const char *va
|
||||
{
|
||||
/* SET */
|
||||
md->unserialize(value, &moddata_local_client(client, md));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* UNSET */
|
||||
md->free(&moddata_local_client(client, md));
|
||||
@@ -540,8 +540,7 @@ int moddata_local_variable_set(const char *varname, const char *value)
|
||||
{
|
||||
/* SET */
|
||||
md->unserialize(value, &moddata_local_variable(md));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* UNSET */
|
||||
md->free(&moddata_local_variable(md));
|
||||
@@ -565,8 +564,7 @@ int moddata_global_variable_set(const char *varname, const char *value)
|
||||
{
|
||||
/* SET */
|
||||
md->unserialize(value, &moddata_global_variable(md));
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* UNSET */
|
||||
md->free(&moddata_global_variable(md));
|
||||
|
||||
+9
-6
@@ -38,9 +38,9 @@ RPCHandler *RPCHandlerAdd(Module *module, RPCHandlerInfo *mreq)
|
||||
if (!mreq->method || !mreq->call)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "RPCHANDLERADD_API_ERROR", NULL,
|
||||
"RPCHandlerAdd() from module $module_name: "
|
||||
"Missing required fields.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
"RPCHandlerAdd() from module $module_name: "
|
||||
"Missing required fields.",
|
||||
log_data_string("module_name", module->header->name));
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -50,12 +50,14 @@ RPCHandler *RPCHandlerAdd(Module *module, RPCHandlerInfo *mreq)
|
||||
if (m->unloaded)
|
||||
{
|
||||
m->unloaded = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* New RPC handler */
|
||||
m = safe_alloc(sizeof(RPCHandler));
|
||||
safe_strdup(m->method, mreq->method);
|
||||
@@ -106,7 +108,8 @@ void RPCHandlerDel(RPCHandler *m)
|
||||
if (m->owner)
|
||||
{
|
||||
ModuleObject *mobj;
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next) {
|
||||
for (mobj = m->owner->objects; mobj; mobj = mobj->next)
|
||||
{
|
||||
if (mobj->type == MOBJ_RPC && mobj->object.rpc == m)
|
||||
{
|
||||
DelListItem(mobj, m->owner->objects);
|
||||
|
||||
+13
-11
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
char umodestring[UMODETABLESZ+1];
|
||||
char umodestring[UMODETABLESZ + 1];
|
||||
|
||||
/** User modes and their handlers */
|
||||
Umode *usermodes = NULL;
|
||||
@@ -53,8 +53,8 @@ long SNO_SPAMF = 0L;
|
||||
long SNO_SNOTICE = 0L;
|
||||
long SNO_OPER = 0L;
|
||||
|
||||
long AllUmodes; /* All umodes */
|
||||
long SendUmodes; /* All umodes which are sent to other servers (global umodes) */
|
||||
long AllUmodes; /* All umodes */
|
||||
long SendUmodes; /* All umodes which are sent to other servers (global umodes) */
|
||||
|
||||
Umode *umode_letter_to_handler[256];
|
||||
|
||||
@@ -83,7 +83,7 @@ void make_umodestr(void)
|
||||
Umode *um;
|
||||
char *p = umodestring;
|
||||
|
||||
for (um=usermodes; um; um = um->next)
|
||||
for (um = usermodes; um; um = um->next)
|
||||
{
|
||||
if (um->letter)
|
||||
{
|
||||
@@ -177,7 +177,7 @@ Umode *UmodeAdd(Module *module, char ch, int global, int unset_on_deoper, int (*
|
||||
Umode *um;
|
||||
int existing = 0;
|
||||
|
||||
for (um=usermodes; um; um = um->next)
|
||||
for (um = usermodes; um; um = um->next)
|
||||
{
|
||||
if (um->letter == ch)
|
||||
{
|
||||
@@ -186,7 +186,8 @@ Umode *UmodeAdd(Module *module, char ch, int global, int unset_on_deoper, int (*
|
||||
um->unloaded = 0;
|
||||
existing = 1;
|
||||
break;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
@@ -198,10 +199,10 @@ Umode *UmodeAdd(Module *module, char ch, int global, int unset_on_deoper, int (*
|
||||
{
|
||||
/* Not found, create */
|
||||
long l, found = 0;
|
||||
for (l = 1; l < LONG_MAX/2; l *= 2)
|
||||
for (l = 1; l < LONG_MAX / 2; l *= 2)
|
||||
{
|
||||
found = 0;
|
||||
for (um=usermodes; um; um = um->next)
|
||||
for (um = usermodes; um; um = um->next)
|
||||
{
|
||||
if (um->mode == l)
|
||||
{
|
||||
@@ -216,7 +217,7 @@ Umode *UmodeAdd(Module *module, char ch, int global, int unset_on_deoper, int (*
|
||||
if (found)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "module", "USER_MODE_OUT_OF_SPACE", NULL,
|
||||
"UmodeAdd: out of space!!!");
|
||||
"UmodeAdd: out of space!!!");
|
||||
if (module)
|
||||
module->errorcode = MODERR_NOSPACE;
|
||||
return NULL;
|
||||
@@ -225,7 +226,8 @@ Umode *UmodeAdd(Module *module, char ch, int global, int unset_on_deoper, int (*
|
||||
um->letter = ch;
|
||||
um->mode = l;
|
||||
usermode_add_sorted(um);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
umode_letter_to_handler[um->letter] = um;
|
||||
}
|
||||
|
||||
@@ -353,7 +355,7 @@ void unload_all_unused_umodes(void)
|
||||
{
|
||||
Umode *um, *um_next;
|
||||
|
||||
for (um=usermodes; um; um = um_next)
|
||||
for (um = usermodes; um; um = um_next)
|
||||
{
|
||||
um_next = um->next;
|
||||
if (um->letter && um->unloaded)
|
||||
|
||||
+53
-53
@@ -23,26 +23,26 @@
|
||||
|
||||
typedef struct AuthTypeList AuthTypeList;
|
||||
struct AuthTypeList {
|
||||
char *name;
|
||||
AuthenticationType type;
|
||||
char *name;
|
||||
AuthenticationType type;
|
||||
};
|
||||
|
||||
/** The list of authentication types that we support. */
|
||||
AuthTypeList MODVAR AuthTypeLists[] = {
|
||||
{"plain", AUTHTYPE_PLAINTEXT},
|
||||
{"plaintext", AUTHTYPE_PLAINTEXT},
|
||||
{"crypt", AUTHTYPE_UNIXCRYPT},
|
||||
{"unixcrypt", AUTHTYPE_UNIXCRYPT},
|
||||
{"bcrypt", AUTHTYPE_BCRYPT},
|
||||
{"cert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"sslclientcert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"tlsclientcert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"certfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"sslclientcertfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"tlsclientcertfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"spkifp", AUTHTYPE_SPKIFP},
|
||||
{"argon2", AUTHTYPE_ARGON2},
|
||||
{NULL, 0},
|
||||
{"plain", AUTHTYPE_PLAINTEXT},
|
||||
{"plaintext", AUTHTYPE_PLAINTEXT},
|
||||
{"crypt", AUTHTYPE_UNIXCRYPT},
|
||||
{"unixcrypt", AUTHTYPE_UNIXCRYPT},
|
||||
{"bcrypt", AUTHTYPE_BCRYPT},
|
||||
{"cert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"sslclientcert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"tlsclientcert", AUTHTYPE_TLS_CLIENTCERT},
|
||||
{"certfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"sslclientcertfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"tlsclientcertfp", AUTHTYPE_TLS_CLIENTCERTFP},
|
||||
{"spkifp", AUTHTYPE_SPKIFP},
|
||||
{"argon2", AUTHTYPE_ARGON2},
|
||||
{NULL, 0},
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@@ -58,15 +58,15 @@ static int parsepass(const char *str, char **salt, char **hash)
|
||||
/* Syntax: $<salt>$<hash> */
|
||||
if (*str != '$')
|
||||
return 0;
|
||||
p = strchr(str+1, '$');
|
||||
if (!p || (p == str+1) || !p[1])
|
||||
p = strchr(str + 1, '$');
|
||||
if (!p || (p == str + 1) || !p[1])
|
||||
return 0;
|
||||
|
||||
max = p - str;
|
||||
if (max > sizeof(saltbuf))
|
||||
max = sizeof(saltbuf);
|
||||
strlcpy(saltbuf, str+1, max);
|
||||
strlcpy(hashbuf, p+1, sizeof(hashbuf));
|
||||
strlcpy(saltbuf, str + 1, max);
|
||||
strlcpy(hashbuf, p + 1, sizeof(hashbuf));
|
||||
*salt = saltbuf;
|
||||
*hash = hashbuf;
|
||||
return 1;
|
||||
@@ -116,13 +116,13 @@ int Auth_AutoDetectHashType(const char *hash)
|
||||
112 | if ((*hash != '$') || !strchr(hash+1, '$'))
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overread"
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overread"
|
||||
#endif
|
||||
if ((*hash != '$') || !strchr(hash+1, '$'))
|
||||
if ((*hash != '$') || !strchr(hash + 1, '$'))
|
||||
return AUTHTYPE_PLAINTEXT;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
if (!strncmp(hash, "$2a$", 4) || !strncmp(hash, "$2b$", 4) || !strncmp(hash, "$2y$", 4))
|
||||
@@ -182,13 +182,13 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: authentication module failure: missing parameter",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
return -1;
|
||||
}
|
||||
if (ce->items && ce->items->next)
|
||||
{
|
||||
config_error("%s:%i: you may not have multiple authentication methods",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
if (type == -1)
|
||||
{
|
||||
config_error("%s:%i: authentication module failure: %s is not an implemented/enabled authentication method",
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->items->name);
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->items->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -208,13 +208,13 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
{
|
||||
const char *hashedpass = mkpass_argon2(ce->value);
|
||||
unreal_log(ULOG_ADVICE, "config", "BEST_PRACTICES_HASHED_PASSWORDS", NULL,
|
||||
"$file:$line_number: $config_item: Advice: it is not recommended to use plaintext passwords in the config file. "
|
||||
"You can replace this password with the following password hash:\n"
|
||||
"password \"$hashed_password\";",
|
||||
log_data_string("config_item", config_item_name(ce)),
|
||||
log_data_string("file", ce->file->filename),
|
||||
log_data_integer("line_number", ce->line_number),
|
||||
log_data_string("hashed_password", hashedpass));
|
||||
"$file:$line_number: $config_item: Advice: it is not recommended to use plaintext passwords in the config file. "
|
||||
"You can replace this password with the following password hash:\n"
|
||||
"password \"$hashed_password\";",
|
||||
log_data_string("config_item", config_item_name(ce)),
|
||||
log_data_string("file", ce->file->filename),
|
||||
log_data_integer("line_number", ce->line_number),
|
||||
log_data_string("hashed_password", hashedpass));
|
||||
bestpractices.hashed_passwords_hits++;
|
||||
}
|
||||
break;
|
||||
@@ -223,7 +223,7 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
if (strlen(ce->value) < 2)
|
||||
{
|
||||
config_error("%s:%i: authentication module failure: AUTHTYPE_UNIXCRYPT: no salt (crypt strings will always be >2 in length)",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@@ -232,7 +232,7 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
if (!(x509_f = fopen(ce->value, "r")))
|
||||
{
|
||||
config_error("%s:%i: authentication module failure: AUTHTYPE_TLS_CLIENTCERT: error opening file %s: %s",
|
||||
ce->file->filename, ce->line_number, ce->value, strerror(errno));
|
||||
ce->file->filename, ce->line_number, ce->value, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
x509_filecert = PEM_read_X509(x509_f, NULL, NULL, NULL);
|
||||
@@ -240,12 +240,12 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
if (!x509_filecert)
|
||||
{
|
||||
config_error("%s:%i: authentication module failure: AUTHTYPE_TLS_CLIENTCERT: PEM_read_X509 errored in file %s (format error?)",
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
return -1;
|
||||
}
|
||||
X509_free(x509_filecert);
|
||||
break;
|
||||
default: ;
|
||||
default:;
|
||||
}
|
||||
|
||||
/* Unix crypt is a bit more complicated: most types are outright 'bad',
|
||||
@@ -263,13 +263,13 @@ int Auth_CheckError(ConfigEntry *ce, int warn_on_plaintext)
|
||||
config_warn("%s:%i: Using simple crypt for authentication is not recommended. "
|
||||
"Consider using the more secure auth-type 'argon2' instead. "
|
||||
"See https://www.unrealircd.org/docs/Authentication_types for the complete list.",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
/* do not return, not an error. */
|
||||
}
|
||||
if ((type == AUTHTYPE_PLAINTEXT) && (strlen(ce->value) > PASSWDLEN))
|
||||
{
|
||||
config_error("%s:%i: passwords length may not exceed %d",
|
||||
ce->file->filename, ce->line_number, PASSWDLEN);
|
||||
ce->file->filename, ce->line_number, PASSWDLEN);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
@@ -310,8 +310,8 @@ void Auth_FreeAuthConfig(AuthConfig *as)
|
||||
* and REAL salt length (after b64_encode, including terminating nul),
|
||||
* used for reserving memory.
|
||||
*/
|
||||
#define RAWSALTLEN 6
|
||||
#define REALSALTLEN 12
|
||||
#define RAWSALTLEN 6
|
||||
#define REALSALTLEN 12
|
||||
|
||||
static int authcheck_argon2(Client *client, AuthConfig *as, const char *para)
|
||||
{
|
||||
@@ -411,7 +411,7 @@ static int authcheck_tls_clientcert_fingerprint(Client *client, AuthConfig *as,
|
||||
/* Check colon version, so that we keep in line with
|
||||
* previous versions, based on Nath's patch -dboyz
|
||||
*/
|
||||
for (i=0, k=0; i<strlen(fp); i++)
|
||||
for (i = 0, k = 0; i < strlen(fp); i++)
|
||||
{
|
||||
if (i != 0 && i % 2 == 0)
|
||||
hexcolon[k++] = ':';
|
||||
@@ -474,8 +474,8 @@ int Auth_Check(Client *client, AuthConfig *as, const char *para)
|
||||
if (!strcmp(as->data, "changemeplease") && !strcmp(para, as->data))
|
||||
{
|
||||
unreal_log(ULOG_INFO, "auth", "AUTH_REJECT_DEFAULT_PASSWORD", client,
|
||||
"Rejecting default password 'changemeplease'. "
|
||||
"Please change the password in the configuration file.");
|
||||
"Rejecting default password 'changemeplease'. "
|
||||
"Please change the password in the configuration file.");
|
||||
return 0;
|
||||
}
|
||||
/* plain text compare */
|
||||
@@ -526,11 +526,11 @@ int Auth_Check(Client *client, AuthConfig *as, const char *para)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_TIME_COST 2
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_MEMORY_COST 6144
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_PARALLELISM_COST 2
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_HASH_LENGTH 32
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_SALT_LENGTH (128/8)
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_TIME_COST 2
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_MEMORY_COST 6144
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_PARALLELISM_COST 2
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_HASH_LENGTH 32
|
||||
#define UNREALIRCD_ARGON2_DEFAULT_SALT_LENGTH (128 / 8)
|
||||
|
||||
static char *mkpass_argon2(const char *para)
|
||||
{
|
||||
@@ -542,7 +542,7 @@ static char *mkpass_argon2(const char *para)
|
||||
return NULL;
|
||||
|
||||
/* Initialize salt */
|
||||
for (i=0; i < sizeof(salt); i++)
|
||||
for (i = 0; i < sizeof(salt); i++)
|
||||
salt[i] = getrandom8();
|
||||
|
||||
*buf = '\0';
|
||||
@@ -579,7 +579,7 @@ static char *mkpass_bcrypt(const char *para)
|
||||
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
for (i=0; i<sizeof(random_data); i++)
|
||||
for (i = 0; i < sizeof(random_data); i++)
|
||||
random_data[i] = getrandom8();
|
||||
|
||||
saltstr = _crypt_gensalt_blowfish_rn("$2y", 9, random_data, sizeof(random_data), salt, sizeof(salt));
|
||||
|
||||
+67
-67
@@ -46,20 +46,20 @@ static mp_pool_t *channel_pool = NULL;
|
||||
* These are +ntmispklr and also the list modes +vhoaq and +beI.
|
||||
*/
|
||||
CoreChannelModeTable corechannelmodetable[] = {
|
||||
{MODE_BAN, 'b', 1, 1},
|
||||
{MODE_EXCEPT, 'e', 1, 1}, /* exception ban */
|
||||
{MODE_INVEX, 'I', 1, 1}, /* invite-only exception */
|
||||
{0x0, 0x0, 0x0, 0x0},
|
||||
{MODE_BAN, 'b', 1, 1},
|
||||
{MODE_EXCEPT, 'e', 1, 1}, /* exception ban */
|
||||
{MODE_INVEX, 'I', 1, 1}, /* invite-only exception */
|
||||
{0x0, 0x0, 0x0, 0x0},
|
||||
};
|
||||
|
||||
/** The advertised supported channel modes in the 004 numeric */
|
||||
char cmodestring[512];
|
||||
|
||||
/** Returns 1 if the IRCOp can override or is a remote connection */
|
||||
inline int op_can_override(const char *acl, Client *client, Channel *channel, void* extra)
|
||||
inline int op_can_override(const char *acl, Client *client, Channel *channel, void *extra)
|
||||
{
|
||||
#ifndef NO_OPEROVERRIDE
|
||||
if (MyUser(client) && !(ValidatePermissionsForPath(acl,client,NULL,channel,extra)))
|
||||
if (MyUser(client) && !(ValidatePermissionsForPath(acl, client, NULL, channel, extra)))
|
||||
return 0;
|
||||
return 1;
|
||||
#else
|
||||
@@ -113,11 +113,11 @@ Membership *find_membership_link(Membership *lp, Channel *ptr)
|
||||
static Member *make_member(void)
|
||||
{
|
||||
Member *lp;
|
||||
unsigned int i;
|
||||
unsigned int i;
|
||||
|
||||
if (freemember == NULL)
|
||||
{
|
||||
for (i = 1; i <= (4072/sizeof(Member)); ++i)
|
||||
for (i = 1; i <= (4072 / sizeof(Member)); ++i)
|
||||
{
|
||||
lp = safe_alloc(sizeof(Member));
|
||||
AddListItem(lp, freemember);
|
||||
@@ -144,11 +144,11 @@ static void free_member(Member *lp)
|
||||
static Membership *make_membership(void)
|
||||
{
|
||||
Membership *m = NULL;
|
||||
unsigned int i;
|
||||
unsigned int i;
|
||||
|
||||
if (freemembership == NULL)
|
||||
{
|
||||
for (i = 1; i <= (4072/sizeof(Membership)); i++)
|
||||
for (i = 1; i <= (4072 / sizeof(Membership)); i++)
|
||||
{
|
||||
m = safe_alloc(sizeof(Membership));
|
||||
AddListItem(m, freemembership);
|
||||
@@ -203,7 +203,8 @@ Client *find_chasing(Client *client, const char *user, int *chasing)
|
||||
*chasing = 1;
|
||||
if (!IsServer(who))
|
||||
return who;
|
||||
else return NULL;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return 1 if the bans are identical, taking into account special handling for extbans */
|
||||
@@ -298,8 +299,8 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba
|
||||
}
|
||||
|
||||
/* Update/set if this ban is new or older than existing one */
|
||||
safe_strldup(ban->banstr, banid, MAXBANLEN+1); /* cAsE may differ, use oldest version of it */
|
||||
safe_strldup(ban->who, setby, NICKLEN+USERLEN+HOSTLEN+4);
|
||||
safe_strldup(ban->banstr, banid, MAXBANLEN + 1); /* cAsE may differ, use oldest version of it */
|
||||
safe_strldup(ban->who, setby, NICKLEN + USERLEN + HOSTLEN + 4);
|
||||
ban->when = seton;
|
||||
return isnew ? 1 : 0;
|
||||
}
|
||||
@@ -310,7 +311,7 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba
|
||||
int add_listmode(Ban **list, Client *client, Channel *channel, const char *banid)
|
||||
{
|
||||
char *setby = client->name;
|
||||
char nuhbuf[NICKLEN+USERLEN+HOSTLEN+4];
|
||||
char nuhbuf[NICKLEN + USERLEN + HOSTLEN + 4];
|
||||
|
||||
if (IsUser(client) && (iConf.ban_setter == SETTER_NICK_USER_HOST))
|
||||
setby = make_nick_user_host_r(nuhbuf, sizeof(nuhbuf), client->name, client->user->username, GetHost(client));
|
||||
@@ -373,12 +374,12 @@ inline int ban_check_mask(BanContext *b)
|
||||
if (!extban || !(extban->is_banned_events & b->ban_check_types))
|
||||
{
|
||||
return 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
b->banstr = nextbanstr;
|
||||
return extban->is_banned(b);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* Is a n!u@h mask. */
|
||||
return match_user(b->banstr, b->client, MATCH_CHECK_ALL);
|
||||
@@ -396,7 +397,7 @@ inline int ban_check_mask(BanContext *b)
|
||||
Ban *is_banned_with_nick(Client *client, Channel *channel, int type, const char *nick, const char **msg, const char **errmsg)
|
||||
{
|
||||
Ban *ban, *ex;
|
||||
char savednick[NICKLEN+1];
|
||||
char savednick[NICKLEN + 1];
|
||||
BanContext *b = safe_alloc(sizeof(BanContext));
|
||||
|
||||
/* It's not really doable to pass 'nick' to all the ban layers,
|
||||
@@ -490,7 +491,7 @@ int ban_exists_ignore_time(Ban *lst, const char *str)
|
||||
if (!strncmp(lst->banstr, "~time:", 6))
|
||||
{
|
||||
/* Special treatment for ~time:xx: */
|
||||
p = strchr(lst->banstr+6, ':');
|
||||
p = strchr(lst->banstr + 6, ':');
|
||||
if (p)
|
||||
{
|
||||
p++;
|
||||
@@ -588,12 +589,13 @@ int remove_user_from_channel_withmb(Client *client, Channel *channel, Membership
|
||||
if (MyUser(client))
|
||||
{
|
||||
unreal_log(ULOG_INFO, "part", "LOCAL_CLIENT_PART", client,
|
||||
"User $client left $channel",
|
||||
log_data_channel("channel", channel));
|
||||
} else {
|
||||
"User $client left $channel",
|
||||
log_data_channel("channel", channel));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "part", "REMOTE_CLIENT_PART", client,
|
||||
"User $client left $channel",
|
||||
log_data_channel("channel", channel));
|
||||
"User $client left $channel",
|
||||
log_data_channel("channel", channel));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +635,7 @@ int has_channel_mode(Channel *channel, char mode)
|
||||
{
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->letter == mode) && (channel->mode.mode & cm->mode))
|
||||
return 1;
|
||||
|
||||
@@ -645,7 +647,7 @@ int has_channel_mode_raw(Cmode_t m, char mode)
|
||||
{
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if ((cm->letter == mode) && (m & cm->mode))
|
||||
return 1;
|
||||
|
||||
@@ -657,11 +659,11 @@ Cmode_t get_extmode_bitbychar(char m)
|
||||
{
|
||||
Cmode *cm;
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
if (cm->letter == m)
|
||||
return cm->mode;
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
if (cm->letter == m)
|
||||
return cm->mode;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Write the "simple" list of channel modes for channel channel onto buffer mbuf with the parameters in pbuf.
|
||||
@@ -683,7 +685,7 @@ void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, siz
|
||||
return;
|
||||
|
||||
if (!client || IsMember(client, channel) || IsServer(client) || IsMe(client) || IsULine(client) ||
|
||||
ValidatePermissionsForPath("channel:see:mode:remote",client,NULL,channel,NULL))
|
||||
ValidatePermissionsForPath("channel:see:mode:remote", client, NULL, channel, NULL))
|
||||
{
|
||||
show_mode_parameters = 1;
|
||||
}
|
||||
@@ -691,7 +693,7 @@ void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, siz
|
||||
*pbuf = '\0';
|
||||
strlcpy(mbuf, "+", mbuf_size);
|
||||
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
{
|
||||
if (cm->letter &&
|
||||
!(hide_local_modes && cm->local) &&
|
||||
@@ -712,7 +714,7 @@ void channel_modes(Client *client, char *mbuf, char *pbuf, size_t mbuf_size, siz
|
||||
|
||||
/* Remove the trailing space from the parameters -- codemastr */
|
||||
if (*pbuf)
|
||||
pbuf[strlen(pbuf)-1]='\0';
|
||||
pbuf[strlen(pbuf) - 1] = '\0';
|
||||
}
|
||||
|
||||
/** Make a pretty mask from the input string - only used by SILENCE
|
||||
@@ -732,8 +734,7 @@ char *pretty_mask(const char *mask_in)
|
||||
*host++ = '\0';
|
||||
if (!user)
|
||||
return make_nick_user_host(NULL, cp, host);
|
||||
}
|
||||
else if (!user && strchr(cp, '.'))
|
||||
} else if (!user && strchr(cp, '.'))
|
||||
{
|
||||
return make_nick_user_host(NULL, NULL, cp);
|
||||
}
|
||||
@@ -797,16 +798,15 @@ const char *convert_regular_ban(char *mask, char *buf, size_t buflen)
|
||||
{
|
||||
*host++ = '\0';
|
||||
if (!user)
|
||||
return make_nick_user_host_r(buf, buflen, NULL, trim_str(mask,USERLEN), trim_str(host,HOSTLEN));
|
||||
}
|
||||
else if (!user && (strchr(mask, '.') || strchr(mask, ':')))
|
||||
return make_nick_user_host_r(buf, buflen, NULL, trim_str(mask, USERLEN), trim_str(host, HOSTLEN));
|
||||
} else if (!user && (strchr(mask, '.') || strchr(mask, ':')))
|
||||
{
|
||||
/* 1.2.3.4 -> *!*@1.2.3.4 (and the same for IPv6) */
|
||||
return make_nick_user_host_r(buf, buflen, NULL, NULL, trim_str(mask,HOSTLEN));
|
||||
return make_nick_user_host_r(buf, buflen, NULL, NULL, trim_str(mask, HOSTLEN));
|
||||
}
|
||||
|
||||
/* regular nick!user@host with the auto-trimming feature */
|
||||
return make_nick_user_host_r(buf, buflen, trim_str(mask,NICKLEN), trim_str(user,USERLEN), trim_str(host,HOSTLEN));
|
||||
return make_nick_user_host_r(buf, buflen, trim_str(mask, NICKLEN), trim_str(user, USERLEN), trim_str(host, HOSTLEN));
|
||||
}
|
||||
|
||||
/** Make a proper ban mask.
|
||||
@@ -829,7 +829,8 @@ const char *clean_ban_mask(const char *mask_in, int what, ExtbanType ban_type, C
|
||||
static char mask[512];
|
||||
|
||||
/* Strip any ':' at beginning since that would cause a desync */
|
||||
for (; (*mask_in && (*mask_in == ':')); mask_in++);
|
||||
for (; (*mask_in && (*mask_in == ':')); mask_in++)
|
||||
;
|
||||
if (!*mask_in)
|
||||
return NULL;
|
||||
|
||||
@@ -890,7 +891,7 @@ const char *clean_ban_mask(const char *mask_in, int what, ExtbanType ban_type, C
|
||||
}
|
||||
/* else, do some basic sanity checks and cut it off at 80 bytes */
|
||||
if ((mask[1] != ':') || (mask[2] == '\0'))
|
||||
return NULL; /* require a ":<char>" after extban type */
|
||||
return NULL; /* require a ":<char>" after extban type */
|
||||
if (strlen(mask) > 80)
|
||||
mask[80] = '\0';
|
||||
return mask;
|
||||
@@ -947,8 +948,7 @@ int valid_channelname(const char *cname)
|
||||
if (*p < 33 || *p == ',' || *p == ':')
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
if (iConf.allowed_channelchars == ALLOWED_CHANNELCHARS_ASCII)
|
||||
} else if (iConf.allowed_channelchars == ALLOWED_CHANNELCHARS_ASCII)
|
||||
{
|
||||
/* The strict setting: only allow ASCII 32-128, except some chars */
|
||||
for (p = cname; *p; p++)
|
||||
@@ -956,8 +956,7 @@ int valid_channelname(const char *cname)
|
||||
if (*p < 33 || *p == ',' || *p == ':' || *p > 127)
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
if (iConf.allowed_channelchars == ALLOWED_CHANNELCHARS_UTF8)
|
||||
} else if (iConf.allowed_channelchars == ALLOWED_CHANNELCHARS_UTF8)
|
||||
{
|
||||
/* Only allow UTF8, and also disallow some chars */
|
||||
for (p = cname; *p; p++)
|
||||
@@ -994,7 +993,7 @@ Channel *make_channel(const char *name)
|
||||
Channel *channel;
|
||||
int len;
|
||||
char *p;
|
||||
char namebuf[CHANNELLEN+1];
|
||||
char namebuf[CHANNELLEN + 1];
|
||||
|
||||
if (BadPtr(name))
|
||||
return NULL;
|
||||
@@ -1135,8 +1134,8 @@ void set_channel_mlock(Client *client, Channel *channel, const char *newmlock, i
|
||||
if (propagate)
|
||||
{
|
||||
sendto_server(client, 0, 0, NULL, ":%s MLOCK %lld %s :%s",
|
||||
client->id, (long long)channel->creationtime, channel->name,
|
||||
BadPtr(channel->mode_lock) ? "" : channel->mode_lock);
|
||||
client->id, (long long)channel->creationtime, channel->name,
|
||||
BadPtr(channel->mode_lock) ? "" : channel->mode_lock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,7 +1168,7 @@ int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in
|
||||
pm->what = MODE_ADD;
|
||||
}
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
if (*pm->modebuf == '\0')
|
||||
return 0;
|
||||
@@ -1178,14 +1177,12 @@ int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in
|
||||
pm->what = MODE_ADD;
|
||||
pm->modebuf++;
|
||||
continue;
|
||||
}
|
||||
else if (*pm->modebuf == '-')
|
||||
} else if (*pm->modebuf == '-')
|
||||
{
|
||||
pm->what = MODE_DEL;
|
||||
pm->modebuf++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
CoreChannelModeTable *tab = &corechannelmodetable[0];
|
||||
Cmode *cm;
|
||||
@@ -1210,10 +1207,11 @@ int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in
|
||||
{
|
||||
eatparam = 1;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* EXTENDED CHANNEL MODE */
|
||||
int found = 0;
|
||||
for (cm=channelmodes; cm; cm = cm->next)
|
||||
for (cm = channelmodes; cm; cm = cm->next)
|
||||
{
|
||||
if (cm->letter == *pm->modebuf)
|
||||
{
|
||||
@@ -1244,7 +1242,8 @@ int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in
|
||||
if (pm->parabuf && *pm->parabuf)
|
||||
{
|
||||
const char *start, *end;
|
||||
for (; *pm->parabuf == ' '; pm->parabuf++); /* skip whitespace */
|
||||
for (; *pm->parabuf == ' '; pm->parabuf++)
|
||||
; /* skip whitespace */
|
||||
start = pm->parabuf;
|
||||
if (*pm->parabuf == '\0')
|
||||
{
|
||||
@@ -1259,15 +1258,15 @@ int parse_chanmode(ParseMode *pm, const char *modebuf_in, const char *parabuf_in
|
||||
if (end - start + 1 > sizeof(pm->buf))
|
||||
end = start + sizeof(pm->buf); /* 'never' reached */
|
||||
strlcpy(pm->buf, start, end - start + 1);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
strlcpy(pm->buf, start, sizeof(pm->buf));
|
||||
pm->parabuf = pm->parabuf + strlen(pm->parabuf); /* point to \0 at end */
|
||||
}
|
||||
stripcrlf(pm->buf); /* needed for unreal_server_compat.c */
|
||||
pm->param = pm->buf;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
pm->modebuf++;
|
||||
continue; /* invalid, got mode but no parameter available */
|
||||
}
|
||||
@@ -1413,7 +1412,8 @@ void set_user_invisible(Client *client, Channel *channel, int invisible)
|
||||
{
|
||||
m->memb_flags |= MEMB_FLAG_INVISIBLE;
|
||||
m->related->memb_flags |= MEMB_FLAG_INVISIBLE;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
m->memb_flags &= ~MEMB_FLAG_INVISIBLE;
|
||||
m->related->memb_flags &= ~MEMB_FLAG_INVISIBLE;
|
||||
}
|
||||
@@ -1431,12 +1431,12 @@ void send_invalid_channelname(Client *client, const char *channelname)
|
||||
if (*channelname != '#')
|
||||
{
|
||||
reason = "Channel name must start with a hash mark (#)";
|
||||
} else
|
||||
if (strlen(channelname) > CHANNELLEN)
|
||||
} else if (strlen(channelname) > CHANNELLEN)
|
||||
{
|
||||
reason = "Channel name is too long";
|
||||
} else {
|
||||
switch(iConf.allowed_channelchars)
|
||||
} else
|
||||
{
|
||||
switch (iConf.allowed_channelchars)
|
||||
{
|
||||
case ALLOWED_CHANNELCHARS_ASCII:
|
||||
reason = "Channel name contains illegal characters (must be ASCII)";
|
||||
@@ -1463,7 +1463,7 @@ int is_extended_ban(const char *str)
|
||||
|
||||
if (*str != '~')
|
||||
return 0;
|
||||
for (p = str+1; *p; p++)
|
||||
for (p = str + 1; *p; p++)
|
||||
{
|
||||
if (!isalnum(*p))
|
||||
{
|
||||
@@ -1505,7 +1505,7 @@ void free_multilinemode(MultiLineMode *m)
|
||||
int i;
|
||||
if (m == NULL)
|
||||
return;
|
||||
for (i=0; i < m->numlines; i++)
|
||||
for (i = 0; i < m->numlines; i++)
|
||||
{
|
||||
safe_free(m->modeline[i]);
|
||||
safe_free(m->paramline[i]);
|
||||
|
||||
+1835
-2095
File diff suppressed because it is too large
Load Diff
+108
-84
@@ -53,13 +53,13 @@ typedef struct {
|
||||
* since we use strncmp for matching.
|
||||
*/
|
||||
static IfFunction if_functions[] = {
|
||||
{ "module-loaded", IF_MODULE_LOADED, 0 },
|
||||
{ "module-exists", IF_MODULE_EXISTS, 0 },
|
||||
{ "minimum-version", IF_MINIMUM_VERSION, 0 },
|
||||
{ "file-exists", IF_FILE_EXISTS, 0 },
|
||||
{ "module-version", IF_MODULE_VERSION, 1 },
|
||||
{ "environment", IF_ENVIRONMENT, 1 },
|
||||
{ "defined", IF_DEFINED, 0 },
|
||||
{"module-loaded", IF_MODULE_LOADED, 0},
|
||||
{"module-exists", IF_MODULE_EXISTS, 0},
|
||||
{"minimum-version", IF_MINIMUM_VERSION, 0},
|
||||
{"file-exists", IF_FILE_EXISTS, 0},
|
||||
{"module-version", IF_MODULE_VERSION, 1},
|
||||
{"environment", IF_ENVIRONMENT, 1},
|
||||
{"defined", IF_DEFINED, 0},
|
||||
};
|
||||
|
||||
static inline int ValidVarCharacter(char x)
|
||||
@@ -89,35 +89,30 @@ static int parse_compare_op_and_value(char **p, char *statement,
|
||||
{
|
||||
*compare_op_out = COMPARE_EQ;
|
||||
op_len = 2;
|
||||
} else
|
||||
if (!strncmp(*p, "!=", 2))
|
||||
} else if (!strncmp(*p, "!=", 2))
|
||||
{
|
||||
*compare_op_out = COMPARE_NE;
|
||||
op_len = 2;
|
||||
} else
|
||||
if (!strncmp(*p, ">=", 2))
|
||||
} else if (!strncmp(*p, ">=", 2))
|
||||
{
|
||||
*compare_op_out = COMPARE_GE;
|
||||
op_len = 2;
|
||||
} else
|
||||
if (!strncmp(*p, "<=", 2))
|
||||
} else if (!strncmp(*p, "<=", 2))
|
||||
{
|
||||
*compare_op_out = COMPARE_LE;
|
||||
op_len = 2;
|
||||
} else
|
||||
if (**p == '>')
|
||||
} else if (**p == '>')
|
||||
{
|
||||
*compare_op_out = COMPARE_GT;
|
||||
op_len = 1;
|
||||
} else
|
||||
if (**p == '<')
|
||||
} else if (**p == '<')
|
||||
{
|
||||
*compare_op_out = COMPARE_LT;
|
||||
op_len = 1;
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: @if: expected comparison operator (==, !=, >, >=, <, <=): %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return 0;
|
||||
}
|
||||
*p += op_len;
|
||||
@@ -130,7 +125,7 @@ static int parse_compare_op_and_value(char **p, char *statement,
|
||||
if (!**p)
|
||||
{
|
||||
config_error("%s:%i: invalid @if statement, missing \" at end perhaps?",
|
||||
filename, linenumber);
|
||||
filename, linenumber);
|
||||
return 0;
|
||||
}
|
||||
**p = '\0';
|
||||
@@ -169,7 +164,7 @@ static PreprocessorItem parse_if_function(char *p, const char *funcname, ConfigI
|
||||
if (*p != '(')
|
||||
{
|
||||
config_error("%s:%i: expected '(' for %s(...",
|
||||
filename, linenumber, funcname);
|
||||
filename, linenumber, funcname);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
p++;
|
||||
@@ -181,7 +176,7 @@ static PreprocessorItem parse_if_function(char *p, const char *funcname, ConfigI
|
||||
if (!*p)
|
||||
{
|
||||
config_error("%s:%i: invalid if statement (termination error): %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
*p = '\0';
|
||||
@@ -204,7 +199,7 @@ static PreprocessorItem parse_if_function(char *p, const char *funcname, ConfigI
|
||||
if (negative)
|
||||
{
|
||||
config_error("%s:%i: @if: the '!' prefix cannot be used with %s() comparisons, use != instead: %s",
|
||||
filename, linenumber, funcname, statement);
|
||||
filename, linenumber, funcname, statement);
|
||||
preprocessor_cc_free_entry(cc);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
@@ -224,7 +219,7 @@ static PreprocessorItem parse_if_function(char *p, const char *funcname, ConfigI
|
||||
|
||||
PreprocessorItem evaluate_preprocessor_if(char *statement, const char *filename, int linenumber, ConditionalConfig **cc_out)
|
||||
{
|
||||
char *p=statement;
|
||||
char *p = statement;
|
||||
int i, negative = 0;
|
||||
ConditionalConfig *cc;
|
||||
|
||||
@@ -277,13 +272,13 @@ PreprocessorItem evaluate_preprocessor_if(char *statement, const char *filename,
|
||||
if (*p != '$')
|
||||
{
|
||||
config_error("%s:%i: invalid @if statement. Either an unknown function, or did you mean $VARNAME?: %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
if (negative)
|
||||
{
|
||||
config_error("%s:%i: @if: the '!' prefix cannot be used with variable comparisons, use != instead: %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
p++;
|
||||
@@ -293,7 +288,7 @@ PreprocessorItem evaluate_preprocessor_if(char *statement, const char *filename,
|
||||
if (!*p)
|
||||
{
|
||||
config_error("%s:%i: invalid if statement (termination error): %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
name_terminate = p;
|
||||
@@ -310,7 +305,7 @@ PreprocessorItem evaluate_preprocessor_if(char *statement, const char *filename,
|
||||
}
|
||||
|
||||
config_error("%s:%i: Error while evaluating '@if' statement '%s'",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
|
||||
@@ -337,7 +332,7 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
if (!if_functions[i].returns_value)
|
||||
{
|
||||
config_error("%s:%i: @define: function '%s' does not return a value",
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -347,7 +342,7 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
if (*p != '(')
|
||||
{
|
||||
config_error("%s:%i: @define: expected '(' for %s(...",
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
return NULL;
|
||||
}
|
||||
p++;
|
||||
@@ -359,7 +354,7 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
if (!*p)
|
||||
{
|
||||
config_error("%s:%i: @define: invalid function call (termination error): %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return NULL;
|
||||
}
|
||||
*p = '\0';
|
||||
@@ -371,7 +366,7 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
if (!env)
|
||||
{
|
||||
config_error("%s:%i: @define: environment variable '%s' is not set",
|
||||
filename, linenumber, arg);
|
||||
filename, linenumber, arg);
|
||||
return NULL;
|
||||
}
|
||||
return env;
|
||||
@@ -383,13 +378,13 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
if (!mod)
|
||||
{
|
||||
config_error("%s:%i: @define: module '%s' is not loaded",
|
||||
filename, linenumber, arg);
|
||||
filename, linenumber, arg);
|
||||
return NULL;
|
||||
}
|
||||
if (!mod->header->version)
|
||||
{
|
||||
config_error("%s:%i: @define: module '%s' has no version information",
|
||||
filename, linenumber, arg);
|
||||
filename, linenumber, arg);
|
||||
return NULL;
|
||||
}
|
||||
return mod->header->version;
|
||||
@@ -397,16 +392,16 @@ static const char *resolve_define_function(char *p, char *statement,
|
||||
|
||||
/* Future value-returning functions go here */
|
||||
config_error("%s:%i: @define: [BUG] unhandled value-returning function '%s'",
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
filename, linenumber, if_functions[i].keyword);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
config_error("%s:%i: @define: expected a quoted string or a value-returning function like environment(): %s",
|
||||
filename, linenumber, statement);
|
||||
filename, linenumber, statement);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PreprocessorItem evaluate_preprocessor_define(char *statement, const char *filename, int linenumber)
|
||||
PreprocessorItem evaluate_preprocessor_define(char *statement, const char *filename, int linenumber)
|
||||
{
|
||||
char *p = statement;
|
||||
char *name, *name_terminator;
|
||||
@@ -418,7 +413,7 @@ PreprocessorItem evaluate_preprocessor_define(char *statement, const char *file
|
||||
if (!*p)
|
||||
{
|
||||
config_error("%s:%i: invalid @define statement",
|
||||
filename, linenumber);
|
||||
filename, linenumber);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
name_terminator = p;
|
||||
@@ -433,7 +428,7 @@ PreprocessorItem evaluate_preprocessor_define(char *statement, const char *file
|
||||
if (!*p)
|
||||
{
|
||||
config_error("%s:%i: invalid @define statement, missing \" at end perhaps?",
|
||||
filename, linenumber);
|
||||
filename, linenumber);
|
||||
return PREPROCESSOR_ERROR;
|
||||
}
|
||||
*p = '\0';
|
||||
@@ -484,7 +479,7 @@ PreprocessorItem evaluate_preprocessor_define(char *statement, const char *file
|
||||
* @returns PREPROCESSOR_USER_ERROR or PREPROCESSOR_USER_WARNING
|
||||
*/
|
||||
static PreprocessorItem evaluate_preprocessor_error_or_warning(char *statement,
|
||||
int is_error, const char *filename, int linenumber)
|
||||
int is_error, const char *filename, int linenumber)
|
||||
{
|
||||
char *p = statement;
|
||||
|
||||
@@ -508,7 +503,7 @@ static PreprocessorItem evaluate_preprocessor_error_or_warning(char *statement,
|
||||
return PREPROCESSOR_USER_WARNING;
|
||||
}
|
||||
|
||||
PreprocessorItem parse_preprocessor_item(char *start, char *end, const char *filename, int linenumber, ConditionalConfig **cc)
|
||||
PreprocessorItem parse_preprocessor_item(char *start, char *end, const char *filename, int linenumber, ConditionalConfig **cc)
|
||||
{
|
||||
char buf[512];
|
||||
int max;
|
||||
@@ -521,17 +516,17 @@ PreprocessorItem parse_preprocessor_item(char *start, char *end, const char *fi
|
||||
strlcpy(buf, start, max);
|
||||
|
||||
if (!strncmp(buf, "@define", 7))
|
||||
return evaluate_preprocessor_define(buf+7, filename, linenumber);
|
||||
return evaluate_preprocessor_define(buf + 7, filename, linenumber);
|
||||
else if (!strncmp(buf, "@if ", 4))
|
||||
return evaluate_preprocessor_if(buf+4, filename, linenumber, cc);
|
||||
return evaluate_preprocessor_if(buf + 4, filename, linenumber, cc);
|
||||
else if (!strncmp(buf, "@else", 5))
|
||||
return PREPROCESSOR_ELSE;
|
||||
else if (!strncmp(buf, "@endif", 6))
|
||||
return PREPROCESSOR_ENDIF;
|
||||
else if (!strncmp(buf, "@error ", 7))
|
||||
return evaluate_preprocessor_error_or_warning(buf+7, 1, filename, linenumber);
|
||||
return evaluate_preprocessor_error_or_warning(buf + 7, 1, filename, linenumber);
|
||||
else if (!strncmp(buf, "@warning ", 9))
|
||||
return evaluate_preprocessor_error_or_warning(buf+9, 0, filename, linenumber);
|
||||
return evaluate_preprocessor_error_or_warning(buf + 9, 0, filename, linenumber);
|
||||
|
||||
config_error("%s:%i: Unknown preprocessor directive: %s", filename, linenumber, buf);
|
||||
return PREPROCESSOR_ERROR; /* ??? */
|
||||
@@ -612,19 +607,16 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
{
|
||||
/* We cannot handle @if module-loaded() yet.. */
|
||||
result = 1;
|
||||
} else
|
||||
if (phase == PREPROCESSOR_PHASE_SECONDARY)
|
||||
} else if (phase == PREPROCESSOR_PHASE_SECONDARY)
|
||||
{
|
||||
/* We can only handle blacklisted modules at this point, so: */
|
||||
if (!is_blacklisted_module(cc->name))
|
||||
result = 1;
|
||||
} else
|
||||
if (is_module_loaded(cc->name))
|
||||
} else if (is_module_loaded(cc->name))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
} else
|
||||
if (cc->condition == IF_MODULE_VERSION)
|
||||
} else if (cc->condition == IF_MODULE_VERSION)
|
||||
{
|
||||
if (phase == PREPROCESSOR_PHASE_INITIAL || phase == PREPROCESSOR_PHASE_SECONDARY)
|
||||
{
|
||||
@@ -640,12 +632,24 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
int cmp = strnatcasecmp(mod->header->version, cc->opt);
|
||||
switch (cc->compare_op)
|
||||
{
|
||||
case COMPARE_EQ: result = (cmp == 0); break;
|
||||
case COMPARE_NE: result = (cmp != 0); break;
|
||||
case COMPARE_GT: result = (cmp > 0); break;
|
||||
case COMPARE_GE: result = (cmp >= 0); break;
|
||||
case COMPARE_LT: result = (cmp < 0); break;
|
||||
case COMPARE_LE: result = (cmp <= 0); break;
|
||||
case COMPARE_EQ:
|
||||
result = (cmp == 0);
|
||||
break;
|
||||
case COMPARE_NE:
|
||||
result = (cmp != 0);
|
||||
break;
|
||||
case COMPARE_GT:
|
||||
result = (cmp > 0);
|
||||
break;
|
||||
case COMPARE_GE:
|
||||
result = (cmp >= 0);
|
||||
break;
|
||||
case COMPARE_LT:
|
||||
result = (cmp < 0);
|
||||
break;
|
||||
case COMPARE_LE:
|
||||
result = (cmp <= 0);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -654,34 +658,29 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (cc->condition == IF_MODULE_EXISTS)
|
||||
} else if (cc->condition == IF_MODULE_EXISTS)
|
||||
{
|
||||
const char *fullpath = Module_TransformPath(cc->name);
|
||||
if (file_exists(fullpath))
|
||||
result = 1;
|
||||
} else
|
||||
if (cc->condition == IF_MINIMUM_VERSION)
|
||||
} else if (cc->condition == IF_MINIMUM_VERSION)
|
||||
{
|
||||
if (strnatcasecmp(VERSIONONLY, cc->name) >= 0)
|
||||
result = 1;
|
||||
} else
|
||||
if (cc->condition == IF_FILE_EXISTS)
|
||||
} else if (cc->condition == IF_FILE_EXISTS)
|
||||
{
|
||||
char *fullpath = convert_to_absolute_path_duplicate(cc->name, CONFDIR);
|
||||
if (file_exists(fullpath))
|
||||
result = 1;
|
||||
safe_free(fullpath);
|
||||
} else
|
||||
if (cc->condition == IF_DEFINED)
|
||||
} else if (cc->condition == IF_DEFINED)
|
||||
{
|
||||
NameValuePrioList *d = find_config_define(cc->name);
|
||||
if (d)
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
} else
|
||||
if (cc->condition == IF_ENVIRONMENT)
|
||||
} else if (cc->condition == IF_ENVIRONMENT)
|
||||
{
|
||||
const char *env = getenv(cc->name);
|
||||
if (env)
|
||||
@@ -691,12 +690,24 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
int cmp = strnatcasecmp(env, cc->opt);
|
||||
switch (cc->compare_op)
|
||||
{
|
||||
case COMPARE_EQ: result = (cmp == 0); break;
|
||||
case COMPARE_NE: result = (cmp != 0); break;
|
||||
case COMPARE_GT: result = (cmp > 0); break;
|
||||
case COMPARE_GE: result = (cmp >= 0); break;
|
||||
case COMPARE_LT: result = (cmp < 0); break;
|
||||
case COMPARE_LE: result = (cmp <= 0); break;
|
||||
case COMPARE_EQ:
|
||||
result = (cmp == 0);
|
||||
break;
|
||||
case COMPARE_NE:
|
||||
result = (cmp != 0);
|
||||
break;
|
||||
case COMPARE_GT:
|
||||
result = (cmp > 0);
|
||||
break;
|
||||
case COMPARE_GE:
|
||||
result = (cmp >= 0);
|
||||
break;
|
||||
case COMPARE_LT:
|
||||
result = (cmp < 0);
|
||||
break;
|
||||
case COMPARE_LE:
|
||||
result = (cmp <= 0);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -704,8 +715,7 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (cc->condition == IF_VALUE)
|
||||
} else if (cc->condition == IF_VALUE)
|
||||
{
|
||||
NameValuePrioList *d = find_config_define(cc->name);
|
||||
if (d)
|
||||
@@ -713,12 +723,24 @@ int preprocessor_resolve_if(ConditionalConfig *cc, PreprocessorPhase phase)
|
||||
int cmp = strnatcasecmp(d->value, cc->opt);
|
||||
switch (cc->compare_op)
|
||||
{
|
||||
case COMPARE_EQ: result = (cmp == 0); break;
|
||||
case COMPARE_NE: result = (cmp != 0); break;
|
||||
case COMPARE_GT: result = (cmp > 0); break;
|
||||
case COMPARE_GE: result = (cmp >= 0); break;
|
||||
case COMPARE_LT: result = (cmp < 0); break;
|
||||
case COMPARE_LE: result = (cmp <= 0); break;
|
||||
case COMPARE_EQ:
|
||||
result = (cmp == 0);
|
||||
break;
|
||||
case COMPARE_NE:
|
||||
result = (cmp != 0);
|
||||
break;
|
||||
case COMPARE_GT:
|
||||
result = (cmp > 0);
|
||||
break;
|
||||
case COMPARE_GE:
|
||||
result = (cmp >= 0);
|
||||
break;
|
||||
case COMPARE_LT:
|
||||
result = (cmp < 0);
|
||||
break;
|
||||
case COMPARE_LE:
|
||||
result = (cmp <= 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@@ -754,7 +776,8 @@ void preprocessor_resolve_conditionals_ce(ConfigEntry **ce_list, PreprocessorPha
|
||||
{
|
||||
/* we are head, so new head */
|
||||
*ce_list = ce->next; /* can be NULL now */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* non-head */
|
||||
ce_prev->next = ce->next; /* can be NULL now */
|
||||
}
|
||||
@@ -822,7 +845,7 @@ void preprocessor_replace_defines(char **item, ConfigEntry *ce)
|
||||
char varname[512];
|
||||
const char *i, *varstart, *varend;
|
||||
char *o;
|
||||
int n = sizeof(buf)-2;
|
||||
int n = sizeof(buf) - 2;
|
||||
int limit;
|
||||
char *value;
|
||||
|
||||
@@ -843,7 +866,8 @@ void preprocessor_replace_defines(char **item, ConfigEntry *ce)
|
||||
/* $ encountered: */
|
||||
varstart = i;
|
||||
i++;
|
||||
for (; *i && ValidVarCharacter(*i); i++);
|
||||
for (; *i && ValidVarCharacter(*i); i++)
|
||||
;
|
||||
varend = i;
|
||||
i--;
|
||||
limit = varend - varstart + 1;
|
||||
@@ -862,7 +886,7 @@ void preprocessor_replace_defines(char **item, ConfigEntry *ce)
|
||||
i++; /* skip extra $ in input */
|
||||
} else
|
||||
{
|
||||
value = get_config_define(varname+1);
|
||||
value = get_config_define(varname + 1);
|
||||
if (!value)
|
||||
{
|
||||
#if 0
|
||||
|
||||
+121
-118
@@ -21,9 +21,9 @@ char *find_best_coredump(void)
|
||||
|
||||
if (!fd)
|
||||
return NULL;
|
||||
|
||||
|
||||
*best_fname = '\0';
|
||||
|
||||
|
||||
while ((dir = readdir(fd)))
|
||||
{
|
||||
char *fname = dir->d_name;
|
||||
@@ -32,7 +32,7 @@ char *find_best_coredump(void)
|
||||
!strstr(fname, ".done"))
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", TMPDIR, fname);
|
||||
t = get_file_time(buf);
|
||||
if (t && (t > best_time))
|
||||
@@ -47,11 +47,11 @@ char *find_best_coredump(void)
|
||||
/* Windows */
|
||||
WIN32_FIND_DATA hData;
|
||||
HANDLE hFile;
|
||||
|
||||
|
||||
hFile = FindFirstFile("unrealircd.*.core", &hData);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
char *fname = hData.cFileName;
|
||||
@@ -68,11 +68,11 @@ char *find_best_coredump(void)
|
||||
}
|
||||
} while (FindNextFile(hFile, &hData));
|
||||
FindClose(hFile);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if (*best_fname)
|
||||
return best_fname;
|
||||
|
||||
|
||||
return NULL; /* none found */
|
||||
}
|
||||
|
||||
@@ -118,13 +118,13 @@ char *find_best_asan_log(void)
|
||||
#define EL_AR_MAX MAXPARA
|
||||
char **explode(char *str, char *delimiter)
|
||||
{
|
||||
static char *ret[EL_AR_MAX+1];
|
||||
static char *ret[EL_AR_MAX + 1];
|
||||
static char buf[1024];
|
||||
char *p, *name;
|
||||
int cnt = 0;
|
||||
|
||||
|
||||
memset(&ret, 0, sizeof(ret)); /* make sure all elements are NULL */
|
||||
|
||||
|
||||
strlcpy(buf, str, sizeof(buf));
|
||||
for (name = strtoken(&p, buf, delimiter); name; name = strtoken(&p, NULL, delimiter))
|
||||
{
|
||||
@@ -133,7 +133,7 @@ char **explode(char *str, char *delimiter)
|
||||
break;
|
||||
}
|
||||
ret[cnt] = NULL;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ void crash_report_fix_libs(char *coredump, int *thirdpartymods)
|
||||
setenv("LC_ALL", "C", 1);
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "echo info sharedlibrary|gdb %s/unrealircd %s 2>&1",
|
||||
BINDIR, coredump);
|
||||
BINDIR, coredump);
|
||||
|
||||
fd = popen(cmd, "r");
|
||||
if (!fd)
|
||||
return;
|
||||
|
||||
while((fgets(buf, sizeof(buf), fd)))
|
||||
while ((fgets(buf, sizeof(buf), fd)))
|
||||
{
|
||||
char *file, *path;
|
||||
char target[512];
|
||||
@@ -165,26 +165,26 @@ void crash_report_fix_libs(char *coredump, int *thirdpartymods)
|
||||
stripcrlf(buf);
|
||||
|
||||
if (strstr(buf, ".third."))
|
||||
*thirdpartymods = 1;
|
||||
*thirdpartymods = 1;
|
||||
|
||||
/* Output we are interested is something like this:
|
||||
* <many spaces> No /home/blabla/unrealircd/tmp/5114DF16.m_kick.so
|
||||
*/
|
||||
if (!strstr(buf, " No "))
|
||||
continue;
|
||||
|
||||
|
||||
path = strchr(buf, '/');
|
||||
if (!path)
|
||||
continue;
|
||||
|
||||
if (!strstr(path, TMPDIR))
|
||||
continue; /* we only care about our TMPDIR stuff */
|
||||
|
||||
|
||||
file = strrchr(path, '/');
|
||||
if (!file)
|
||||
continue;
|
||||
file++;
|
||||
|
||||
|
||||
/* files have the following two formats:
|
||||
* 5BE7DF9.m_svsnline.so for modules/m_svsnline.so
|
||||
* 300AA138.chanmodes.nokick.so for modules/chanmodes/nokick.so
|
||||
@@ -194,15 +194,15 @@ void crash_report_fix_libs(char *coredump, int *thirdpartymods)
|
||||
snprintf(target, sizeof(target), "%s/%s.%s", MODULESDIR, arr[1], arr[2]);
|
||||
else
|
||||
snprintf(target, sizeof(target), "%s/%s/%s.%s", MODULESDIR, arr[1], arr[2], arr[3]);
|
||||
|
||||
|
||||
if (!file_exists(target))
|
||||
{
|
||||
printf("WARNING: could not resolve %s: %s does not exist\n", path, target);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (symlink(target, path) < 0)
|
||||
printf("WARNING: could not create symlink %s -> %s\n", path, target);
|
||||
}
|
||||
|
||||
}
|
||||
pclose(fd);
|
||||
#endif
|
||||
@@ -237,16 +237,16 @@ int crash_report_backtrace(FILE *reportfd, char *coredump)
|
||||
"quit\n");
|
||||
fclose(fd);
|
||||
|
||||
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "gdb -batch -x %s %s/unrealircd %s 2>&1",
|
||||
buf, BINDIR, coredump);
|
||||
|
||||
buf, BINDIR, coredump);
|
||||
|
||||
fd = popen(cmd, "r");
|
||||
if (!fd)
|
||||
return 0;
|
||||
|
||||
|
||||
fprintf(reportfd, "START OF BACKTRACE\n");
|
||||
while((fgets(buf, sizeof(buf), fd)))
|
||||
while ((fgets(buf, sizeof(buf), fd)))
|
||||
{
|
||||
stripcrlf(buf);
|
||||
fprintf(reportfd, " %s\n", buf);
|
||||
@@ -264,7 +264,7 @@ int crash_report_backtrace(FILE *reportfd, char *coredump)
|
||||
if (!fd)
|
||||
return 0;
|
||||
fprintf(reportfd, "START OF CRASH DUMP\n");
|
||||
while((fgets(buf, sizeof(buf), fd)))
|
||||
while ((fgets(buf, sizeof(buf), fd)))
|
||||
{
|
||||
stripcrlf(buf);
|
||||
fprintf(reportfd, " %s\n", buf);
|
||||
@@ -291,8 +291,8 @@ int crash_report_asan_log(FILE *reportfd, char *coredump)
|
||||
asantime = get_file_time(asan_log);
|
||||
|
||||
fprintf(reportfd, "ASan log file found '%s' which is %ld seconds older than core file\n",
|
||||
asan_log,
|
||||
(long)((long)(coretime) - (long)asantime));
|
||||
asan_log,
|
||||
(long)((long)(coretime) - (long)asantime));
|
||||
|
||||
fd = fopen(asan_log, "r");
|
||||
if (!fd)
|
||||
@@ -301,7 +301,7 @@ int crash_report_asan_log(FILE *reportfd, char *coredump)
|
||||
return 0;
|
||||
}
|
||||
fprintf(reportfd, "START OF ASAN LOG\n");
|
||||
while((fgets(buf, sizeof(buf), fd)))
|
||||
while ((fgets(buf, sizeof(buf), fd)))
|
||||
{
|
||||
stripcrlf(buf);
|
||||
fprintf(reportfd, " %s\n", buf);
|
||||
@@ -321,32 +321,33 @@ int crash_report_asan_log(FILE *reportfd, char *coredump)
|
||||
void crash_report_header(FILE *reportfd, char *coredump)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
|
||||
fprintf(reportfd, "== UNREALIRCD CRASH REPORT ==\n"
|
||||
"\n"
|
||||
"SYSTEM INFORMATION:\n");
|
||||
|
||||
|
||||
fprintf(reportfd, "UnrealIRCd version: %s\n", VERSIONONLY);
|
||||
#if defined(__VERSION__)
|
||||
fprintf(reportfd, " Compiler: %s\n", __VERSION__);
|
||||
#endif
|
||||
|
||||
|
||||
fprintf(reportfd, " Operating System: %s\n", MYOSNAME);
|
||||
|
||||
|
||||
|
||||
fprintf(reportfd, "Using core file: %s\n", coredump);
|
||||
|
||||
|
||||
t = get_file_time(coredump);
|
||||
if (t != 0)
|
||||
{
|
||||
fprintf(reportfd, "Crash date/time: %s\n", myctime(t) ? myctime(t) : "???");
|
||||
fprintf(reportfd, " Crash secs ago: %ld\n",
|
||||
(long)(time(NULL) - t));
|
||||
} else {
|
||||
(long)(time(NULL) - t));
|
||||
} else
|
||||
{
|
||||
fprintf(reportfd, "Crash date/time: UNKNOWN\n");
|
||||
fprintf(reportfd, " Crash secs ago: UNKNOWN\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(reportfd, "\n");
|
||||
}
|
||||
|
||||
@@ -358,18 +359,18 @@ int corefile_vs_binary_mismatch(char *coredump)
|
||||
#ifndef _WIN32
|
||||
time_t core, binary;
|
||||
char fname[512];
|
||||
|
||||
|
||||
snprintf(fname, sizeof(fname), "%s/unrealircd", BINDIR);
|
||||
|
||||
|
||||
core = get_file_time(coredump);
|
||||
binary = get_file_time(fname);
|
||||
|
||||
|
||||
if (!core || !binary)
|
||||
return 0; /* don't know then */
|
||||
|
||||
|
||||
if (binary > core)
|
||||
return 1; /* yup, mismatch ;/ */
|
||||
|
||||
|
||||
return 0; /* GOOD! */
|
||||
#else
|
||||
return 0; /* guess we don't check this on Windows? Or will we check UnrealIRCd.exe... hmm.. yeah maybe good idea */
|
||||
@@ -383,7 +384,7 @@ int attach_file(FILE *fdi, FILE *fdo)
|
||||
size_t n, total = 0;
|
||||
|
||||
fprintf(fdo, "\n*** ATTACHMENT ****\n");
|
||||
while((n = fread(binbuf, 1, sizeof(binbuf), fdi)) > 0)
|
||||
while ((n = fread(binbuf, 1, sizeof(binbuf), fdi)) > 0)
|
||||
{
|
||||
b64_encode(binbuf, n, printbuf, sizeof(printbuf));
|
||||
fprintf(fdo, "%s\n", printbuf);
|
||||
@@ -462,14 +463,14 @@ int attach_coredump(FILE *fdo, char *coredump)
|
||||
/* On *NIX we create a .tar.bz2 / .tar.gz (may take a couple of seconds) */
|
||||
printf("Please wait...\n");
|
||||
snprintf(fname, sizeof(fname), "tar c %s/unrealircd %s %s %s 2>/dev/null|(bzip2 || gzip) 2>/dev/null",
|
||||
BINDIR, coredump, MODULESDIR, libcname);
|
||||
BINDIR, coredump, MODULESDIR, libcname);
|
||||
|
||||
fdi = popen(fname, "r");
|
||||
#else
|
||||
/* On Windows we attach de .mdmp, the small minidump file */
|
||||
strlcpy(fname, coredump, sizeof(fname));
|
||||
if (strlen(fname) > 5)
|
||||
fname[strlen(fname)-5] = '\0'; /* cut off the '.core' part */
|
||||
fname[strlen(fname) - 5] = '\0'; /* cut off the '.core' part */
|
||||
strlcat(fname, ".mdmp", sizeof(fname)); /* and add '.mdmp' */
|
||||
fprintf(fdo, "Windows MINIDUMP: %s\n", fname);
|
||||
fdi = fopen(fname, "rb");
|
||||
@@ -496,15 +497,15 @@ char *generate_crash_report(char *coredump, int *thirdpartymods)
|
||||
|
||||
if (coredump == NULL)
|
||||
coredump = find_best_coredump();
|
||||
|
||||
|
||||
if (coredump == NULL)
|
||||
return NULL; /* nothing available */
|
||||
|
||||
if (corefile_vs_binary_mismatch(coredump))
|
||||
return NULL;
|
||||
|
||||
|
||||
snprintf(reportfname, sizeof(reportfname), "%s/crash.report.%s.%ld.txt",
|
||||
TMPDIR, unreal_getfilename(coredump), (long)time(NULL));
|
||||
TMPDIR, unreal_getfilename(coredump), (long)time(NULL));
|
||||
|
||||
reportfd = fopen(reportfname, "w");
|
||||
if (!reportfd)
|
||||
@@ -515,7 +516,7 @@ char *generate_crash_report(char *coredump, int *thirdpartymods)
|
||||
|
||||
crash_report_header(reportfd, coredump);
|
||||
crash_report_fix_libs(coredump, thirdpartymods);
|
||||
|
||||
|
||||
crash_report_backtrace(reportfd, coredump);
|
||||
crash_report_asan_log(reportfd, coredump);
|
||||
attach_coredump(reportfd, coredump);
|
||||
@@ -525,9 +526,9 @@ char *generate_crash_report(char *coredump, int *thirdpartymods)
|
||||
return reportfname;
|
||||
}
|
||||
|
||||
#define REPORT_NEVER -1
|
||||
#define REPORT_ASK 0
|
||||
#define REPORT_AUTO 1
|
||||
#define REPORT_NEVER -1
|
||||
#define REPORT_ASK 0
|
||||
#define REPORT_AUTO 1
|
||||
|
||||
#define CRASH_REPORT_HOST "crash.unrealircd.org"
|
||||
|
||||
@@ -544,20 +545,20 @@ int crashreport_send(char *fname)
|
||||
BIO *socket = NULL;
|
||||
int xfr = 0;
|
||||
char *errstr = NULL;
|
||||
|
||||
|
||||
filesize = get_file_size(fname);
|
||||
if (filesize < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
for (n = 0; n < sizeof(delimiter); n++)
|
||||
delimiter[n] = getrandom8()%26 + 'a';
|
||||
delimiter[sizeof(delimiter)-1] = '\0';
|
||||
|
||||
delimiter[n] = getrandom8() % 26 + 'a';
|
||||
delimiter[sizeof(delimiter) - 1] = '\0';
|
||||
|
||||
snprintf(header, sizeof(header), "--%s\r\n"
|
||||
"Content-Disposition: form-data; name=\"upload\"; filename=\"crash.txt\"\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"\r\n",
|
||||
delimiter);
|
||||
"Content-Disposition: form-data; name=\"upload\"; filename=\"crash.txt\"\r\n"
|
||||
"Content-Type: text/plain\r\n"
|
||||
"\r\n",
|
||||
delimiter);
|
||||
snprintf(footer, sizeof(footer), "\r\n--%s--\r\n", delimiter);
|
||||
|
||||
ctx_client = https_new_ctx();
|
||||
@@ -569,7 +570,7 @@ int crashreport_send(char *fname)
|
||||
|
||||
/* We can safely require TLSv1.3+ on unrealircd.org infra */
|
||||
#if defined(HAS_SSL_CTX_SET_MIN_PROTO_VERSION) && defined(TLS1_3_VERSION)
|
||||
SSL_CTX_set_min_proto_version(ctx_client, TLS1_3_VERSION);
|
||||
SSL_CTX_set_min_proto_version(ctx_client, TLS1_3_VERSION);
|
||||
#endif
|
||||
|
||||
socket = BIO_new_ssl_connect(ctx_client);
|
||||
@@ -578,7 +579,7 @@ int crashreport_send(char *fname)
|
||||
printf("ERROR: TLS initalization failure (II)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BIO_get_ssl(socket, &ssl);
|
||||
if (!ssl)
|
||||
{
|
||||
@@ -595,7 +596,7 @@ int crashreport_send(char *fname)
|
||||
printf("ERROR: Could not connect to %s\n", CRASH_REPORT_HOST);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (BIO_do_handshake(socket) != 1)
|
||||
{
|
||||
printf("ERROR: Could not connect to %s (TLS handshake failed)\n", CRASH_REPORT_HOST);
|
||||
@@ -610,21 +611,21 @@ int crashreport_send(char *fname)
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "POST /crash.php HTTP/1.1\r\n"
|
||||
"User-Agent: UnrealIRCd %s\r\n"
|
||||
"Host: %s\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Accept: */*\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"Expect: 100-continue\r\n"
|
||||
"Content-Type: multipart/form-data; boundary=%s\r\n"
|
||||
"\r\n",
|
||||
VERSIONONLY,
|
||||
CRASH_REPORT_HOST,
|
||||
(int)(filesize+strlen(header)+strlen(footer)),
|
||||
delimiter);
|
||||
|
||||
"User-Agent: UnrealIRCd %s\r\n"
|
||||
"Host: %s\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Accept: */*\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"Expect: 100-continue\r\n"
|
||||
"Content-Type: multipart/form-data; boundary=%s\r\n"
|
||||
"\r\n",
|
||||
VERSIONONLY,
|
||||
CRASH_REPORT_HOST,
|
||||
(int)(filesize + strlen(header) + strlen(footer)),
|
||||
delimiter);
|
||||
|
||||
BIO_puts(socket, buf);
|
||||
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
n = BIO_read(socket, buf, 255);
|
||||
if ((n < 0) || strncmp(buf, "HTTP/1.1 100", 12))
|
||||
@@ -639,7 +640,7 @@ int crashreport_send(char *fname)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
fd = fopen(fname, "rb");
|
||||
if (!fd)
|
||||
return 0;
|
||||
@@ -664,7 +665,9 @@ int crashreport_send(char *fname)
|
||||
|
||||
BIO_puts(socket, footer);
|
||||
|
||||
do { } while(BIO_should_retry(socket)); /* make sure we are really finished (you never know with TLS) */
|
||||
do
|
||||
{
|
||||
} while (BIO_should_retry(socket)); /* make sure we are really finished (you never know with TLS) */
|
||||
|
||||
/* Attempt to shut down gracefully (which is a two step process) */
|
||||
if (SSL_shutdown(ssl) == 0)
|
||||
@@ -674,18 +677,18 @@ int crashreport_send(char *fname)
|
||||
printf("\n");
|
||||
#endif
|
||||
BIO_free_all(socket);
|
||||
|
||||
|
||||
SSL_CTX_free(ctx_client);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mark_coredump_as_read(char *coredump)
|
||||
{
|
||||
char buf[512];
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s.%ld.done", coredump, (long)time(NULL));
|
||||
|
||||
|
||||
(void)rename(coredump, buf);
|
||||
}
|
||||
|
||||
@@ -693,11 +696,12 @@ static int report_pref = REPORT_ASK;
|
||||
|
||||
void report_crash_not_sent(char *fname)
|
||||
{
|
||||
printf("Crash report will not be sent to UnrealIRCd Team.\n"
|
||||
"\n"
|
||||
"Feel free to read the report at %s and delete it.\n"
|
||||
"Or, if you change your mind, you can submit it anyway at https://bugs.unrealircd.org/\n"
|
||||
" (if you do, please set the option 'View Status' at the end of the bug report page to 'private'!!)\n", fname);
|
||||
printf("Crash report will not be sent to UnrealIRCd Team.\n"
|
||||
"\n"
|
||||
"Feel free to read the report at %s and delete it.\n"
|
||||
"Or, if you change your mind, you can submit it anyway at https://bugs.unrealircd.org/\n"
|
||||
" (if you do, please set the option 'View Status' at the end of the bug report page to 'private'!!)\n",
|
||||
fname);
|
||||
}
|
||||
|
||||
/** This checks if there are indications that 3rd party modules are
|
||||
@@ -742,11 +746,11 @@ void report_crash(void)
|
||||
return; /* no crashes */
|
||||
|
||||
crashed_secs_ago = time(NULL) - get_file_time(coredump);
|
||||
if (crashed_secs_ago > 86400*7)
|
||||
if (crashed_secs_ago > 86400 * 7)
|
||||
return; /* stop bothering about it after a while */
|
||||
|
||||
fname = generate_crash_report(coredump, &thirdpartymods);
|
||||
|
||||
|
||||
if (!fname)
|
||||
return;
|
||||
|
||||
@@ -758,24 +762,23 @@ void report_crash(void)
|
||||
|
||||
if (thirdpartymods)
|
||||
{
|
||||
printf("** IMPORTANT **\n"
|
||||
"Your UnrealIRCd crashed and you have 3rd party modules loaded (modules created\n"
|
||||
"by someone other than the UnrealIRCd team). If you installed new 3rd party\n"
|
||||
"module(s) in the past few weeks we suggest to unload these modules and see if\n"
|
||||
"the crash issue dissapears. If so, that module is probably to blame.\n"
|
||||
"If you keep crashing without any 3rd party modules loaded then please do report\n"
|
||||
"it to the UnrealIRCd team.\n"
|
||||
"The reason we ask you to do this is because MORE THAN 95%% OF ALL CRASH ISSUES\n"
|
||||
"ARE CAUSED BY 3RD PARTY MODULES and not by an UnrealIRCd bug.\n"
|
||||
"\n");
|
||||
printf("** IMPORTANT **\n"
|
||||
"Your UnrealIRCd crashed and you have 3rd party modules loaded (modules created\n"
|
||||
"by someone other than the UnrealIRCd team). If you installed new 3rd party\n"
|
||||
"module(s) in the past few weeks we suggest to unload these modules and see if\n"
|
||||
"the crash issue dissapears. If so, that module is probably to blame.\n"
|
||||
"If you keep crashing without any 3rd party modules loaded then please do report\n"
|
||||
"it to the UnrealIRCd team.\n"
|
||||
"The reason we ask you to do this is because MORE THAN 95%% OF ALL CRASH ISSUES\n"
|
||||
"ARE CAUSED BY 3RD PARTY MODULES and not by an UnrealIRCd bug.\n"
|
||||
"\n");
|
||||
}
|
||||
|
||||
|
||||
if (report_pref == REPORT_NEVER)
|
||||
{
|
||||
report_crash_not_sent(fname);
|
||||
return;
|
||||
} else
|
||||
if (report_pref == REPORT_ASK)
|
||||
} else if (report_pref == REPORT_ASK)
|
||||
{
|
||||
char answerbuf[64], *answer;
|
||||
printf("Shall I send a crash report to the UnrealIRCd developers?\n");
|
||||
@@ -784,13 +787,13 @@ void report_crash(void)
|
||||
else
|
||||
printf("NOTE: If the crash is caused by a 3rd party module then UnrealIRCd devs can't fix that.\n");
|
||||
printf("\n");
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
printf("Answer (Y/N): ");
|
||||
*answerbuf = '\0';
|
||||
answer = fgets(answerbuf, sizeof(answerbuf), stdin);
|
||||
|
||||
|
||||
if (answer && (toupper(*answer) == 'N'))
|
||||
{
|
||||
report_crash_not_sent(fname);
|
||||
@@ -800,9 +803,9 @@ void report_crash(void)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf("Invalid response. Please enter either Y or N\n\n");
|
||||
} while(1);
|
||||
} while (1);
|
||||
} else if (report_pref != REPORT_AUTO)
|
||||
{
|
||||
printf("Huh. report_pref setting is weird. Aborting.\n");
|
||||
@@ -817,7 +820,7 @@ void report_crash(void)
|
||||
"give you feedback about the crash? This is completely optional, just press ENTER to skip.\n\n"
|
||||
"E-mail address (optional): ");
|
||||
line = fgets(buf, sizeof(buf), stdin);
|
||||
|
||||
|
||||
if (line && *line && (*line != '\n'))
|
||||
{
|
||||
FILE *fd = fopen(fname, "a");
|
||||
@@ -832,7 +835,7 @@ void report_crash(void)
|
||||
"Again, this is completely optional. Just press ENTER to skip.\n\n"
|
||||
"Additional information (optional): ");
|
||||
line = fgets(buf, sizeof(buf), stdin);
|
||||
|
||||
|
||||
if (line && *line && (*line != '\n'))
|
||||
{
|
||||
FILE *fd = fopen(fname, "a");
|
||||
@@ -852,27 +855,27 @@ void report_crash(void)
|
||||
#else
|
||||
/* Windows */
|
||||
if (MessageBox(NULL, "UnrealIRCd crashed. May I send a report about this to the UnrealIRCd developers? This helps us a lot.",
|
||||
"UnrealIRCd crash",
|
||||
MB_YESNO|MB_ICONQUESTION) == IDYES)
|
||||
"UnrealIRCd crash",
|
||||
MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||
{
|
||||
/* Yay */
|
||||
|
||||
|
||||
if (crashreport_send(fname))
|
||||
{
|
||||
MessageBox(NULL, "The crash report has been sent to the UnrealIRCd developers. "
|
||||
"If you have any additional information (like details surrounding "
|
||||
"the crash) then please e-mail syzop@unrealircd.org, such "
|
||||
"information is most welcome. Thanks!",
|
||||
"UnrealIRCd crash report sent", MB_ICONINFORMATION|MB_OK);
|
||||
"UnrealIRCd crash report sent", MB_ICONINFORMATION | MB_OK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mark_coredump_as_read(coredump);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
if (MessageBox(NULL, "Start UnrealIRCd again?",
|
||||
"UnrealIRCd crash",
|
||||
MB_YESNO|MB_ICONQUESTION) == IDYES)
|
||||
"UnrealIRCd crash",
|
||||
MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||
{
|
||||
StartUnrealAgain();
|
||||
}
|
||||
|
||||
+18
-14
@@ -129,7 +129,7 @@ void dbuf_delete(dbuf *dyn, size_t length)
|
||||
**
|
||||
** Partially based on extract_one_line() from ircd-hybrid. --kaniini
|
||||
*/
|
||||
int dbuf_getmsg(dbuf *dyn, char *buf)
|
||||
int dbuf_getmsg(dbuf *dyn, char *buf)
|
||||
{
|
||||
dbufbuf *block;
|
||||
int line_bytes = 0, empty_bytes = 0, phase = 0;
|
||||
@@ -159,17 +159,20 @@ int dbuf_getmsg(dbuf *dyn, char *buf)
|
||||
empty_bytes++;
|
||||
if (phase == 1)
|
||||
phase = 2;
|
||||
}
|
||||
else switch (phase)
|
||||
{
|
||||
case 0: phase = 1; /* FALLTHROUGH */
|
||||
case 1: if (line_bytes++ < READBUFSIZE - 2)
|
||||
*p++ = c;
|
||||
break;
|
||||
case 2: *p = '\0';
|
||||
dbuf_delete(dyn, line_bytes + empty_bytes);
|
||||
return MIN(line_bytes, READBUFSIZE - 2);
|
||||
}
|
||||
} else
|
||||
switch (phase)
|
||||
{
|
||||
case 0:
|
||||
phase = 1; /* FALLTHROUGH */
|
||||
case 1:
|
||||
if (line_bytes++ < READBUFSIZE - 2)
|
||||
*p++ = c;
|
||||
break;
|
||||
case 2:
|
||||
*p = '\0';
|
||||
dbuf_delete(dyn, line_bytes + empty_bytes);
|
||||
return MIN(line_bytes, READBUFSIZE - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +183,8 @@ int dbuf_getmsg(dbuf *dyn, char *buf)
|
||||
*/
|
||||
line_bytes = 0;
|
||||
*buf = '\0';
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Zero terminate the string */
|
||||
*p = '\0';
|
||||
}
|
||||
@@ -203,7 +207,7 @@ int dbuf_get(dbuf *dyn, char **buf)
|
||||
|
||||
/* First calculate the room needed... */
|
||||
list_for_each_entry2(block, dbufbuf, &dyn->dbuf_list, dbuf_node)
|
||||
bytes += block->size;
|
||||
bytes += block->size;
|
||||
|
||||
d = *buf = safe_alloc(bytes + 1);
|
||||
|
||||
|
||||
+37
-39
@@ -29,59 +29,58 @@
|
||||
/** String of server options in this compile (eg 'D' for debug mode).
|
||||
*/
|
||||
MODVAR char serveropts[] = {
|
||||
#ifdef DEBUGMODE
|
||||
'D',
|
||||
#ifdef DEBUGMODE
|
||||
'D',
|
||||
#endif
|
||||
/* FDLIST (always) */
|
||||
'F',
|
||||
/* Hub (always) */
|
||||
'h',
|
||||
/* NOSPOOF (always) */
|
||||
'n',
|
||||
#ifdef VALLOC
|
||||
'V',
|
||||
/* FDLIST (always) */
|
||||
'F',
|
||||
/* Hub (always) */
|
||||
'h',
|
||||
/* NOSPOOF (always) */
|
||||
'n',
|
||||
#ifdef VALLOC
|
||||
'V',
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
'W',
|
||||
#ifdef _WIN32
|
||||
'W',
|
||||
#endif
|
||||
#ifdef USE_SYSLOG
|
||||
'Y',
|
||||
#ifdef USE_SYSLOG
|
||||
'Y',
|
||||
#endif
|
||||
'6',
|
||||
'6',
|
||||
#ifndef NO_OPEROVERRIDE
|
||||
'O',
|
||||
'O',
|
||||
#endif
|
||||
#ifndef OPEROVERRIDE_VERIFY
|
||||
'o',
|
||||
'o',
|
||||
#endif
|
||||
'E',
|
||||
'E',
|
||||
#ifdef USE_LIBCURL
|
||||
'r',
|
||||
'r',
|
||||
#endif
|
||||
'\0', /* Don't change those nuls. -- Syzop */
|
||||
'\0',
|
||||
'\0',
|
||||
'\0',
|
||||
'\0',
|
||||
'\0', /* Don't change those nuls. -- Syzop */
|
||||
'\0',
|
||||
'\0',
|
||||
'\0',
|
||||
'\0',
|
||||
};
|
||||
|
||||
char *extraflags = NULL;
|
||||
|
||||
MODVAR int debugfd = 2;
|
||||
|
||||
void flag_add(char ch)
|
||||
void flag_add(char ch)
|
||||
{
|
||||
char *newextra;
|
||||
if (extraflags)
|
||||
{
|
||||
char tmp[2] = { ch, 0 };
|
||||
char tmp[2] = {ch, 0};
|
||||
newextra = safe_alloc(strlen(extraflags) + 2);
|
||||
strcpy(newextra, extraflags);
|
||||
strcat(newextra, tmp);
|
||||
safe_free(extraflags);
|
||||
extraflags = newextra;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
extraflags = safe_alloc(2);
|
||||
extraflags[0] = ch;
|
||||
@@ -89,12 +88,12 @@ void flag_add(char ch)
|
||||
}
|
||||
}
|
||||
|
||||
void flag_del(char ch)
|
||||
void flag_del(char ch)
|
||||
{
|
||||
int newsz;
|
||||
char *p, *op;
|
||||
char *newflags;
|
||||
newsz = 0;
|
||||
newsz = 0;
|
||||
p = extraflags;
|
||||
for (newsz = 0, p = extraflags; *p; p++)
|
||||
if (*p != ch)
|
||||
@@ -109,14 +108,13 @@ void flag_del(char ch)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
|
||||
#ifndef _WIN32
|
||||
#define SET_ERRNO(x) errno = x
|
||||
#else
|
||||
#define SET_ERRNO(x) WSASetLastError(x)
|
||||
#endif /* _WIN32 */
|
||||
#ifndef _WIN32
|
||||
#define SET_ERRNO(x) errno = x
|
||||
#else
|
||||
#define SET_ERRNO(x) WSASetLastError(x)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static char debugbuf[4096];
|
||||
|
||||
@@ -131,17 +129,17 @@ void debug(int level, FORMAT_STRING(const char *form), ...)
|
||||
{
|
||||
(void)ircvsnprintf(debugbuf, sizeof(debugbuf), form, vl);
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
strlcat(debugbuf, "\n", sizeof(debugbuf));
|
||||
if (write(debugfd, debugbuf, strlen(debugbuf)) < 0)
|
||||
{
|
||||
/* Yeah.. what can we do if output isn't working? Outputting an error makes no sense */
|
||||
;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
strlcat(debugbuf, "\r\n", sizeof(debugbuf));
|
||||
OutputDebugString(debugbuf);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
va_end(vl);
|
||||
SET_ERRNO(err);
|
||||
|
||||
+72
-75
@@ -23,20 +23,20 @@
|
||||
|
||||
/* Do we even support this, poll on Windows? */
|
||||
#ifdef BACKEND_POLL
|
||||
#ifndef _WIN32
|
||||
# include <poll.h>
|
||||
#else
|
||||
# define poll WSAPoll
|
||||
# define POLLRDHUP POLLHUP
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#else
|
||||
#define poll WSAPoll
|
||||
#define POLLRDHUP POLLHUP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <WinSock2.h>
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
/* Not sure if this is suitable for production,
|
||||
@@ -101,9 +101,9 @@ void fd_setselect_real(int fd, int flags, IOCallbackFunc iocb, void *data)
|
||||
***************************************************************************************/
|
||||
#ifdef BACKEND_SELECT
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
static int highest_fd = -1;
|
||||
static fd_set read_fds, write_fds;
|
||||
@@ -118,8 +118,7 @@ void fd_refresh(int fd)
|
||||
flags |= FD_SELECT_READ;
|
||||
|
||||
FD_SET(fd, &read_fds);
|
||||
}
|
||||
else
|
||||
} else
|
||||
FD_CLR(fd, &read_fds);
|
||||
|
||||
if (fde->write_callback)
|
||||
@@ -127,15 +126,14 @@ void fd_refresh(int fd)
|
||||
flags |= FD_SELECT_WRITE;
|
||||
|
||||
FD_SET(fd, &write_fds);
|
||||
}
|
||||
else
|
||||
} else
|
||||
FD_CLR(fd, &write_fds);
|
||||
|
||||
if (flags && highest_fd < fd)
|
||||
highest_fd = fd;
|
||||
|
||||
while (highest_fd > 0 &&
|
||||
!(FD_ISSET(highest_fd, &read_fds) || FD_ISSET(highest_fd, &write_fds)))
|
||||
!(FD_ISSET(highest_fd, &read_fds) || FD_ISSET(highest_fd, &write_fds)))
|
||||
highest_fd--;
|
||||
|
||||
fde->backend_flags = flags;
|
||||
@@ -154,8 +152,8 @@ void fd_debug(fd_set *f, int highest, char *name)
|
||||
if (ioctlsocket(i, FIONBIO, &nonb) < 0)
|
||||
{
|
||||
unreal_log(ULOG_ERROR, "io", "FD_DEBUG", NULL,
|
||||
"[BUG] fd_debug: fd $fd is invalid!!!",
|
||||
log_data_integer("fd", i));
|
||||
"[BUG] fd_debug: fd $fd is invalid!!!",
|
||||
log_data_integer("fd", i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,26 +164,26 @@ void fd_select(int delay)
|
||||
int num, fd;
|
||||
fd_set work_read_fds;
|
||||
fd_set work_write_fds;
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
fd_set work_except_fds; /* only needed on windows as it may indicate a failed connect() */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* copy the FD sets so that our master sets are untouched */
|
||||
memcpy(&work_read_fds, &read_fds, sizeof(fd_set));
|
||||
memcpy(&work_write_fds, &write_fds, sizeof(fd_set));
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
memcpy(&work_except_fds, &write_fds, sizeof(fd_set));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
memset(&to, 0, sizeof(to));
|
||||
to.tv_sec = delay / 1000;
|
||||
to.tv_usec = (delay % 1000) * 1000;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
num = select(highest_fd + 1, &work_read_fds, &work_write_fds, &work_except_fds, &to);
|
||||
#else
|
||||
#else
|
||||
num = select(highest_fd + 1, &work_read_fds, &work_write_fds, NULL, &to);
|
||||
#endif
|
||||
#endif
|
||||
if (num < 0)
|
||||
{
|
||||
unreal_log(ULOG_FATAL, "io", "SELECT_ERROR", NULL,
|
||||
@@ -194,11 +192,11 @@ void fd_select(int delay)
|
||||
/* DEBUG the actual problem: */
|
||||
memcpy(&work_read_fds, &read_fds, sizeof(fd_set));
|
||||
memcpy(&work_write_fds, &write_fds, sizeof(fd_set));
|
||||
fd_debug(&work_read_fds, highest_fd+1, "read");
|
||||
fd_debug(&work_write_fds, highest_fd+1, "write");
|
||||
#ifdef _WIN32
|
||||
fd_debug(&work_read_fds, highest_fd + 1, "read");
|
||||
fd_debug(&work_write_fds, highest_fd + 1, "write");
|
||||
#ifdef _WIN32
|
||||
Sleep(500);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (num <= 0)
|
||||
@@ -220,11 +218,11 @@ void fd_select(int delay)
|
||||
if (FD_ISSET(fd, &work_write_fds))
|
||||
evflags |= FD_SELECT_WRITE;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
/* Exception may happen due to failed connect. Translate to write event, like on *NIX. */
|
||||
if (FD_ISSET(fd, &work_except_fds))
|
||||
evflags |= FD_SELECT_WRITE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!evflags)
|
||||
continue;
|
||||
@@ -260,7 +258,7 @@ void fd_fork()
|
||||
***************************************************************************************/
|
||||
#ifdef BACKEND_KQUEUE
|
||||
|
||||
#include <sys/event.h>
|
||||
#include <sys/event.h>
|
||||
|
||||
static int kqueue_fd = -1;
|
||||
static struct kevent kqueue_events[MAXCONNECTIONS * 2];
|
||||
@@ -272,20 +270,20 @@ void fd_fork()
|
||||
kqueue_fd = kqueue();
|
||||
int p;
|
||||
|
||||
for (p=0; p < MAXCONNECTIONS * 2; ++p)
|
||||
for (p = 0; p < MAXCONNECTIONS * 2; ++p)
|
||||
{
|
||||
if (kqueue_enabled[p])
|
||||
{
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[p], 1, NULL, 0, &(const struct timespec){ .tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[p], 1, NULL, 0, &(const struct timespec){.tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
{
|
||||
if (ERRNO == P_EWOULDBLOCK || ERRNO == P_EAGAIN)
|
||||
continue;
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
unreal_log(ULOG_ERROR, "io", "KEVENT_FAILED", NULL,
|
||||
"[io] fd_fork(): kevent returned error: $system_error",
|
||||
log_data_string("system_error", strerror(errno)));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,18 +296,18 @@ void fd_refresh(int fd)
|
||||
if (kqueue_fd == -1)
|
||||
{
|
||||
kqueue_fd = kqueue();
|
||||
memset(kqueue_enabled,0,MAXCONNECTIONS*2);
|
||||
memset(kqueue_enabled, 0, MAXCONNECTIONS * 2);
|
||||
}
|
||||
|
||||
kqueue_enabled[fd] = 0;
|
||||
kqueue_enabled[fd+MAXCONNECTIONS] = 0;
|
||||
kqueue_enabled[fd + MAXCONNECTIONS] = 0;
|
||||
|
||||
if (fde->read_callback != NULL || fde->backend_flags & EVFILT_READ)
|
||||
{
|
||||
EV_SET(&kqueue_prepared[fd], (uintptr_t) fd, (short) EVFILT_READ, fde->read_callback != NULL ? EV_ADD : EV_DELETE, 0, 0, fde);
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[fd], 1, NULL, 0, &(const struct timespec){ .tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
EV_SET(&kqueue_prepared[fd], (uintptr_t)fd, (short)EVFILT_READ, fde->read_callback != NULL ? EV_ADD : EV_DELETE, 0, 0, fde);
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[fd], 1, NULL, 0, &(const struct timespec){.tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
if (ERRNO != P_EWOULDBLOCK && ERRNO != P_EAGAIN)
|
||||
{
|
||||
int save_err = errno;
|
||||
@@ -320,16 +318,16 @@ void fd_refresh(int fd)
|
||||
log_data_string("fd_action", (fde->read_callback ? "add" : "delete")),
|
||||
log_data_string("callback", "read_callback"));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (fde->write_callback != NULL || fde->backend_flags & EVFILT_WRITE)
|
||||
{
|
||||
EV_SET(&kqueue_prepared[fd+MAXCONNECTIONS], (uintptr_t) fd, (short) EVFILT_WRITE, fde->write_callback != NULL ? EV_ADD : EV_DELETE, 0, 0, fde);
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[fd+MAXCONNECTIONS], 1, NULL, 0, &(const struct timespec){ .tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
EV_SET(&kqueue_prepared[fd + MAXCONNECTIONS], (uintptr_t)fd, (short)EVFILT_WRITE, fde->write_callback != NULL ? EV_ADD : EV_DELETE, 0, 0, fde);
|
||||
if (kevent(kqueue_fd, &kqueue_prepared[fd + MAXCONNECTIONS], 1, NULL, 0, &(const struct timespec){.tv_sec = 0, .tv_nsec = 0}) != 0)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
if (ERRNO != P_EWOULDBLOCK && ERRNO != P_EAGAIN && fde->write_callback)
|
||||
{
|
||||
int save_err = errno;
|
||||
@@ -340,7 +338,7 @@ void fd_refresh(int fd)
|
||||
log_data_string("fd_action", "add"),
|
||||
log_data_string("callback", "write_callback"));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,13 +348,12 @@ void fd_refresh(int fd)
|
||||
{
|
||||
fde->backend_flags |= EVFILT_READ;
|
||||
kqueue_enabled[fd] = 1;
|
||||
|
||||
}
|
||||
|
||||
if (fde->write_callback != NULL)
|
||||
{
|
||||
fde->backend_flags |= EVFILT_WRITE;
|
||||
kqueue_enabled[fd+MAXCONNECTIONS] = 1;
|
||||
kqueue_enabled[fd + MAXCONNECTIONS] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +366,7 @@ void fd_select(int delay)
|
||||
if (kqueue_fd == -1)
|
||||
{
|
||||
kqueue_fd = kqueue();
|
||||
memset(kqueue_enabled,0,MAXCONNECTIONS*2);
|
||||
memset(kqueue_enabled, 0, MAXCONNECTIONS * 2);
|
||||
}
|
||||
|
||||
memset(&ts, 0, sizeof(ts));
|
||||
@@ -415,7 +412,7 @@ void fd_select(int delay)
|
||||
***************************************************************************************/
|
||||
#ifdef BACKEND_EPOLL
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
static int epoll_fd = -1;
|
||||
static struct epoll_event epfds[MAXCONNECTIONS + 1];
|
||||
@@ -459,10 +456,10 @@ void fd_refresh(int fd)
|
||||
return;
|
||||
|
||||
unreal_log(ULOG_ERROR, "io", "EPOLL_CTL_FAILED", NULL,
|
||||
"[io] fd_refresh(): epoll_ctl returned error for fd $fd ($fd_description): $system_error",
|
||||
log_data_string("system_error", strerror(save_errno)),
|
||||
log_data_integer("fd", fd),
|
||||
log_data_string("fd_description", fde->desc));
|
||||
"[io] fd_refresh(): epoll_ctl returned error for fd $fd ($fd_description): $system_error",
|
||||
log_data_string("system_error", strerror(save_errno)),
|
||||
log_data_integer("fd", fd),
|
||||
log_data_string("fd_description", fde->desc));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -473,11 +470,11 @@ void fd_select(int delay)
|
||||
{
|
||||
int num, p, revents, fd;
|
||||
struct epoll_event *epfd;
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
int read_callbacks = 0, write_callbacks = 0;
|
||||
struct timeval oldt, t;
|
||||
long long tdiff;
|
||||
#endif
|
||||
#endif
|
||||
if (epoll_fd == -1)
|
||||
epoll_fd = epoll_create(MAXCONNECTIONS);
|
||||
|
||||
@@ -485,9 +482,9 @@ void fd_select(int delay)
|
||||
if (num <= 0)
|
||||
return;
|
||||
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
gettimeofday(&oldt, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for (p = 0; p < num; p++)
|
||||
{
|
||||
@@ -517,9 +514,9 @@ void fd_select(int delay)
|
||||
if (iocb != NULL)
|
||||
iocb(fd, evflags, fde->data);
|
||||
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
read_callbacks++;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (evflags & FD_SELECT_WRITE)
|
||||
@@ -529,20 +526,20 @@ void fd_select(int delay)
|
||||
if (iocb != NULL)
|
||||
iocb(fd, evflags, fde->data);
|
||||
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
write_callbacks++;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
#if 0
|
||||
if (((read_callbacks + write_callbacks) % 100) == 0)
|
||||
{
|
||||
/* every 100 events.. set the internal clock so we don't screw up under extreme load */
|
||||
timeofday = time(NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
#ifdef DETECT_HIGH_CPU
|
||||
gettimeofday(&t, NULL);
|
||||
tdiff = ((t.tv_sec - oldt.tv_sec) * 1000000) + (t.tv_usec - oldt.tv_usec);
|
||||
|
||||
@@ -551,11 +548,11 @@ void fd_select(int delay)
|
||||
unreal_log(ULOG_WARNING, "io", "HIGH_LOAD", NULL,
|
||||
"HIGH CPU LOAD! fd_select() took $time_msec msec "
|
||||
"(read: $num_read_callbacks, write: $num_write_callbacks)",
|
||||
log_data_integer("time_msec", tdiff/1000),
|
||||
log_data_integer("time_msec", tdiff / 1000),
|
||||
log_data_integer("num_read_callbacks", read_callbacks),
|
||||
log_data_integer("num_write_callbacks", write_callbacks));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -570,12 +567,12 @@ void fd_fork()
|
||||
***************************************************************************************/
|
||||
#ifdef BACKEND_POLL
|
||||
|
||||
#ifndef POLLRDNORM
|
||||
# define POLLRDNORM POLLIN
|
||||
#endif
|
||||
#ifndef POLLWRNORM
|
||||
# define POLLWRNORM POLLOUT
|
||||
#endif
|
||||
#ifndef POLLRDNORM
|
||||
#define POLLRDNORM POLLIN
|
||||
#endif
|
||||
#ifndef POLLWRNORM
|
||||
#define POLLWRNORM POLLOUT
|
||||
#endif
|
||||
|
||||
static struct pollfd pollfds[FD_SETSIZE];
|
||||
static nfds_t nfds = 0;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
* and perhaps by then it is long enough that we don't need the fallback to older
|
||||
* functions.
|
||||
*/
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
/* Forward declerations */
|
||||
@@ -73,8 +73,8 @@ ares_channel resolver_channel_https; /**< The resolver channel for HTTPS request
|
||||
ares_channel resolver_channel_dnsbl; /**< The resolver channel for DNSBLs. */
|
||||
|
||||
#define RESOLVER_CHANNEL_CLIENT (void *)0x1
|
||||
#define RESOLVER_CHANNEL_HTTPS (void *)0x2
|
||||
#define RESOLVER_CHANNEL_DNSBL (void *)0x3
|
||||
#define RESOLVER_CHANNEL_HTTPS (void *)0x2
|
||||
#define RESOLVER_CHANNEL_DNSBL (void *)0x3
|
||||
|
||||
DNSStats dnsstats;
|
||||
|
||||
@@ -124,7 +124,7 @@ static void unrealdns_sock_state_cb(void *data, ares_socket_t fd, int read, int
|
||||
fd_close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (read)
|
||||
selflags |= FD_SELECT_READ;
|
||||
|
||||
@@ -175,7 +175,7 @@ void init_resolver(int firsttime)
|
||||
|
||||
if (requests)
|
||||
abort(); /* should never happen */
|
||||
|
||||
|
||||
if (firsttime)
|
||||
{
|
||||
memset(&cache_hashtbl, 0, sizeof(cache_hashtbl));
|
||||
@@ -185,14 +185,14 @@ void init_resolver(int firsttime)
|
||||
}
|
||||
|
||||
memset(&options, 0, sizeof(options));
|
||||
options.flags |= ARES_FLAG_NOALIASES|ARES_FLAG_IGNTC;
|
||||
options.flags |= ARES_FLAG_NOALIASES | ARES_FLAG_IGNTC;
|
||||
options.sock_state_cb = unrealdns_sock_state_cb;
|
||||
/* Don't search domains or you'll get lookups for like
|
||||
* 1.1.168.192.dnsbl.dronebl.org.mydomain.org which is a waste.
|
||||
*/
|
||||
options.domains = NULL;
|
||||
options.ndomains = 0;
|
||||
optmask = ARES_OPT_TIMEOUTMS|ARES_OPT_TRIES|ARES_OPT_FLAGS|ARES_OPT_SOCK_STATE_CB|ARES_OPT_DOMAINS;
|
||||
optmask = ARES_OPT_TIMEOUTMS | ARES_OPT_TRIES | ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB | ARES_OPT_DOMAINS;
|
||||
#ifndef _WIN32
|
||||
/* on *NIX don't use the hosts file, since it causes countless useless reads.
|
||||
* on Windows we use it for now, this could be changed in the future.
|
||||
@@ -352,7 +352,8 @@ struct hostent *unrealdns_doclient(Client *client)
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
inet_pton(AF_INET6, client->ip, &addr);
|
||||
ares_gethostbyaddr(resolver_channel_client, &addr, 16, AF_INET6, unrealdns_cb_iptoname, r);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
struct in_addr addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
inet_pton(AF_INET, client->ip, &addr);
|
||||
@@ -394,8 +395,8 @@ void unrealdns_cb_iptoname(void *arg, int status, int timeouts, struct hostent *
|
||||
unrealdns_freeandremovereq(r);
|
||||
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
/* Check for status and null name (yes, we must) */
|
||||
if ((status != 0) || !he->h_name || !*he->h_name)
|
||||
{
|
||||
@@ -444,7 +445,8 @@ void unrealdns_cb_nametoip_verify(void *arg, int status, int timeouts, struct ho
|
||||
continue; /* something fucked */
|
||||
if (!memcmp(he->h_addr_list[i], &addr, 16))
|
||||
break; /* MATCH */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
struct in_addr addr;
|
||||
if (inet_pton(AF_INET, client->ip, &addr) != 1)
|
||||
continue; /* something fucked */
|
||||
@@ -486,7 +488,7 @@ void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct host
|
||||
DNSReq *r = (DNSReq *)arg;
|
||||
int n;
|
||||
struct hostent *he2;
|
||||
char ipbuf[HOSTLEN+1];
|
||||
char ipbuf[HOSTLEN + 1];
|
||||
const char *ip = NULL;
|
||||
|
||||
if (!r->linkblock)
|
||||
@@ -509,8 +511,8 @@ void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct host
|
||||
|
||||
/* fatal error while resolving */
|
||||
unreal_log(ULOG_ERROR, "link", "LINK_ERROR_RESOLVING", NULL,
|
||||
"Unable to resolve hostname $link_block.hostname, when trying to connect to server $link_block.",
|
||||
log_data_link_block(r->linkblock));
|
||||
"Unable to resolve hostname $link_block.hostname, when trying to connect to server $link_block.",
|
||||
log_data_link_block(r->linkblock));
|
||||
r->linkblock->refcount--;
|
||||
unrealdns_freeandremovereq(r);
|
||||
return;
|
||||
@@ -527,7 +529,7 @@ void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct host
|
||||
unrealdns_freeandremovereq(r);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Ok, since we got here, it seems things were actually succesfull */
|
||||
|
||||
/* Fill in [linkblockstruct]->ipnum */
|
||||
@@ -543,7 +545,7 @@ void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct host
|
||||
|
||||
static uint64_t unrealdns_hash_ip(const char *ip)
|
||||
{
|
||||
return siphash(ip, siphashkey_dns_ip) % DNS_HASH_SIZE;
|
||||
return siphash(ip, siphashkey_dns_ip) % DNS_HASH_SIZE;
|
||||
}
|
||||
|
||||
static void unrealdns_addtocache(const char *name, const char *ip)
|
||||
@@ -557,7 +559,7 @@ static void unrealdns_addtocache(const char *name, const char *ip)
|
||||
|
||||
/* Check first if it is already present in the cache.
|
||||
* This is possible, when 2 clients connect at the same time.
|
||||
*/
|
||||
*/
|
||||
for (c = cache_hashtbl[hashv]; c; c = c->hnext)
|
||||
if (!strcmp(ip, c->ip))
|
||||
return; /* already present in cache */
|
||||
@@ -565,7 +567,8 @@ static void unrealdns_addtocache(const char *name, const char *ip)
|
||||
/* Remove last item, if we got too many entries.. */
|
||||
if (unrealdns_num_cache >= DNS_MAX_ENTRIES)
|
||||
{
|
||||
for (c = cache_list; c->next; c = c->next);
|
||||
for (c = cache_list; c->next; c = c->next)
|
||||
;
|
||||
unrealdns_removecacherecord(c);
|
||||
}
|
||||
|
||||
@@ -577,7 +580,7 @@ static void unrealdns_addtocache(const char *name, const char *ip)
|
||||
c->expires = TStime() + DNS_NEGCACHE_TTL;
|
||||
else
|
||||
c->expires = TStime() + DNS_CACHE_TTL;
|
||||
|
||||
|
||||
/* Add to hash table */
|
||||
if (cache_hashtbl[hashv])
|
||||
{
|
||||
@@ -585,7 +588,7 @@ static void unrealdns_addtocache(const char *name, const char *ip)
|
||||
c->hnext = cache_hashtbl[hashv];
|
||||
}
|
||||
cache_hashtbl[hashv] = c;
|
||||
|
||||
|
||||
/* Add to linked list */
|
||||
if (cache_list)
|
||||
{
|
||||
@@ -607,7 +610,7 @@ static const char *unrealdns_findcache_ip(const char *ip, int *found)
|
||||
DNSCache *c;
|
||||
|
||||
hashv = unrealdns_hash_ip(ip);
|
||||
|
||||
|
||||
for (c = cache_hashtbl[hashv]; c; c = c->hnext)
|
||||
{
|
||||
if (!strcmp(ip, c->ip))
|
||||
@@ -617,7 +620,7 @@ static const char *unrealdns_findcache_ip(const char *ip, int *found)
|
||||
return c->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dnsstats.cache_misses++;
|
||||
*found = 0;
|
||||
return NULL;
|
||||
@@ -627,7 +630,7 @@ static const char *unrealdns_findcache_ip(const char *ip, int *found)
|
||||
*/
|
||||
void unrealdns_removecacherecord(DNSCache *c)
|
||||
{
|
||||
unsigned int hashv;
|
||||
unsigned int hashv;
|
||||
|
||||
/* We basically got 4 pointers to update:
|
||||
* <previous listitem>->next
|
||||
@@ -640,23 +643,24 @@ unsigned int hashv;
|
||||
c->prev->next = c->next;
|
||||
else
|
||||
cache_list = c->next; /* new list HEAD */
|
||||
|
||||
|
||||
if (c->next)
|
||||
c->next->prev = c->prev;
|
||||
|
||||
|
||||
if (c->hprev)
|
||||
c->hprev->hnext = c->hnext;
|
||||
else {
|
||||
else
|
||||
{
|
||||
/* new hash HEAD */
|
||||
hashv = unrealdns_hash_ip(c->ip);
|
||||
if (cache_hashtbl[hashv] != c)
|
||||
abort(); /* impossible */
|
||||
cache_hashtbl[hashv] = c->hnext;
|
||||
}
|
||||
|
||||
|
||||
if (c->hnext)
|
||||
c->hnext->hprev = c->hprev;
|
||||
|
||||
|
||||
safe_free(c->name);
|
||||
safe_free(c->ip);
|
||||
safe_free(c);
|
||||
@@ -667,7 +671,7 @@ unsigned int hashv;
|
||||
/** This regulary removes old dns records from the cache */
|
||||
EVENT(unrealdns_removeoldrecords)
|
||||
{
|
||||
DNSCache *c, *next;
|
||||
DNSCache *c, *next;
|
||||
|
||||
for (c = cache_list; c; c = next)
|
||||
{
|
||||
@@ -679,7 +683,7 @@ DNSCache *c, *next;
|
||||
|
||||
struct hostent *unreal_create_hostent(const char *name, const char *ip)
|
||||
{
|
||||
struct hostent *he;
|
||||
struct hostent *he;
|
||||
|
||||
/* Create a hostent structure (I HATE HOSTENTS) and return it.. */
|
||||
he = safe_alloc(sizeof(struct hostent));
|
||||
@@ -692,7 +696,8 @@ struct hostent *he;
|
||||
he->h_addr_list = safe_alloc(sizeof(char *) * 2); /* alocate an array of 2 pointers */
|
||||
he->h_addr_list[0] = safe_alloc(sizeof(struct in6_addr));
|
||||
inet_pton(AF_INET6, ip, he->h_addr_list[0]);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
he->h_addrtype = AF_INET;
|
||||
he->h_length = sizeof(struct in_addr);
|
||||
he->h_addr_list = safe_alloc(sizeof(char *) * 2); /* alocate an array of 2 pointers */
|
||||
@@ -717,7 +722,7 @@ static void unrealdns_freeandremovereq(DNSReq *r)
|
||||
r->prev->next = r->next;
|
||||
else
|
||||
requests = r->next; /* new HEAD */
|
||||
|
||||
|
||||
if (r->next)
|
||||
r->next->prev = r->prev;
|
||||
|
||||
@@ -744,7 +749,6 @@ void unrealdns_delasyncconnects(void)
|
||||
for (r = requests; r; r = r->next)
|
||||
if (r->type == DNSREQ_CONNECT)
|
||||
r->linkblock = NULL;
|
||||
|
||||
}
|
||||
|
||||
void dns_check_for_changes(void)
|
||||
@@ -788,7 +792,7 @@ CMD_FUNC(cmd_dns)
|
||||
DNSReq *r;
|
||||
const char *param;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:dns",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:dns", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
@@ -810,18 +814,16 @@ CMD_FUNC(cmd_dns)
|
||||
for (c = cache_list; c; c = c->next)
|
||||
if (!c->name)
|
||||
sendtxtnumeric(client, " %s", c->ip);
|
||||
} else
|
||||
if (*param == 'r') /* LIST REQUESTS */
|
||||
} else if (*param == 'r') /* LIST REQUESTS */
|
||||
{
|
||||
sendtxtnumeric(client, "DNS Request List:");
|
||||
for (r = requests; r; r = r->next)
|
||||
sendtxtnumeric(client, " %s", r->client ? r->client->ip : "<client lost>");
|
||||
} else
|
||||
if (*param == 'c') /* CLEAR CACHE */
|
||||
} else if (*param == 'c') /* CLEAR CACHE */
|
||||
{
|
||||
unreal_log(ULOG_INFO, "dns", "DNS_CACHE_CLEARED", client,
|
||||
"DNS cache cleared by $client");
|
||||
|
||||
"DNS cache cleared by $client");
|
||||
|
||||
while (cache_list)
|
||||
{
|
||||
c = cache_list->next;
|
||||
@@ -833,8 +835,7 @@ CMD_FUNC(cmd_dns)
|
||||
memset(&cache_hashtbl, 0, sizeof(cache_hashtbl));
|
||||
unrealdns_num_cache = 0;
|
||||
sendnotice(client, "DNS Cache has been cleared");
|
||||
} else
|
||||
if (*param == 'i') /* INFORMATION */
|
||||
} else if (*param == 'i') /* INFORMATION */
|
||||
{
|
||||
struct ares_options inf;
|
||||
struct ares_addr_node *serverlist = NULL, *ns;
|
||||
@@ -842,7 +843,7 @@ CMD_FUNC(cmd_dns)
|
||||
int optmask;
|
||||
|
||||
sendtxtnumeric(client, "****** DNS Configuration Information ******");
|
||||
sendtxtnumeric(client, " c-ares version: %s",ares_version(NULL));
|
||||
sendtxtnumeric(client, " c-ares version: %s", ares_version(NULL));
|
||||
|
||||
// Duplicate code follows, because.. yeah.. we use a struct? :D
|
||||
|
||||
@@ -918,8 +919,7 @@ CMD_FUNC(cmd_dns)
|
||||
}
|
||||
|
||||
typedef struct ApiCallbackWrappedArg ApiCallbackWrappedArg;
|
||||
struct ApiCallbackWrappedArg
|
||||
{
|
||||
struct ApiCallbackWrappedArg {
|
||||
char *callback_name;
|
||||
void *callback_arg;
|
||||
};
|
||||
|
||||
+4
-5
@@ -60,9 +60,9 @@ int fd_open(int fd, const char *desc, FDCloseMethod close_method)
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
# define OPEN_MODES S_IRUSR|S_IWUSR
|
||||
#define OPEN_MODES S_IRUSR | S_IWUSR
|
||||
#else
|
||||
# define OPEN_MODES S_IREAD|S_IWRITE
|
||||
#define OPEN_MODES S_IREAD | S_IWRITE
|
||||
#endif
|
||||
|
||||
int fd_fileopen(const char *path, unsigned int flags)
|
||||
@@ -153,11 +153,11 @@ void fd_unnotify(int fd)
|
||||
|
||||
if ((fd < 0) || (fd >= MAXCONNECTIONS))
|
||||
return;
|
||||
|
||||
|
||||
fde = &fd_table[fd];
|
||||
if (!fde || !fde->is_open)
|
||||
return;
|
||||
|
||||
|
||||
fde->read_callback = fde->write_callback = NULL;
|
||||
fd_refresh(fd);
|
||||
}
|
||||
@@ -215,4 +215,3 @@ void fd_desc(int fd, const char *desc)
|
||||
|
||||
strlcpy(fde->desc, desc, FD_DESC_SZ);
|
||||
}
|
||||
|
||||
|
||||
+164
-140
@@ -42,49 +42,50 @@
|
||||
|
||||
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
||||
|
||||
#define U32TO8_LE(p, v) \
|
||||
(p)[0] = (char)((v)); \
|
||||
(p)[1] = (char)((v) >> 8); \
|
||||
(p)[2] = (char)((v) >> 16); \
|
||||
(p)[3] = (char)((v) >> 24);
|
||||
#define U32TO8_LE(p, v) \
|
||||
(p)[0] = (char)((v)); \
|
||||
(p)[1] = (char)((v) >> 8); \
|
||||
(p)[2] = (char)((v) >> 16); \
|
||||
(p)[3] = (char)((v) >> 24);
|
||||
|
||||
#define U64TO8_LE(p, v) \
|
||||
U32TO8_LE((p), (uint32_t)((v))); \
|
||||
U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
|
||||
#define U64TO8_LE(p, v) \
|
||||
U32TO8_LE((p), (uint32_t)((v))); \
|
||||
U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
|
||||
|
||||
#define U8TO64_LE(p) \
|
||||
(((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \
|
||||
((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \
|
||||
((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \
|
||||
((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
|
||||
#define U8TO64_LE(p) \
|
||||
(((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \
|
||||
((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \
|
||||
((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \
|
||||
((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
|
||||
|
||||
#define U8TO64_LE_NOCASE(p) \
|
||||
(((uint64_t)(tolower((p)[0]))) | \
|
||||
((uint64_t)(tolower((p)[1])) << 8) | \
|
||||
((uint64_t)(tolower((p)[2])) << 16) | \
|
||||
((uint64_t)(tolower((p)[3])) << 24) | \
|
||||
((uint64_t)(tolower((p)[4])) << 32) | \
|
||||
((uint64_t)(tolower((p)[5])) << 40) | \
|
||||
((uint64_t)(tolower((p)[6])) << 48) | \
|
||||
((uint64_t)(tolower((p)[7])) << 56))
|
||||
#define U8TO64_LE_NOCASE(p) \
|
||||
(((uint64_t)(tolower((p)[0]))) | \
|
||||
((uint64_t)(tolower((p)[1])) << 8) | \
|
||||
((uint64_t)(tolower((p)[2])) << 16) | \
|
||||
((uint64_t)(tolower((p)[3])) << 24) | \
|
||||
((uint64_t)(tolower((p)[4])) << 32) | \
|
||||
((uint64_t)(tolower((p)[5])) << 40) | \
|
||||
((uint64_t)(tolower((p)[6])) << 48) | \
|
||||
((uint64_t)(tolower((p)[7])) << 56))
|
||||
|
||||
#define SIPROUND \
|
||||
do { \
|
||||
v0 += v1; \
|
||||
v1 = ROTL(v1, 13); \
|
||||
v1 ^= v0; \
|
||||
v0 = ROTL(v0, 32); \
|
||||
v2 += v3; \
|
||||
v3 = ROTL(v3, 16); \
|
||||
v3 ^= v2; \
|
||||
v0 += v3; \
|
||||
v3 = ROTL(v3, 21); \
|
||||
v3 ^= v0; \
|
||||
v2 += v1; \
|
||||
v1 = ROTL(v1, 17); \
|
||||
v1 ^= v2; \
|
||||
v2 = ROTL(v2, 32); \
|
||||
} while (0)
|
||||
#define SIPROUND \
|
||||
do \
|
||||
{ \
|
||||
v0 += v1; \
|
||||
v1 = ROTL(v1, 13); \
|
||||
v1 ^= v0; \
|
||||
v0 = ROTL(v0, 32); \
|
||||
v2 += v3; \
|
||||
v3 = ROTL(v3, 16); \
|
||||
v3 ^= v2; \
|
||||
v0 += v3; \
|
||||
v3 = ROTL(v3, 21); \
|
||||
v3 ^= v0; \
|
||||
v2 += v1; \
|
||||
v1 = ROTL(v1, 17); \
|
||||
v1 ^= v2; \
|
||||
v2 = ROTL(v2, 32); \
|
||||
} while (0)
|
||||
|
||||
/** Generic hash function in UnrealIRCd - raw version.
|
||||
* Note that you probably want siphash() or siphash_nocase() instead.
|
||||
@@ -102,61 +103,72 @@
|
||||
*/
|
||||
uint64_t siphash_raw(const char *in, size_t inlen, const char *k)
|
||||
{
|
||||
uint64_t hash;
|
||||
char *out = (char*) &hash;
|
||||
uint64_t v0 = 0x736f6d6570736575ULL;
|
||||
uint64_t v1 = 0x646f72616e646f6dULL;
|
||||
uint64_t v2 = 0x6c7967656e657261ULL;
|
||||
uint64_t v3 = 0x7465646279746573ULL;
|
||||
uint64_t k0 = U8TO64_LE(k);
|
||||
uint64_t k1 = U8TO64_LE(k + 8);
|
||||
uint64_t m;
|
||||
const char *end = in + inlen - (inlen % sizeof(uint64_t));
|
||||
const int left = inlen & 7;
|
||||
uint64_t b = ((uint64_t)inlen) << 56;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
uint64_t hash;
|
||||
char *out = (char *)&hash;
|
||||
uint64_t v0 = 0x736f6d6570736575ULL;
|
||||
uint64_t v1 = 0x646f72616e646f6dULL;
|
||||
uint64_t v2 = 0x6c7967656e657261ULL;
|
||||
uint64_t v3 = 0x7465646279746573ULL;
|
||||
uint64_t k0 = U8TO64_LE(k);
|
||||
uint64_t k1 = U8TO64_LE(k + 8);
|
||||
uint64_t m;
|
||||
const char *end = in + inlen - (inlen % sizeof(uint64_t));
|
||||
const int left = inlen & 7;
|
||||
uint64_t b = ((uint64_t)inlen) << 56;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
|
||||
for (; in != end; in += 8) {
|
||||
m = U8TO64_LE(in);
|
||||
v3 ^= m;
|
||||
for (; in != end; in += 8)
|
||||
{
|
||||
m = U8TO64_LE(in);
|
||||
v3 ^= m;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= m;
|
||||
}
|
||||
v0 ^= m;
|
||||
}
|
||||
|
||||
switch (left) {
|
||||
case 7: b |= ((uint64_t)in[6]) << 48; /* fallthrough */
|
||||
case 6: b |= ((uint64_t)in[5]) << 40; /* fallthrough */
|
||||
case 5: b |= ((uint64_t)in[4]) << 32; /* fallthrough */
|
||||
case 4: b |= ((uint64_t)in[3]) << 24; /* fallthrough */
|
||||
case 3: b |= ((uint64_t)in[2]) << 16; /* fallthrough */
|
||||
case 2: b |= ((uint64_t)in[1]) << 8; /* fallthrough */
|
||||
case 1: b |= ((uint64_t)in[0]); break;
|
||||
case 0: break;
|
||||
}
|
||||
switch (left)
|
||||
{
|
||||
case 7:
|
||||
b |= ((uint64_t)in[6]) << 48; /* fallthrough */
|
||||
case 6:
|
||||
b |= ((uint64_t)in[5]) << 40; /* fallthrough */
|
||||
case 5:
|
||||
b |= ((uint64_t)in[4]) << 32; /* fallthrough */
|
||||
case 4:
|
||||
b |= ((uint64_t)in[3]) << 24; /* fallthrough */
|
||||
case 3:
|
||||
b |= ((uint64_t)in[2]) << 16; /* fallthrough */
|
||||
case 2:
|
||||
b |= ((uint64_t)in[1]) << 8; /* fallthrough */
|
||||
case 1:
|
||||
b |= ((uint64_t)in[0]);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
v3 ^= b;
|
||||
v3 ^= b;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= b;
|
||||
v2 ^= 0xff;
|
||||
v0 ^= b;
|
||||
v2 ^= 0xff;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out, b);
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out, b);
|
||||
|
||||
return hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
/** Generic hash function in UnrealIRCd - case insensitive.
|
||||
@@ -172,62 +184,73 @@ uint64_t siphash_raw(const char *in, size_t inlen, const char *k)
|
||||
*/
|
||||
uint64_t siphash_nocase(const char *in, const char *k)
|
||||
{
|
||||
uint64_t hash;
|
||||
char *out = (char*) &hash;
|
||||
size_t inlen = strlen(in);
|
||||
uint64_t v0 = 0x736f6d6570736575ULL;
|
||||
uint64_t v1 = 0x646f72616e646f6dULL;
|
||||
uint64_t v2 = 0x6c7967656e657261ULL;
|
||||
uint64_t v3 = 0x7465646279746573ULL;
|
||||
uint64_t k0 = U8TO64_LE(k);
|
||||
uint64_t k1 = U8TO64_LE(k + 8);
|
||||
uint64_t m;
|
||||
const char *end = in + inlen - (inlen % sizeof(uint64_t));
|
||||
const int left = inlen & 7;
|
||||
uint64_t b = ((uint64_t)inlen) << 56;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
uint64_t hash;
|
||||
char *out = (char *)&hash;
|
||||
size_t inlen = strlen(in);
|
||||
uint64_t v0 = 0x736f6d6570736575ULL;
|
||||
uint64_t v1 = 0x646f72616e646f6dULL;
|
||||
uint64_t v2 = 0x6c7967656e657261ULL;
|
||||
uint64_t v3 = 0x7465646279746573ULL;
|
||||
uint64_t k0 = U8TO64_LE(k);
|
||||
uint64_t k1 = U8TO64_LE(k + 8);
|
||||
uint64_t m;
|
||||
const char *end = in + inlen - (inlen % sizeof(uint64_t));
|
||||
const int left = inlen & 7;
|
||||
uint64_t b = ((uint64_t)inlen) << 56;
|
||||
v3 ^= k1;
|
||||
v2 ^= k0;
|
||||
v1 ^= k1;
|
||||
v0 ^= k0;
|
||||
|
||||
for (; in != end; in += 8) {
|
||||
m = U8TO64_LE_NOCASE(in);
|
||||
v3 ^= m;
|
||||
for (; in != end; in += 8)
|
||||
{
|
||||
m = U8TO64_LE_NOCASE(in);
|
||||
v3 ^= m;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= m;
|
||||
}
|
||||
v0 ^= m;
|
||||
}
|
||||
|
||||
switch (left) {
|
||||
case 7: b |= ((uint64_t)tolower(in[6])) << 48; /* fallthrough */
|
||||
case 6: b |= ((uint64_t)tolower(in[5])) << 40; /* fallthrough */
|
||||
case 5: b |= ((uint64_t)tolower(in[4])) << 32; /* fallthrough */
|
||||
case 4: b |= ((uint64_t)tolower(in[3])) << 24; /* fallthrough */
|
||||
case 3: b |= ((uint64_t)tolower(in[2])) << 16; /* fallthrough */
|
||||
case 2: b |= ((uint64_t)tolower(in[1])) << 8; /* fallthrough */
|
||||
case 1: b |= ((uint64_t)tolower(in[0])); break;
|
||||
case 0: break;
|
||||
}
|
||||
switch (left)
|
||||
{
|
||||
case 7:
|
||||
b |= ((uint64_t)tolower(in[6])) << 48; /* fallthrough */
|
||||
case 6:
|
||||
b |= ((uint64_t)tolower(in[5])) << 40; /* fallthrough */
|
||||
case 5:
|
||||
b |= ((uint64_t)tolower(in[4])) << 32; /* fallthrough */
|
||||
case 4:
|
||||
b |= ((uint64_t)tolower(in[3])) << 24; /* fallthrough */
|
||||
case 3:
|
||||
b |= ((uint64_t)tolower(in[2])) << 16; /* fallthrough */
|
||||
case 2:
|
||||
b |= ((uint64_t)tolower(in[1])) << 8; /* fallthrough */
|
||||
case 1:
|
||||
b |= ((uint64_t)tolower(in[0]));
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
v3 ^= b;
|
||||
v3 ^= b;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
v0 ^= b;
|
||||
v2 ^= 0xff;
|
||||
v0 ^= b;
|
||||
v2 ^= 0xff;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out, b);
|
||||
b = v0 ^ v1 ^ v2 ^ v3;
|
||||
U64TO8_LE(out, b);
|
||||
|
||||
return hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
/* End of imported code */
|
||||
@@ -243,9 +266,9 @@ uint64_t siphash_nocase(const char *in, const char *k)
|
||||
*/
|
||||
uint64_t siphash(const char *in, const char *k)
|
||||
{
|
||||
size_t inlen = strlen(in);
|
||||
size_t inlen = strlen(in);
|
||||
|
||||
return siphash_raw(in, inlen, k);
|
||||
return siphash_raw(in, inlen, k);
|
||||
}
|
||||
|
||||
/** Generate a key that is used by siphash() and siphash_nocase().
|
||||
@@ -440,9 +463,9 @@ Client *hash_find_id(const char *name, Client *client)
|
||||
Client *hash_find_nickatserver(const char *str, Client *def)
|
||||
{
|
||||
char *serv;
|
||||
char nick[NICKLEN+HOSTLEN+1];
|
||||
char nick[NICKLEN + HOSTLEN + 1];
|
||||
Client *client;
|
||||
|
||||
|
||||
strlcpy(nick, str, sizeof(nick)); /* let's work on a copy */
|
||||
|
||||
serv = strchr(nick, '@');
|
||||
@@ -452,14 +475,14 @@ Client *hash_find_nickatserver(const char *str, Client *def)
|
||||
client = find_user(nick, NULL);
|
||||
if (!client)
|
||||
return NULL; /* client not found */
|
||||
|
||||
|
||||
if (!serv)
|
||||
return client; /* validated: was just 'nick' and not 'nick@serv' */
|
||||
|
||||
/* Now validate the server portion */
|
||||
if (client->user && !smycmp(serv, client->user->server))
|
||||
return client; /* validated */
|
||||
|
||||
|
||||
return def;
|
||||
}
|
||||
/*
|
||||
@@ -590,7 +613,7 @@ Channel *hash_get_chan_bucket(uint64_t hashv)
|
||||
*/
|
||||
Client *find_server_by_uid(const char *uid)
|
||||
{
|
||||
char sid[SIDLEN+1];
|
||||
char sid[SIDLEN + 1];
|
||||
|
||||
if (!isdigit(*uid))
|
||||
return NULL; /* not a UID/SID */
|
||||
@@ -606,7 +629,7 @@ Client *find_server_by_uid(const char *uid)
|
||||
* already handled real-time. This is just to catch the other cases
|
||||
* (we don't know what type of complex known-users rules people have).
|
||||
*/
|
||||
#define UPDATE_KNOWN_USER_CACHE_TIMER_WORKPERITERATION (NICK_HASH_TABLE_SIZE/24)
|
||||
#define UPDATE_KNOWN_USER_CACHE_TIMER_WORKPERITERATION (NICK_HASH_TABLE_SIZE / 24)
|
||||
|
||||
EVENT(update_known_user_cache_timer)
|
||||
{
|
||||
@@ -614,9 +637,10 @@ EVENT(update_known_user_cache_timer)
|
||||
int work_done = 0;
|
||||
Client *client;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
list_for_each_entry(client, &idTable[slot], id_hash)
|
||||
update_known_user_cache(client);
|
||||
update_known_user_cache(client);
|
||||
|
||||
if (++slot >= NICK_HASH_TABLE_SIZE)
|
||||
slot = 0;
|
||||
|
||||
+196
-180
@@ -32,7 +32,8 @@ static void open_debugfile(), setup_signals();
|
||||
|
||||
EVENT(loop_event)
|
||||
{
|
||||
if (loop.do_garbage_collect == 1) {
|
||||
if (loop.do_garbage_collect == 1)
|
||||
{
|
||||
garbage_collect(NULL);
|
||||
}
|
||||
}
|
||||
@@ -42,19 +43,22 @@ EVENT(garbage_collect)
|
||||
extern int freelinks;
|
||||
extern Link *freelink;
|
||||
Link p;
|
||||
int ii;
|
||||
int ii;
|
||||
|
||||
if (loop.do_garbage_collect == 1)
|
||||
unreal_log(ULOG_INFO, "main", "GARBAGE_COLLECT_STARTED", NULL, "Doing garbage collection...");
|
||||
if (freelinks > HOW_MANY_FREELINKS_ALLOWED) {
|
||||
if (freelinks > HOW_MANY_FREELINKS_ALLOWED)
|
||||
{
|
||||
ii = freelinks;
|
||||
while (freelink && (freelinks > HOW_MANY_FREELINKS_ALLOWED)) {
|
||||
while (freelink && (freelinks > HOW_MANY_FREELINKS_ALLOWED))
|
||||
{
|
||||
freelinks--;
|
||||
p.next = freelink;
|
||||
freelink = freelink->next;
|
||||
safe_free(p.next);
|
||||
}
|
||||
if (loop.do_garbage_collect == 1) {
|
||||
if (loop.do_garbage_collect == 1)
|
||||
{
|
||||
loop.do_garbage_collect = 0;
|
||||
unreal_log(ULOG_INFO, "main", "GARBAGE_COLLECT_STARTED", NULL, "Cleaned up $count garbage blocks",
|
||||
log_data_integer("count", (ii - freelinks)));
|
||||
@@ -79,19 +83,21 @@ int match_tkls(Client *client)
|
||||
if (IsUser(client))
|
||||
{
|
||||
/* Check ban realname { } */
|
||||
if (!ValidatePermissionsForPath("immune",client,NULL,NULL,NULL) && (bconf = find_ban(NULL, client->info, CONF_BAN_REALNAME)))
|
||||
if (!ValidatePermissionsForPath("immune", client, NULL, NULL, NULL) && (bconf = find_ban(NULL, client->info, CONF_BAN_REALNAME)))
|
||||
{
|
||||
unreal_log(ULOG_INFO, "tkl", "BAN_REALNAME", client,
|
||||
"Banned client $client.details due to realname ban: $reason",
|
||||
log_data_string("reason", bconf->reason ? bconf->reason : "no reason"));
|
||||
|
||||
if (bconf->reason) {
|
||||
if (bconf->reason)
|
||||
{
|
||||
if (IsUser(client))
|
||||
snprintf(banbuf, sizeof(banbuf), "User has been banned (%s)", bconf->reason);
|
||||
else
|
||||
snprintf(banbuf, sizeof(banbuf), "Banned (%s)", bconf->reason);
|
||||
exit_client(client, NULL, banbuf);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (IsUser(client))
|
||||
exit_client(client, NULL, "User has been banned");
|
||||
else
|
||||
@@ -165,14 +171,12 @@ void check_ping(Client *client)
|
||||
return; /* some recent command was executed */
|
||||
|
||||
if (
|
||||
/* If we have sent a ping */
|
||||
(IsPingSent(client)
|
||||
/* And they had 2x ping frequency to respond */
|
||||
&& ((TStime() - client->local->last_msg_received) >= (2 * ping)))
|
||||
||
|
||||
/* Or isn't registered and time spent is larger than ping (CONNECTTIMEOUT).. */
|
||||
(!IsRegistered(client) && (TStime() - client->local->fake_lag >= ping))
|
||||
)
|
||||
/* If we have sent a ping */
|
||||
(IsPingSent(client)
|
||||
/* And they had 2x ping frequency to respond */
|
||||
&& ((TStime() - client->local->last_msg_received) >= (2 * ping))) ||
|
||||
/* Or isn't registered and time spent is larger than ping (CONNECTTIMEOUT).. */
|
||||
(!IsRegistered(client) && (TStime() - client->local->fake_lag >= ping)))
|
||||
{
|
||||
if (IsServer(client) || IsConnecting(client) ||
|
||||
IsHandshake(client) || IsTLSConnectHandshake(client))
|
||||
@@ -183,11 +187,10 @@ void check_ping(Client *client)
|
||||
SetServerDisconnectLogged(client);
|
||||
}
|
||||
ircsnprintf(scratch, sizeof(scratch), "Ping timeout: %lld seconds",
|
||||
(long long) (TStime() - client->local->last_msg_received));
|
||||
(long long)(TStime() - client->local->last_msg_received));
|
||||
exit_client(client, NULL, scratch);
|
||||
return;
|
||||
}
|
||||
else if (IsRegistered(client) && !IsPingSent(client))
|
||||
} else if (IsRegistered(client) && !IsPingSent(client))
|
||||
{
|
||||
/* Time to send a PING */
|
||||
SetPingSent(client);
|
||||
@@ -195,17 +198,16 @@ void check_ping(Client *client)
|
||||
/* not nice but does the job */
|
||||
client->local->last_msg_received = TStime() - ping;
|
||||
sendto_one(client, NULL, "PING :%s", me.name);
|
||||
}
|
||||
else if (!IsPingWarning(client) && PINGWARNING > 0 &&
|
||||
(IsServer(client) || IsHandshake(client) || IsConnecting(client) ||
|
||||
IsTLSConnectHandshake(client)) &&
|
||||
(TStime() - client->local->last_msg_received) >= (ping + PINGWARNING))
|
||||
} else if (!IsPingWarning(client) && PINGWARNING > 0 &&
|
||||
(IsServer(client) || IsHandshake(client) || IsConnecting(client) ||
|
||||
IsTLSConnectHandshake(client)) &&
|
||||
(TStime() - client->local->last_msg_received) >= (ping + PINGWARNING))
|
||||
{
|
||||
SetPingWarning(client);
|
||||
unreal_log(ULOG_WARNING, "link", "LINK_UNRELIABLE", client,
|
||||
"Warning, no response from $client for $time_delta seconds",
|
||||
log_data_integer("time_delta", PINGWARNING),
|
||||
client->server->conf ? log_data_link_block(client->server->conf) : NULL);
|
||||
"Warning, no response from $client for $time_delta seconds",
|
||||
log_data_integer("time_delta", PINGWARNING),
|
||||
client->server->conf ? log_data_link_block(client->server->conf) : NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -290,13 +292,15 @@ static int bad_command(const char *argv0)
|
||||
|
||||
printf("ERROR: Incorrect command line argument encountered (if you are looking for foreground mode, it is -F).\n"
|
||||
"IMPORTANT: This is the unrealircd BINARY. End-users should NOT call this binary directly.\n"
|
||||
"Please run the SCRIPT instead: %s/unrealircd\n", SCRIPTDIR);
|
||||
"Please run the SCRIPT instead: %s/unrealircd\n",
|
||||
SCRIPTDIR);
|
||||
printf("Server not started\n\n");
|
||||
#else
|
||||
if (!IsService) {
|
||||
if (!IsService)
|
||||
{
|
||||
MessageBox(NULL,
|
||||
"Usage: UnrealIRCd [-f configfile]\n",
|
||||
"UnrealIRCD/32", MB_OK);
|
||||
"Usage: UnrealIRCd [-f configfile]\n",
|
||||
"UnrealIRCD/32", MB_OK);
|
||||
}
|
||||
#endif
|
||||
return (-1);
|
||||
@@ -345,7 +349,7 @@ void fix_timers(void)
|
||||
{
|
||||
if (e->last_run.tv_sec > TStime())
|
||||
{
|
||||
e->last_run.tv_sec = TStime()-1;
|
||||
e->last_run.tv_sec = TStime() - 1;
|
||||
e->last_run.tv_usec = 0;
|
||||
}
|
||||
}
|
||||
@@ -369,14 +373,14 @@ void fix_timers(void)
|
||||
* This should work until 2038, and very likely after that as well
|
||||
* because 'long' should be 64 bit on all systems by then... -- Syzop
|
||||
*/
|
||||
#define mytdiff(a, b) ((long)a - (long)b)
|
||||
#define mytdiff(a, b) ((long)a - (long)b)
|
||||
|
||||
#define NEGATIVE_SHIFT_WARN -15
|
||||
#define POSITIVE_SHIFT_WARN 20
|
||||
#define NEGATIVE_SHIFT_WARN -15
|
||||
#define POSITIVE_SHIFT_WARN 20
|
||||
|
||||
void detect_timeshift_and_warn(void)
|
||||
{
|
||||
static time_t highesttimeofday=0, oldtimeofday=0, lasthighwarn=0;
|
||||
static time_t highesttimeofday = 0, oldtimeofday = 0, lasthighwarn = 0;
|
||||
|
||||
if (oldtimeofday == 0)
|
||||
oldtimeofday = timeofday; /* pretend everything is ok the first time.. */
|
||||
@@ -396,8 +400,7 @@ void detect_timeshift_and_warn(void)
|
||||
log_data_timestamp("time_from", oldtimeofday),
|
||||
log_data_timestamp("time_to", timeofday));
|
||||
fix_timers();
|
||||
} else
|
||||
if (mytdiff(timeofday, oldtimeofday) > POSITIVE_SHIFT_WARN) /* do not set too low or you get false positives */
|
||||
} else if (mytdiff(timeofday, oldtimeofday) > POSITIVE_SHIFT_WARN) /* do not set too low or you get false positives */
|
||||
{
|
||||
/* tdiff = # of seconds of time set forward (eg: 60) */
|
||||
time_t tdiff = timeofday - oldtimeofday;
|
||||
@@ -413,27 +416,28 @@ void detect_timeshift_and_warn(void)
|
||||
fix_timers();
|
||||
}
|
||||
|
||||
if (highesttimeofday+NEGATIVE_SHIFT_WARN > timeofday)
|
||||
if (highesttimeofday + NEGATIVE_SHIFT_WARN > timeofday)
|
||||
{
|
||||
if (lasthighwarn > timeofday)
|
||||
lasthighwarn = timeofday;
|
||||
if (timeofday - lasthighwarn > 300)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "system", "SYSTEM_CLOCK_JUMP_BACKWARDS_PREVIOUSLY", NULL,
|
||||
"The system clock previously went backwards. Waiting for time to be OK again. This will be in $time_delta seconds.",
|
||||
log_data_integer("time_delta", highesttimeofday - timeofday),
|
||||
log_data_timestamp("time_from", highesttimeofday),
|
||||
log_data_timestamp("time_to", timeofday));
|
||||
"The system clock previously went backwards. Waiting for time to be OK again. This will be in $time_delta seconds.",
|
||||
log_data_integer("time_delta", highesttimeofday - timeofday),
|
||||
log_data_timestamp("time_from", highesttimeofday),
|
||||
log_data_timestamp("time_to", timeofday));
|
||||
lasthighwarn = timeofday;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
highesttimeofday = timeofday;
|
||||
}
|
||||
|
||||
oldtimeofday = timeofday;
|
||||
}
|
||||
|
||||
#define DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME 5
|
||||
#define DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME 5
|
||||
|
||||
EVENT(detect_high_connection_rate)
|
||||
{
|
||||
@@ -443,65 +447,67 @@ EVENT(detect_high_connection_rate)
|
||||
if (iConf.high_connection_rate == 0)
|
||||
{
|
||||
quick_close = 0;
|
||||
connections_past_period=0; /* reset */
|
||||
connections_past_period = 0; /* reset */
|
||||
return;
|
||||
}
|
||||
|
||||
if (connections_past_period > iConf.high_connection_rate*DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME)
|
||||
if (connections_past_period > iConf.high_connection_rate * DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME)
|
||||
{
|
||||
quick_close = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
quick_close = 0;
|
||||
}
|
||||
|
||||
if (OpenFiles >= maxclients-10)
|
||||
if (OpenFiles >= maxclients - 10)
|
||||
quick_close = 1;
|
||||
|
||||
/* Send a warning to IRCOps every XYZ time */
|
||||
if (quick_close && (TStime() - last_detect_high_connection_rate_warning > 600) && connections_past_period)
|
||||
{
|
||||
if (connections_past_period >= iConf.high_connection_rate*DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME)
|
||||
if (connections_past_period >= iConf.high_connection_rate * DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "htm", "HIGH_CONNECTION_RATE", NULL,
|
||||
"High rate of connection attempts detected: $connects_per_second/sec exceeds $limit/sec: some minor functionality is now disabled. "
|
||||
"This could be an attack, or lots of genuine users connecting after a network outage.\n"
|
||||
"This message will appear every 10 minutes for as long as this is the case. "
|
||||
"You will NOT get a notification if all is normal again (which is evaluated every $sample_time seconds). "
|
||||
"See https://www.unrealircd.org/docs/FAQ#hi-conn-rate",
|
||||
log_data_integer("connects_per_second", connections_past_period/DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME),
|
||||
log_data_integer("limit", iConf.high_connection_rate),
|
||||
log_data_integer("sample_time", DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME));
|
||||
} else {
|
||||
"High rate of connection attempts detected: $connects_per_second/sec exceeds $limit/sec: some minor functionality is now disabled. "
|
||||
"This could be an attack, or lots of genuine users connecting after a network outage.\n"
|
||||
"This message will appear every 10 minutes for as long as this is the case. "
|
||||
"You will NOT get a notification if all is normal again (which is evaluated every $sample_time seconds). "
|
||||
"See https://www.unrealircd.org/docs/FAQ#hi-conn-rate",
|
||||
log_data_integer("connects_per_second", connections_past_period / DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME),
|
||||
log_data_integer("limit", iConf.high_connection_rate),
|
||||
log_data_integer("sample_time", DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "htm", "HIGH_CONNECTION_RATE", NULL,
|
||||
"High amount of connections in use ($connections is near limit of $maxclients maximum clients). Some minor functionality is now disabled. "
|
||||
"This could be an attack, or lots of genuine users connecting.\n"
|
||||
"This message will appear every 10 minutes for as long as this is the case. "
|
||||
"You will NOT get a notification if all is normal again (which is evaluated every $sample_time seconds). "
|
||||
"See https://www.unrealircd.org/docs/FAQ#hi-conn-rate",
|
||||
log_data_integer("connections", OpenFiles),
|
||||
log_data_integer("maxclients", maxclients),
|
||||
log_data_integer("sample_time", DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME));
|
||||
"High amount of connections in use ($connections is near limit of $maxclients maximum clients). Some minor functionality is now disabled. "
|
||||
"This could be an attack, or lots of genuine users connecting.\n"
|
||||
"This message will appear every 10 minutes for as long as this is the case. "
|
||||
"You will NOT get a notification if all is normal again (which is evaluated every $sample_time seconds). "
|
||||
"See https://www.unrealircd.org/docs/FAQ#hi-conn-rate",
|
||||
log_data_integer("connections", OpenFiles),
|
||||
log_data_integer("maxclients", maxclients),
|
||||
log_data_integer("sample_time", DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME));
|
||||
}
|
||||
last_detect_high_connection_rate_warning = TStime();
|
||||
}
|
||||
|
||||
connections_past_period=0; /* reset */
|
||||
connections_past_period = 0; /* reset */
|
||||
}
|
||||
|
||||
void SetupEvents(void)
|
||||
{
|
||||
/* Start events */
|
||||
EventAdd(NULL, "tunefile", save_tunefile, NULL, 300*1000, 0);
|
||||
EventAdd(NULL, "garbage", garbage_collect, NULL, GARBAGE_COLLECT_EVERY*1000, 0);
|
||||
EventAdd(NULL, "tunefile", save_tunefile, NULL, 300 * 1000, 0);
|
||||
EventAdd(NULL, "garbage", garbage_collect, NULL, GARBAGE_COLLECT_EVERY * 1000, 0);
|
||||
EventAdd(NULL, "loop", loop_event, NULL, 1000, 0);
|
||||
EventAdd(NULL, "unrealdns_removeoldrecords", unrealdns_removeoldrecords, NULL, 15000, 0);
|
||||
EventAdd(NULL, "check_pings", check_pings, NULL, 1000, 0);
|
||||
EventAdd(NULL, "check_deadsockets", check_deadsockets, NULL, 1000, 0);
|
||||
EventAdd(NULL, "handshake_timeout", handshake_timeout, NULL, 1000, 0);
|
||||
EventAdd(NULL, "tls_check_expiry", tls_check_expiry, NULL, (86400/2)*1000, 0);
|
||||
EventAdd(NULL, "tls_check_expiry", tls_check_expiry, NULL, (86400 / 2) * 1000, 0);
|
||||
EventAdd(NULL, "unrealdb_expire_secret_cache", unrealdb_expire_secret_cache, NULL, 61000, 0);
|
||||
EventAdd(NULL, "memory_log_cleaner", memory_log_cleaner, NULL, 61500, 0);
|
||||
EventAdd(NULL, "detect_high_connection_rate", detect_high_connection_rate, NULL, 1000*DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME, 0);
|
||||
EventAdd(NULL, "detect_high_connection_rate", detect_high_connection_rate, NULL, 1000 * DETECT_HIGH_CONNECTION_RATE_SAMPLE_TIME, 0);
|
||||
EventAdd(NULL, "central_spamfilter_download_evt", central_spamfilter_download_evt, NULL, 5000, 0);
|
||||
EventAdd(NULL, "update_known_user_cache_timer", update_known_user_cache_timer, NULL, 5000, 0);
|
||||
EventAdd(NULL, "log_throttle_flush", log_throttle_flush, NULL, 5000, 0);
|
||||
@@ -566,15 +572,15 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
if (euid == 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"** ERROR **\n"
|
||||
"You attempted to run UnrealIRCd as root. This is VERY DANGEROUS\n"
|
||||
"as any compromise of your UnrealIRCd will result in full\n"
|
||||
"privileges to the attacker on the entire machine.\n"
|
||||
"You MUST start UnrealIRCd as a different user!\n"
|
||||
"\n"
|
||||
"For more information, see:\n"
|
||||
"https://www.unrealircd.org/docs/Do_not_run_as_root\n"
|
||||
"\n");
|
||||
"** ERROR **\n"
|
||||
"You attempted to run UnrealIRCd as root. This is VERY DANGEROUS\n"
|
||||
"as any compromise of your UnrealIRCd will result in full\n"
|
||||
"privileges to the attacker on the entire machine.\n"
|
||||
"You MUST start UnrealIRCd as a different user!\n"
|
||||
"\n"
|
||||
"For more information, see:\n"
|
||||
"https://www.unrealircd.org/docs/Do_not_run_as_root\n"
|
||||
"\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
@@ -584,7 +590,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
cmdLine = GetCommandLine();
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
(void)umask(077); /* better safe than sorry --SRB */
|
||||
(void)umask(077); /* better safe than sorry --SRB */
|
||||
#else
|
||||
init_winsock();
|
||||
#endif
|
||||
@@ -613,23 +619,25 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
init_sys();
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#ifndef _WIN32
|
||||
mkdir(TMPDIR, S_IRUSR|S_IWUSR|S_IXUSR); /* Create the tmp dir, if it doesn't exist */
|
||||
mkdir(CACHEDIR, S_IRUSR|S_IWUSR|S_IXUSR); /* Create the cache dir, if it doesn't exist */
|
||||
#else
|
||||
#ifndef _WIN32
|
||||
mkdir(TMPDIR, S_IRUSR | S_IWUSR | S_IXUSR); /* Create the tmp dir, if it doesn't exist */
|
||||
mkdir(CACHEDIR, S_IRUSR | S_IWUSR | S_IXUSR); /* Create the cache dir, if it doesn't exist */
|
||||
#else
|
||||
mkdir(TMPDIR);
|
||||
mkdir(CACHEDIR);
|
||||
#endif
|
||||
if (chdir(TMPDIR)) {
|
||||
# ifndef _WIN32
|
||||
#endif
|
||||
if (chdir(TMPDIR))
|
||||
{
|
||||
#ifndef _WIN32
|
||||
perror("chdir");
|
||||
fprintf(stderr, "ERROR: Unable to change to directory '%s'\n", TMPDIR);
|
||||
# else
|
||||
if (!IsService) {
|
||||
#else
|
||||
if (!IsService)
|
||||
{
|
||||
MessageBox(NULL, strerror(GetLastError()),
|
||||
"UnrealIRCD/32: chdir()", MB_OK);
|
||||
"UnrealIRCD/32: chdir()", MB_OK);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
@@ -640,11 +648,14 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
* ** be empty. Flag characters cannot be concatenated (like
|
||||
* ** "-fxyz"), it would conflict with the form "-fstring".
|
||||
*/
|
||||
while (--argc > 0 && (*++argv)[0] == '-') {
|
||||
while (--argc > 0 && (*++argv)[0] == '-')
|
||||
{
|
||||
char *p = argv[0] + 1;
|
||||
int flag = *p++;
|
||||
if (flag == '\0' || *p == '\0') {
|
||||
if (argc > 1 && argv[1][0] != '-') {
|
||||
int flag = *p++;
|
||||
if (flag == '\0' || *p == '\0')
|
||||
{
|
||||
if (argc > 1 && argv[1][0] != '-')
|
||||
{
|
||||
p = *++argv;
|
||||
argc -= 1;
|
||||
} else
|
||||
@@ -672,79 +683,81 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
//unrealdb_test();
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
case 't':
|
||||
bootopt |= BOOT_TTY;
|
||||
break;
|
||||
case 'v':
|
||||
(void)printf("%s\n", version);
|
||||
case 't':
|
||||
bootopt |= BOOT_TTY;
|
||||
break;
|
||||
case 'v':
|
||||
(void)printf("%s\n", version);
|
||||
#else
|
||||
case 'v':
|
||||
if (!IsService) {
|
||||
MessageBox(NULL, version,
|
||||
"UnrealIRCD/Win32 version", MB_OK);
|
||||
}
|
||||
case 'v':
|
||||
if (!IsService)
|
||||
{
|
||||
MessageBox(NULL, version,
|
||||
"UnrealIRCD/Win32 version", MB_OK);
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
case 'C':
|
||||
config_verbose = atoi(p);
|
||||
break;
|
||||
case 'c':
|
||||
loop.config_test = 1;
|
||||
break;
|
||||
case 'x':
|
||||
#ifdef DEBUGMODE
|
||||
debuglevel = atoi(p);
|
||||
debugmode = *p ? p : "0";
|
||||
bootopt |= BOOT_DEBUG;
|
||||
break;
|
||||
exit(0);
|
||||
case 'C':
|
||||
config_verbose = atoi(p);
|
||||
break;
|
||||
case 'c':
|
||||
loop.config_test = 1;
|
||||
break;
|
||||
case 'x':
|
||||
#ifdef DEBUGMODE
|
||||
debuglevel = atoi(p);
|
||||
debugmode = *p ? p : "0";
|
||||
bootopt |= BOOT_DEBUG;
|
||||
break;
|
||||
#else
|
||||
# ifndef _WIN32
|
||||
(void)fprintf(stderr,
|
||||
"%s: DEBUGMODE must be defined for -x y\n",
|
||||
myargv[0]);
|
||||
# else
|
||||
if (!IsService) {
|
||||
MessageBox(NULL,
|
||||
"DEBUGMODE must be defined for -x option",
|
||||
"UnrealIRCD/32", MB_OK);
|
||||
}
|
||||
# endif
|
||||
exit(0);
|
||||
#ifndef _WIN32
|
||||
(void)fprintf(stderr,
|
||||
"%s: DEBUGMODE must be defined for -x y\n",
|
||||
myargv[0]);
|
||||
#else
|
||||
if (!IsService)
|
||||
{
|
||||
MessageBox(NULL,
|
||||
"DEBUGMODE must be defined for -x option",
|
||||
"UnrealIRCD/32", MB_OK);
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
#endif
|
||||
case 'K':
|
||||
{
|
||||
char *p = NULL;
|
||||
if (chdir(TMPDIR) < 0)
|
||||
{
|
||||
fprintf(stderr, "Could not change to directory '%s'\n", TMPDIR);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "Starting crash test!\n");
|
||||
*p = 'a';
|
||||
fprintf(stderr, "It is impossible to get here\n");
|
||||
exit(0);
|
||||
}
|
||||
case 'R':
|
||||
report_crash();
|
||||
exit(0);
|
||||
case 'K':
|
||||
{
|
||||
char *p = NULL;
|
||||
if (chdir(TMPDIR) < 0)
|
||||
{
|
||||
fprintf(stderr, "Could not change to directory '%s'\n", TMPDIR);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "Starting crash test!\n");
|
||||
*p = 'a';
|
||||
fprintf(stderr, "It is impossible to get here\n");
|
||||
exit(0);
|
||||
}
|
||||
case 'R':
|
||||
report_crash();
|
||||
exit(0);
|
||||
#ifndef _WIN32
|
||||
case 'm':
|
||||
modulemanager(argc, argv);
|
||||
exit(0);
|
||||
case 'm':
|
||||
modulemanager(argc, argv);
|
||||
exit(0);
|
||||
#endif
|
||||
case '8':
|
||||
utf8_test();
|
||||
exit(0);
|
||||
case 'L':
|
||||
loop.boot_function = link_generator;
|
||||
break;
|
||||
default:
|
||||
case '8':
|
||||
utf8_test();
|
||||
exit(0);
|
||||
case 'L':
|
||||
loop.boot_function = link_generator;
|
||||
break;
|
||||
default:
|
||||
#ifndef _WIN32
|
||||
return bad_command(myargv[0]);
|
||||
return bad_command(myargv[0]);
|
||||
#else
|
||||
return bad_command(NULL);
|
||||
return bad_command(NULL);
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,9 +768,10 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
/*
|
||||
* but asked for debugging output to tty
|
||||
*/
|
||||
if ((debuglevel < 0) && (bootopt & BOOT_TTY)) {
|
||||
if ((debuglevel < 0) && (bootopt & BOOT_TTY))
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"you specified -t without -x. use -x <n>\n");
|
||||
"you specified -t without -x. use -x <n>\n");
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
@@ -767,7 +781,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
if (argc > 0)
|
||||
return bad_command(myargv[0]); /* This should exit out */
|
||||
return bad_command(myargv[0]); /* This should exit out */
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
fprintf(stderr, "%s", unreallogo);
|
||||
@@ -783,9 +797,9 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
fprintf(stderr, "UnrealIRCd is using the following libraries:\n");
|
||||
fprintf(stderr, "* %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
fprintf(stderr, "* libsodium %s\n", sodium_version_string());
|
||||
#ifdef USE_LIBCURL
|
||||
#ifdef USE_LIBCURL
|
||||
fprintf(stderr, "* %s\n", curl_version());
|
||||
#endif
|
||||
#endif
|
||||
fprintf(stderr, "* c-ares %s\n", ares_version(NULL));
|
||||
fprintf(stderr, "* %s\n", pcre2_version());
|
||||
#endif
|
||||
@@ -796,7 +810,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
#ifndef _WIN32
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "This server can handle %d concurrent sockets (%d clients + %d reserve)\n\n",
|
||||
maxclients+reserved_fds, maxclients, reserved_fds);
|
||||
maxclients + reserved_fds, maxclients, reserved_fds);
|
||||
#endif
|
||||
init_CommandHash();
|
||||
initwhowas();
|
||||
@@ -892,7 +906,7 @@ int InitUnrealIRCd(int argc, char *argv[])
|
||||
if (p < 0)
|
||||
{
|
||||
fprintf(stderr, "Could not create background job. Call to fork() failed: %s\n",
|
||||
strerror(errno));
|
||||
strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
if (p > 0)
|
||||
@@ -1002,40 +1016,42 @@ void SocketLoop(void *dummy)
|
||||
*/
|
||||
static void open_debugfile(void)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
int fd;
|
||||
#ifdef DEBUGMODE
|
||||
int fd;
|
||||
Client *client;
|
||||
if (debuglevel >= 0) {
|
||||
if (debuglevel >= 0)
|
||||
{
|
||||
client = make_client(NULL, NULL);
|
||||
client->local->fd = 2;
|
||||
SetLog(client);
|
||||
client->flags = 0;
|
||||
|
||||
strlcpy(client->local->sockhost, me.local->sockhost, sizeof client->local->sockhost);
|
||||
# ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
/*(void)printf("isatty = %d ttyname = %#x\n",
|
||||
isatty(2), (u_int)ttyname(2)); */
|
||||
if (!(bootopt & BOOT_TTY)) { /* leave debugging output on fd 2 */
|
||||
if (!(bootopt & BOOT_TTY))
|
||||
{ /* leave debugging output on fd 2 */
|
||||
if (truncate(LOGFILE, 0) < 0)
|
||||
fprintf(stderr, "WARNING: could not truncate log file '%s'\n", LOGFILE);
|
||||
if ((fd = open(LOGFILE, O_WRONLY | O_CREAT, 0600)) < 0)
|
||||
if ((fd = open("/dev/null", O_WRONLY)) < 0)
|
||||
exit(-1);
|
||||
|
||||
#if 1
|
||||
#if 1
|
||||
client->local->fd = fd;
|
||||
debugfd = fd;
|
||||
#else
|
||||
/* if (fd != 2) {
|
||||
#else
|
||||
/* if (fd != 2) {
|
||||
(void)dup2(fd, 2);
|
||||
(void)close(fd);
|
||||
} -- hands off stderr! */
|
||||
#endif
|
||||
#endif
|
||||
strlcpy(client->name, LOGFILE, sizeof(client->name));
|
||||
} else if (isatty(2) && ttyname(2))
|
||||
strlcpy(client->name, ttyname(2), sizeof(client->name));
|
||||
else
|
||||
# endif
|
||||
#endif
|
||||
strlcpy(client->name, "FD2-Pipe", sizeof(client->name));
|
||||
}
|
||||
#endif
|
||||
@@ -1050,10 +1066,10 @@ static void setup_signals()
|
||||
(void)sigemptyset(&act.sa_mask);
|
||||
(void)sigaddset(&act.sa_mask, SIGPIPE);
|
||||
(void)sigaddset(&act.sa_mask, SIGALRM);
|
||||
#ifdef SIGWINCH
|
||||
#ifdef SIGWINCH
|
||||
(void)sigaddset(&act.sa_mask, SIGWINCH);
|
||||
(void)sigaction(SIGWINCH, &act, NULL);
|
||||
#endif
|
||||
#endif
|
||||
(void)sigaction(SIGPIPE, &act, NULL);
|
||||
act.sa_handler = ignore_this_signal;
|
||||
(void)sigaction(SIGALRM, &act, NULL);
|
||||
|
||||
+10
-10
@@ -15,17 +15,17 @@ struct timeval timeofday_tv;
|
||||
int tainted = 0;
|
||||
LoopStruct loop;
|
||||
MODVAR IRCCounts irccounts;
|
||||
MODVAR Client me; /* That's me */
|
||||
MODVAR Client me; /* That's me */
|
||||
MODVAR char *me_hash;
|
||||
char *configfile = NULL; /* Server configuration file */
|
||||
int debuglevel = 0; /* Server debug level */
|
||||
int bootopt = 0; /* Server boot option flags */
|
||||
char *debugmode = ""; /* -"- -"- -"- */
|
||||
int dorehash = 0; /**< Rehash server on next socket loop */
|
||||
int dorestart = 0; /**< Restart server on next socket loop */
|
||||
int doreloadcert = 0; /**< Reload TLS certificate on next socket loop */
|
||||
MODVAR int quick_close = 0; /**< Quickly close client connections (1) or be friendly to TLS users (0) */
|
||||
MODVAR int connections_past_period=0; /**< Number of new connections past period, used for set::high-connection-rate */
|
||||
char *configfile = NULL; /* Server configuration file */
|
||||
int debuglevel = 0; /* Server debug level */
|
||||
int bootopt = 0; /* Server boot option flags */
|
||||
char *debugmode = ""; /* -"- -"- -"- */
|
||||
int dorehash = 0; /**< Rehash server on next socket loop */
|
||||
int dorestart = 0; /**< Restart server on next socket loop */
|
||||
int doreloadcert = 0; /**< Reload TLS certificate on next socket loop */
|
||||
MODVAR int quick_close = 0; /**< Quickly close client connections (1) or be friendly to TLS users (0) */
|
||||
MODVAR int connections_past_period = 0; /**< Number of new connections past period, used for set::high-connection-rate */
|
||||
#ifndef _WIN32
|
||||
char **myargv;
|
||||
#else
|
||||
|
||||
+58
-53
@@ -37,12 +37,13 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
{
|
||||
char *str_begin = str;
|
||||
char c;
|
||||
const char *end = str+size-1; /* for comparison, not dereferencing. It is the last position a null can go. */
|
||||
const char *end = str + size - 1; /* for comparison, not dereferencing. It is the last position a null can go. */
|
||||
char scratch_buffer[32]; /* large enough for 64 bit integer as a string */
|
||||
|
||||
if (!size) return str;
|
||||
if (!size)
|
||||
return str;
|
||||
|
||||
while (str!=end && (c = *format++))
|
||||
while (str != end && (c = *format++))
|
||||
{
|
||||
if (c == '%')
|
||||
{
|
||||
@@ -51,52 +52,53 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
{
|
||||
/* %s - string */
|
||||
const char *p1 = va_arg(vl, const char *);
|
||||
while (str!=end && *p1) *str++ = *p1++;
|
||||
while (str != end && *p1)
|
||||
*str++ = *p1++;
|
||||
continue;
|
||||
}
|
||||
else if (c == 'c')
|
||||
} else if (c == 'c')
|
||||
{
|
||||
/* %c - single character */
|
||||
*str++ = (char)va_arg(vl, int);
|
||||
continue;
|
||||
}
|
||||
else if (c == 'd' || c == 'i')
|
||||
} else if (c == 'd' || c == 'i')
|
||||
{
|
||||
/* %d and %i - integer */
|
||||
char *t;
|
||||
int v = va_arg(vl, int);
|
||||
int i = 0;
|
||||
size_t len;
|
||||
if (v==0)
|
||||
if (v == 0)
|
||||
{
|
||||
*str++ = '0';
|
||||
continue;
|
||||
}
|
||||
t = scratch_buffer + sizeof(scratch_buffer);
|
||||
if (v<0)
|
||||
if (v < 0)
|
||||
{
|
||||
*str++ = '-';
|
||||
if (str==end) break;
|
||||
if (str == end)
|
||||
break;
|
||||
while (v)
|
||||
{
|
||||
*--t = '0' - (v%10);
|
||||
v/=10;
|
||||
*--t = '0' - (v % 10);
|
||||
v /= 10;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
while (v)
|
||||
{
|
||||
*--t = (v%10) + '0';
|
||||
v/=10;
|
||||
*--t = (v % 10) + '0';
|
||||
v /= 10;
|
||||
}
|
||||
}
|
||||
|
||||
len = sizeof(scratch_buffer)-(t-scratch_buffer);
|
||||
if ((str+len)>end) break;
|
||||
len = sizeof(scratch_buffer) - (t - scratch_buffer);
|
||||
if ((str + len) > end)
|
||||
break;
|
||||
for (i = 0; i < len; i++)
|
||||
*str++=t[i];
|
||||
*str++ = t[i];
|
||||
continue;
|
||||
}
|
||||
else if (c == 'l')
|
||||
} else if (c == 'l')
|
||||
{
|
||||
if (format[0] == 'l' && format[1] == 'd')
|
||||
{
|
||||
@@ -108,33 +110,36 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
|
||||
format += 2;
|
||||
|
||||
if (v==0)
|
||||
if (v == 0)
|
||||
{
|
||||
*str++ = '0';
|
||||
continue;
|
||||
}
|
||||
t = scratch_buffer + sizeof(scratch_buffer);
|
||||
if (v<0)
|
||||
if (v < 0)
|
||||
{
|
||||
*str++ = '-';
|
||||
if (str==end) break;
|
||||
if (str == end)
|
||||
break;
|
||||
while (v)
|
||||
{
|
||||
*--t = '0' - (v%10);
|
||||
v/=10;
|
||||
*--t = '0' - (v % 10);
|
||||
v /= 10;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
while (v)
|
||||
{
|
||||
*--t = (v%10) + '0';
|
||||
v/=10;
|
||||
*--t = (v % 10) + '0';
|
||||
v /= 10;
|
||||
}
|
||||
}
|
||||
|
||||
len = sizeof(scratch_buffer)-(t-scratch_buffer);
|
||||
if ((str+len)>end) break;
|
||||
len = sizeof(scratch_buffer) - (t - scratch_buffer);
|
||||
if ((str + len) > end)
|
||||
break;
|
||||
for (i = 0; i < len; i++)
|
||||
*str++=t[i];
|
||||
*str++ = t[i];
|
||||
continue;
|
||||
}
|
||||
if (*format == 'u')
|
||||
@@ -146,7 +151,7 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
size_t len;
|
||||
|
||||
format++;
|
||||
if (v==0)
|
||||
if (v == 0)
|
||||
{
|
||||
*str++ = '0';
|
||||
continue;
|
||||
@@ -155,25 +160,25 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
t = scratch_buffer + sizeof(scratch_buffer);
|
||||
while (v)
|
||||
{
|
||||
*--t = (v%10) + '0';
|
||||
v/=10;
|
||||
*--t = (v % 10) + '0';
|
||||
v /= 10;
|
||||
}
|
||||
|
||||
len = sizeof(scratch_buffer)-(t-scratch_buffer);
|
||||
if ((str+len)>end) break;
|
||||
len = sizeof(scratch_buffer) - (t - scratch_buffer);
|
||||
if ((str + len) > end)
|
||||
break;
|
||||
for (i = 0; i < len; i++)
|
||||
*str++=t[i];
|
||||
*str++ = t[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (c == 'u')
|
||||
} else if (c == 'u')
|
||||
{
|
||||
/* %u - unsigned integer */
|
||||
char *t;
|
||||
unsigned int v = va_arg(vl, unsigned int);
|
||||
int i = 0;
|
||||
size_t len;
|
||||
if (v==0)
|
||||
if (v == 0)
|
||||
{
|
||||
*str++ = '0';
|
||||
continue;
|
||||
@@ -182,30 +187,29 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
t = scratch_buffer + sizeof(scratch_buffer);
|
||||
while (v)
|
||||
{
|
||||
*--t = (v%10) + '0';
|
||||
v/=10;
|
||||
*--t = (v % 10) + '0';
|
||||
v /= 10;
|
||||
}
|
||||
|
||||
len = sizeof(scratch_buffer)-(t-scratch_buffer);
|
||||
if ((str+len)>end) break;
|
||||
len = sizeof(scratch_buffer) - (t - scratch_buffer);
|
||||
if ((str + len) > end)
|
||||
break;
|
||||
for (i = 0; i < len; i++)
|
||||
*str++=t[i];
|
||||
*str++ = t[i];
|
||||
continue;
|
||||
}
|
||||
else if (c == '%')
|
||||
} else if (c == '%')
|
||||
{
|
||||
/* %% - literal percent character */
|
||||
*str++ = '%';
|
||||
continue;
|
||||
}
|
||||
else if (!c)
|
||||
} else if (!c)
|
||||
break; /* A % at the end of the format string (illegal, skipped) */
|
||||
|
||||
|
||||
/* The default case, when we cannot handle the % format:
|
||||
* Stop what we are doing and pass control to the real vsnprintf()
|
||||
*/
|
||||
format -= 2;
|
||||
vsnprintf(str, (size_t)(end-str+1), format, vl);
|
||||
vsnprintf(str, (size_t)(end - str + 1), format, vl);
|
||||
return str_begin;
|
||||
}
|
||||
*str++ = c;
|
||||
@@ -214,7 +218,8 @@ char *ircvsnprintf(char *str, size_t size, const char *format, va_list vl)
|
||||
return str_begin;
|
||||
}
|
||||
|
||||
char *ircsnprintf(char *str, size_t size, const char *format, ...) {
|
||||
char *ircsnprintf(char *str, size_t size, const char *format, ...)
|
||||
{
|
||||
va_list vl;
|
||||
char *ret;
|
||||
va_start(vl, format);
|
||||
|
||||
+54
-48
@@ -52,9 +52,10 @@ json_t *json_string_unreal(const char *s)
|
||||
|
||||
if (log_json_filter)
|
||||
{
|
||||
stripped = StripControlCodesEx(s, buf1, sizeof(buf1), UNRL_STRIP_LOW_ASCII|UNRL_STRIP_KEEP_LF);
|
||||
stripped = StripControlCodesEx(s, buf1, sizeof(buf1), UNRL_STRIP_LOW_ASCII | UNRL_STRIP_KEEP_LF);
|
||||
verified_s = unrl_utf8_make_valid(buf1, buf2, sizeof(buf2), 0);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
verified_s = unrl_utf8_make_valid(s, buf2, sizeof(buf2), 0);
|
||||
}
|
||||
|
||||
@@ -140,13 +141,13 @@ const char *timestamp_iso8601_now(void)
|
||||
tm = gmtime(&sec);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec,
|
||||
(int)(t.tv_usec / 1000));
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec,
|
||||
(int)(t.tv_usec / 1000));
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -165,13 +166,13 @@ const char *timestamp_iso8601(time_t v)
|
||||
return NULL;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec,
|
||||
0);
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec,
|
||||
0);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -206,7 +207,7 @@ void json_expand_client_security_groups(json_t *parent, Client *client)
|
||||
*/
|
||||
void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
{
|
||||
char buf[BUFSIZE+1];
|
||||
char buf[BUFSIZE + 1];
|
||||
json_t *child;
|
||||
json_t *user = NULL;
|
||||
time_t ts;
|
||||
@@ -216,7 +217,8 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
{
|
||||
child = json_object();
|
||||
json_object_set_new(j, key, child);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
child = j;
|
||||
}
|
||||
|
||||
@@ -253,32 +255,36 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
* but we don't know that, so we assume that is not the case).
|
||||
*/
|
||||
const char *ident;
|
||||
char temp[USERLEN+1];
|
||||
char temp[USERLEN + 1];
|
||||
if (IDENT_CHECK)
|
||||
{
|
||||
if (IsIdentSuccess(client))
|
||||
{
|
||||
/* ident succeeded means: use the identd and no ~ prefix */
|
||||
ident = client->ident;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* ident check failed means ~ prefix */
|
||||
snprintf(temp, sizeof(temp), "~%s", client->user->username);
|
||||
ident = temp;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* no ident check means no ~ prefix */
|
||||
ident = client->user->username;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s!%s@%s", client->name, ident, client->user->realhost);
|
||||
}
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else if (client->ip) {
|
||||
} else if (client->ip)
|
||||
{
|
||||
if (*client->name)
|
||||
snprintf(buf, sizeof(buf), "%s@%s", client->name, client->ip);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "[%s]", client->ip);
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
json_object_set_new(child, "details", json_string_unreal(client->name));
|
||||
}
|
||||
|
||||
@@ -332,7 +338,7 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
|
||||
/* user modes and snomasks */
|
||||
get_usermode_string_r(client, buf, sizeof(buf));
|
||||
json_object_set_new(user, "modes", json_string_unreal(buf+1));
|
||||
json_object_set_new(user, "modes", json_string_unreal(buf + 1));
|
||||
if (client->user->snomask)
|
||||
json_object_set_new(user, "snomasks", json_string_unreal(client->user->snomask));
|
||||
|
||||
@@ -370,7 +376,8 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
}
|
||||
json_array_append_new(channels, json_string_unreal(m->channel->name));
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Long format for JSON-RPC */
|
||||
for (m = client->user->channel; m; m = m->next)
|
||||
{
|
||||
@@ -383,8 +390,7 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
}
|
||||
}
|
||||
RunHook(HOOKTYPE_JSON_EXPAND_CLIENT_USER, client, detail, child, user);
|
||||
} else
|
||||
if (IsMe(client))
|
||||
} else if (IsMe(client))
|
||||
{
|
||||
json_t *server = json_object();
|
||||
json_t *features;
|
||||
@@ -419,14 +425,13 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
/* first one is special - wait.. is this still the case? lol. */
|
||||
snprintf(buf, sizeof(buf), "%s%s", CHPAR1, EXPAR1);
|
||||
json_array_append_new(chanmodes, json_string_unreal(buf));
|
||||
for (i=1; i < 4; i++)
|
||||
for (i = 1; i < 4; i++)
|
||||
json_array_append_new(chanmodes, json_string_unreal(extchmstr[i]));
|
||||
}
|
||||
if (!BadPtr(client->server->features.nickchars))
|
||||
json_object_set_new(features, "nick_character_sets", json_string_unreal(charsys_get_current_languages()));
|
||||
RunHook(HOOKTYPE_JSON_EXPAND_CLIENT_SERVER, client, detail, child, server);
|
||||
} else
|
||||
if (IsServer(client) && client->server)
|
||||
} else if (IsServer(client) && client->server)
|
||||
{
|
||||
/* client.server */
|
||||
|
||||
@@ -461,7 +466,7 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
int i;
|
||||
json_t *chanmodes = json_array();
|
||||
json_object_set_new(features, "chanmodes", chanmodes);
|
||||
for (i=0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
json_array_append_new(chanmodes, json_string_unreal(client->server->features.chanmodes[i]));
|
||||
}
|
||||
if (!BadPtr(client->server->features.nickchars))
|
||||
@@ -502,7 +507,8 @@ void json_expand_channel(json_t *j, const char *key, Channel *channel, int detai
|
||||
{
|
||||
child = json_object();
|
||||
json_object_set_new(j, key, child);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
child = j;
|
||||
}
|
||||
|
||||
@@ -523,10 +529,11 @@ void json_expand_channel(json_t *j, const char *key, Channel *channel, int detai
|
||||
channel_modes(NULL, mode1, mode2, sizeof(mode1), sizeof(mode2), channel, 0);
|
||||
if (*mode2)
|
||||
{
|
||||
snprintf(modes, sizeof(modes), "%s %s", mode1+1, mode2);
|
||||
snprintf(modes, sizeof(modes), "%s %s", mode1 + 1, mode2);
|
||||
json_object_set_new(child, "modes", json_string_unreal(modes));
|
||||
} else {
|
||||
json_object_set_new(child, "modes", json_string_unreal(mode1+1));
|
||||
} else
|
||||
{
|
||||
json_object_set_new(child, "modes", json_string_unreal(mode1 + 1));
|
||||
}
|
||||
|
||||
if (detail > 1)
|
||||
@@ -547,7 +554,7 @@ void json_expand_channel(json_t *j, const char *key, Channel *channel, int detai
|
||||
json_t *e = json_object();
|
||||
if (*u->member_modes)
|
||||
json_object_set_new(e, "level", json_string_unreal(u->member_modes));
|
||||
json_expand_client(e, NULL, u->client, detail-3);
|
||||
json_expand_client(e, NULL, u->client, detail - 3);
|
||||
json_array_append_new(list, e);
|
||||
}
|
||||
}
|
||||
@@ -565,7 +572,8 @@ void json_expand_tkl(json_t *root, const char *key, TKL *tkl, int detail)
|
||||
{
|
||||
j = json_object();
|
||||
json_object_set_new(root, key, j);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
j = root;
|
||||
}
|
||||
|
||||
@@ -584,7 +592,8 @@ void json_expand_tkl(json_t *root, const char *key, TKL *tkl, int detail)
|
||||
{
|
||||
json_object_set_new(j, "expire_at_string", json_string_unreal("Never"));
|
||||
json_object_set_new(j, "duration_string", json_string_unreal("permanent"));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
*buf = '\0';
|
||||
short_date(tkl->expire_at, buf);
|
||||
strlcat(buf, " GMT", sizeof(buf));
|
||||
@@ -605,15 +614,13 @@ void json_expand_tkl(json_t *root, const char *key, TKL *tkl, int detail)
|
||||
json_object_set_new(j, "spamfilter_id", json_string_unreal(tkl->spamfilter_id));
|
||||
json_object_set_new(j, "hits", json_integer(tkl->hits));
|
||||
json_object_set_new(j, "last_hit_at", json_timestamp(tkl->lasthit));
|
||||
} else
|
||||
if (TKLIsNameBan(tkl))
|
||||
} else if (TKLIsNameBan(tkl))
|
||||
{
|
||||
json_object_set_new(j, "name", json_string_unreal(tkl->ptr.nameban->name));
|
||||
json_object_set_new(j, "reason", json_string_unreal(tkl->ptr.nameban->reason));
|
||||
json_object_set_new(j, "hits", json_integer(tkl->hits));
|
||||
json_object_set_new(j, "last_hit_at", json_timestamp(tkl->lasthit));
|
||||
} else
|
||||
if (TKLIsBanException(tkl))
|
||||
} else if (TKLIsBanException(tkl))
|
||||
{
|
||||
if (tkl->ptr.banexception->match)
|
||||
json_expand_security_group(j, "match", tkl->ptr.banexception->match, 1);
|
||||
@@ -621,8 +628,7 @@ void json_expand_tkl(json_t *root, const char *key, TKL *tkl, int detail)
|
||||
json_object_set_new(j, "name", json_string_unreal(tkl_uhost(tkl, buf, sizeof(buf), 0)));
|
||||
json_object_set_new(j, "reason", json_string_unreal(tkl->ptr.banexception->reason));
|
||||
json_object_set_new(j, "exception_types", json_string_unreal(tkl->ptr.banexception->bantypes));
|
||||
} else
|
||||
if (TKLIsSpamfilter(tkl))
|
||||
} else if (TKLIsSpamfilter(tkl))
|
||||
{
|
||||
if (tkl->ptr.spamfilter->match->str)
|
||||
{
|
||||
@@ -655,7 +661,8 @@ void json_expand_textanalysis(json_t *root, const char *key, TextAnalysis *ta, i
|
||||
{
|
||||
j = json_object();
|
||||
json_object_set_new(root, key, j);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
j = root;
|
||||
}
|
||||
|
||||
@@ -667,7 +674,7 @@ void json_expand_textanalysis(json_t *root, const char *key, TextAnalysis *ta, i
|
||||
|
||||
blk = json_object();
|
||||
json_object_set_new(j, "unicode_blockmap", blk);
|
||||
for (i=0; i < UNICODE_BLOCK_COUNT; i++)
|
||||
for (i = 0; i < UNICODE_BLOCK_COUNT; i++)
|
||||
{
|
||||
if (ta->unicode_blockmap[i])
|
||||
json_object_set_new(blk, utf8_get_block_name(i), json_integer(ta->unicode_blockmap[i]));
|
||||
@@ -807,8 +814,7 @@ void json_expand_security_group(json_t *j, const char *key, SecurityGroup *s, in
|
||||
{
|
||||
child = json_object();
|
||||
json_object_set_new(j, key, child);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
child = j;
|
||||
}
|
||||
|
||||
+62
-61
@@ -23,35 +23,34 @@
|
||||
void free_link(Link *);
|
||||
Link *make_link();
|
||||
|
||||
ID_Copyright
|
||||
("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
|
||||
ID_Copyright("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
|
||||
ID_Notes("2.24 4/20/94");
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
static struct liststats {
|
||||
int inuse;
|
||||
int inuse;
|
||||
} cloc, crem, users, servs, links;
|
||||
|
||||
#endif
|
||||
|
||||
MODVAR int flinks = 0;
|
||||
MODVAR int freelinks = 0;
|
||||
MODVAR int flinks = 0;
|
||||
MODVAR int freelinks = 0;
|
||||
MODVAR Link *freelink = NULL;
|
||||
MODVAR Member *freemember = NULL;
|
||||
MODVAR Membership *freemembership = NULL;
|
||||
MODVAR int numclients = 0;
|
||||
MODVAR int numclients = 0;
|
||||
|
||||
// TODO: Document whether servers are included or excluded in these lists...
|
||||
|
||||
MODVAR struct list_head unknown_list; /**< Local clients in handshake (may become a user or server later) */
|
||||
MODVAR struct list_head control_list; /**< Local "control channel" clients */
|
||||
MODVAR struct list_head lclient_list; /**< Local clients (users only, right?) */
|
||||
MODVAR struct list_head client_list; /**< All clients - local and remote (not in handshake) */
|
||||
MODVAR struct list_head server_list; /**< Locally connected servers */
|
||||
MODVAR struct list_head oper_list; /**< Locally connected IRC Operators */
|
||||
MODVAR struct list_head global_server_list; /**< All servers (local and remote) */
|
||||
MODVAR struct list_head dead_list; /**< All dead clients (local and remote) that will soon be freed in the main loop */
|
||||
MODVAR struct list_head rpc_remote_list; /**< All remote RPC clients (very specific use-case) */
|
||||
MODVAR struct list_head unknown_list; /**< Local clients in handshake (may become a user or server later) */
|
||||
MODVAR struct list_head control_list; /**< Local "control channel" clients */
|
||||
MODVAR struct list_head lclient_list; /**< Local clients (users only, right?) */
|
||||
MODVAR struct list_head client_list; /**< All clients - local and remote (not in handshake) */
|
||||
MODVAR struct list_head server_list; /**< Locally connected servers */
|
||||
MODVAR struct list_head oper_list; /**< Locally connected IRC Operators */
|
||||
MODVAR struct list_head global_server_list; /**< All servers (local and remote) */
|
||||
MODVAR struct list_head dead_list; /**< All dead clients (local and remote) that will soon be freed in the main loop */
|
||||
MODVAR struct list_head rpc_remote_list; /**< All remote RPC clients (very specific use-case) */
|
||||
|
||||
static mp_pool_t *client_pool = NULL;
|
||||
static mp_pool_t *local_client_pool = NULL;
|
||||
@@ -60,7 +59,7 @@ static mp_pool_t *link_pool = NULL;
|
||||
|
||||
void initlists(void)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
memset(&cloc, 0, sizeof(cloc));
|
||||
memset(&crem, 0, sizeof(crem));
|
||||
memset(&users, 0, sizeof(users));
|
||||
@@ -99,7 +98,7 @@ Client *make_client(Client *from, Client *servr)
|
||||
Client *client = mp_pool_get(client_pool);
|
||||
memset(client, 0, sizeof(Client));
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
if (!from)
|
||||
cloc.inuse++;
|
||||
else
|
||||
@@ -107,7 +106,7 @@ Client *make_client(Client *from, Client *servr)
|
||||
#endif
|
||||
|
||||
/* Note: all fields are already NULL/0, no need to set here */
|
||||
client->direction = from ? from : client; /* 'from' of local client is self! */
|
||||
client->direction = from ? from : client; /* 'from' of local client is self! */
|
||||
client->uplink = servr;
|
||||
client->status = CLIENT_STATUS_UNKNOWN;
|
||||
|
||||
@@ -120,16 +119,16 @@ Client *make_client(Client *from, Client *servr)
|
||||
{
|
||||
/* Local client */
|
||||
const char *id;
|
||||
|
||||
|
||||
client->local = mp_pool_get(local_client_pool);
|
||||
memset(client->local, 0, sizeof(LocalClient));
|
||||
|
||||
|
||||
INIT_LIST_HEAD(&client->lclient_node);
|
||||
INIT_LIST_HEAD(&client->special_node);
|
||||
|
||||
client->local->fake_lag = client->local->last_msg_received =
|
||||
client->lastnick = client->local->creationtime =
|
||||
client->local->idle_since = TStime();
|
||||
client->lastnick = client->local->creationtime =
|
||||
client->local->idle_since = TStime();
|
||||
client->local->class = NULL;
|
||||
client->local->passwd = NULL;
|
||||
client->local->sockhost[0] = '\0';
|
||||
@@ -196,7 +195,7 @@ void free_client(Client *client)
|
||||
dbuf_delete(&client->local->recvQ, DBufLength(&client->local->recvQ));
|
||||
dbuf_delete(&client->local->sendQ, DBufLength(&client->local->sendQ));
|
||||
free_all_tags(client);
|
||||
|
||||
|
||||
mp_pool_release(client->local);
|
||||
}
|
||||
if (*client->id)
|
||||
@@ -232,7 +231,7 @@ User *make_user(Client *client)
|
||||
memset(user, 0, sizeof(User));
|
||||
client->user = user;
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
users.inuse++;
|
||||
#endif
|
||||
|
||||
@@ -253,7 +252,8 @@ User *make_user(Client *client)
|
||||
{
|
||||
/* initially set client->user->realhost to IP */
|
||||
strlcpy(user->realhost, client->ip, sizeof(user->realhost));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
*user->realhost = '\0';
|
||||
}
|
||||
/* These may change later (eg when using hostname instead of IP),
|
||||
@@ -272,7 +272,7 @@ Server *make_server(Client *client)
|
||||
if (!serv)
|
||||
{
|
||||
serv = safe_alloc(sizeof(Server));
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
servs.inuse++;
|
||||
#endif
|
||||
*serv->by = '\0';
|
||||
@@ -316,7 +316,7 @@ void free_user(Client *client)
|
||||
safe_free(client->user->operlogin);
|
||||
safe_free(client->user->snomask);
|
||||
mp_pool_release(client->user);
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
users.inuse--;
|
||||
#endif
|
||||
client->user = NULL;
|
||||
@@ -355,17 +355,15 @@ void remove_client_from_list(Client *client)
|
||||
if (client->uplink && client->uplink->server)
|
||||
client->uplink->server->users--;
|
||||
}
|
||||
if (IsUnknown(client) || IsConnecting(client) || IsHandshake(client)
|
||||
|| IsTLSHandshake(client)
|
||||
)
|
||||
if (IsUnknown(client) || IsConnecting(client) || IsHandshake(client) || IsTLSHandshake(client))
|
||||
irccounts.unknown--;
|
||||
|
||||
if (IsUser(client)) /* Only persons can have been added before */
|
||||
if (IsUser(client)) /* Only persons can have been added before */
|
||||
{
|
||||
add_history(client, 0, WHOWAS_EVENT_QUIT);
|
||||
off_history(client); /* Remove all pointers to client */
|
||||
off_history(client); /* Remove all pointers to client */
|
||||
}
|
||||
|
||||
|
||||
if (client->user)
|
||||
free_user(client);
|
||||
if (client->server)
|
||||
@@ -378,11 +376,11 @@ void remove_client_from_list(Client *client)
|
||||
safe_free(client->server->features.software);
|
||||
safe_free(client->server->features.nickchars);
|
||||
safe_free(client->server);
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
servs.inuse--;
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
if (client->local && client->local->fd == -2)
|
||||
cloc.inuse--;
|
||||
else
|
||||
@@ -422,7 +420,7 @@ Link *make_link(void)
|
||||
{
|
||||
Link *l = mp_pool_get(link_pool);
|
||||
memset(l, 0, sizeof(Link));
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
links.inuse++;
|
||||
#endif
|
||||
return l;
|
||||
@@ -433,7 +431,7 @@ void free_link(Link *lp)
|
||||
{
|
||||
mp_pool_release(lp);
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
links.inuse--;
|
||||
#endif
|
||||
}
|
||||
@@ -441,7 +439,7 @@ void free_link(Link *lp)
|
||||
/** Returns the length (entry count) of a +beI list */
|
||||
int link_list_length(Link *lp)
|
||||
{
|
||||
int count = 0;
|
||||
int count = 0;
|
||||
|
||||
for (; lp; lp = lp->next)
|
||||
count++;
|
||||
@@ -453,7 +451,7 @@ Ban *make_ban(void)
|
||||
Ban *lp;
|
||||
|
||||
lp = safe_alloc(sizeof(Ban));
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
links.inuse++;
|
||||
#endif
|
||||
return lp;
|
||||
@@ -462,7 +460,7 @@ Ban *make_ban(void)
|
||||
void free_ban(Ban *lp)
|
||||
{
|
||||
safe_free(lp);
|
||||
#ifdef DEBUGMODE
|
||||
#ifdef DEBUGMODE
|
||||
links.inuse--;
|
||||
#endif
|
||||
}
|
||||
@@ -489,7 +487,8 @@ void append_ListItem(ListStruct *item, ListStruct **list)
|
||||
return;
|
||||
}
|
||||
|
||||
for (l = *list; l->next; l = l->next);
|
||||
for (l = *list; l->next; l = l->next)
|
||||
;
|
||||
l->next = item;
|
||||
item->prev = l;
|
||||
}
|
||||
@@ -516,14 +515,14 @@ void del_ListItem(ListStruct *item, ListStruct **list)
|
||||
void add_ListItemPrio(ListStructPrio *new, ListStructPrio **list, int priority)
|
||||
{
|
||||
ListStructPrio *x, *last = NULL;
|
||||
|
||||
|
||||
if (!*list)
|
||||
{
|
||||
/* We are the only item. Easy. */
|
||||
*list = new;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (x = *list; x; x = x->next)
|
||||
{
|
||||
last = x;
|
||||
@@ -540,7 +539,8 @@ void add_ListItemPrio(ListStructPrio *new, ListStructPrio **list, int priority)
|
||||
new->next = x;
|
||||
x->prev->next = new;
|
||||
x->prev = new;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* We are the new head */
|
||||
*list = new;
|
||||
new->next = x;
|
||||
@@ -558,14 +558,14 @@ void add_ListItemPrio(ListStructPrio *new, ListStructPrio **list, int priority)
|
||||
|
||||
void _add_name_list(NameList **list, const char *name)
|
||||
{
|
||||
NameList *e = safe_alloc(sizeof(NameList)+strlen(name)+1);
|
||||
NameList *e = safe_alloc(sizeof(NameList) + strlen(name) + 1);
|
||||
strcpy(e->name, name); /* safe, allocated above */
|
||||
AddListItem(e, *list);
|
||||
}
|
||||
|
||||
void _append_name_list(NameList **list, const char *name)
|
||||
{
|
||||
NameList *e = safe_alloc(sizeof(NameList)+strlen(name)+1);
|
||||
NameList *e = safe_alloc(sizeof(NameList) + strlen(name) + 1);
|
||||
strcpy(e->name, name); /* safe, allocated above */
|
||||
AppendListItem(e, *list);
|
||||
}
|
||||
@@ -588,7 +588,7 @@ NameList *duplicate_name_list(NameList *e)
|
||||
/* We do manual pointer tracking here to speed things up */
|
||||
for (; e; e = e->next)
|
||||
{
|
||||
n = safe_alloc(sizeof(NameList)+strlen(e->name)+1);
|
||||
n = safe_alloc(sizeof(NameList) + strlen(e->name) + 1);
|
||||
strcpy(n->name, e->name); /* safe, allocated above */
|
||||
if (tail)
|
||||
tail->next = n;
|
||||
@@ -739,34 +739,35 @@ NameValuePrioList *duplicate_nvplist_append(NameValuePrioList *e, NameValuePrioL
|
||||
return *list;
|
||||
}
|
||||
|
||||
#define nv_find_by_name(stru, name) do_nv_find_by_name(stru, name, ARRAY_SIZEOF((stru)))
|
||||
#define nv_find_by_name(stru, name) do_nv_find_by_name(stru, name, ARRAY_SIZEOF((stru)))
|
||||
|
||||
long do_nv_find_by_name(NameValue *table, const char *cmd, int numelements)
|
||||
{
|
||||
int start = 0;
|
||||
int stop = numelements-1;
|
||||
int stop = numelements - 1;
|
||||
int mid;
|
||||
while (start <= stop) {
|
||||
mid = (start+stop)/2;
|
||||
while (start <= stop)
|
||||
{
|
||||
mid = (start + stop) / 2;
|
||||
|
||||
if (smycmp(cmd,table[mid].name) < 0) {
|
||||
stop = mid-1;
|
||||
}
|
||||
else if (strcmp(cmd,table[mid].name) == 0) {
|
||||
if (smycmp(cmd, table[mid].name) < 0)
|
||||
{
|
||||
stop = mid - 1;
|
||||
} else if (strcmp(cmd, table[mid].name) == 0)
|
||||
{
|
||||
return table[mid].value;
|
||||
}
|
||||
else
|
||||
start = mid+1;
|
||||
} else
|
||||
start = mid + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define nv_find_by_value(stru, value) do_nv_find_by_value(stru, value, ARRAY_SIZEOF((stru)))
|
||||
#define nv_find_by_value(stru, value) do_nv_find_by_value(stru, value, ARRAY_SIZEOF((stru)))
|
||||
const char *do_nv_find_by_value(NameValue *table, long value, int numelements)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < numelements; i++)
|
||||
for (i = 0; i < numelements; i++)
|
||||
if (table[i].value == value)
|
||||
return table[i].name;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
// TODO: Make configurable at compile time (runtime won't do, as we haven't read the config file)
|
||||
#define show_event_console 0
|
||||
|
||||
#define MAXLOGLENGTH 16384 /**< Maximum length of a log entry (which may be multiple lines) */
|
||||
#define MAXLOGLENGTH 16384 /**< Maximum length of a log entry (which may be multiple lines) */
|
||||
#define LOG_THROTTLE_TABLE_SIZE 256
|
||||
|
||||
typedef struct LogThrottleEntry LogThrottleEntry;
|
||||
@@ -47,12 +47,12 @@ struct LogThrottleEntry {
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
Log *logs[NUM_LOG_DESTINATIONS] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
Log *temp_logs[NUM_LOG_DESTINATIONS] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
Log *logs[NUM_LOG_DESTINATIONS] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
Log *temp_logs[NUM_LOG_DESTINATIONS] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
static int snomask_num_destinations = 0;
|
||||
|
||||
static char snomasks_in_use[257] = { '\0' };
|
||||
static char snomasks_in_use_testing[257] = { '\0' };
|
||||
static char snomasks_in_use[257] = {'\0'};
|
||||
static char snomasks_in_use_testing[257] = {'\0'};
|
||||
|
||||
LogEntry *memory_log = NULL; /**< Log entries in memory (OLDEST entry) */
|
||||
LogEntry *memory_log_tail = NULL; /**< Tail of log entries in memory (NEWEST entry) */
|
||||
@@ -81,7 +81,7 @@ LogType log_type_stringtoval(const char *str)
|
||||
|
||||
const char *log_type_valtostring(LogType v)
|
||||
{
|
||||
switch(v)
|
||||
switch (v)
|
||||
{
|
||||
case LOG_TYPE_TEXT:
|
||||
return "text";
|
||||
@@ -119,7 +119,7 @@ LogSource *add_log_source(const char *str)
|
||||
if (*str == '!')
|
||||
{
|
||||
negative = 1;
|
||||
strlcpy(buf, str+1, sizeof(buf));
|
||||
strlcpy(buf, str + 1, sizeof(buf));
|
||||
} else
|
||||
{
|
||||
strlcpy(buf, str, sizeof(buf));
|
||||
@@ -142,8 +142,7 @@ LogSource *add_log_source(const char *str)
|
||||
if (isupper(*p))
|
||||
{
|
||||
event_id = p;
|
||||
} else
|
||||
if (loglevel == ULOG_INVALID)
|
||||
} else if (loglevel == ULOG_INVALID)
|
||||
{
|
||||
loglevel = log_level_stringtoval(p);
|
||||
if ((loglevel == ULOG_INVALID) && !subsystem)
|
||||
@@ -195,8 +194,7 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
/* TODO: Validate the sources lightly for formatting issues */
|
||||
any_sources = 1;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "destination"))
|
||||
} else if (!strcmp(ce->name, "destination"))
|
||||
{
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
@@ -209,17 +207,16 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
{
|
||||
config_error_blank(cep->file->filename, cep->line_number, "set::logging::snomask");
|
||||
errors++;
|
||||
} else
|
||||
if ((strlen(cep->value) != 1) || !(islower(cep->value[0]) || isupper(cep->value[0])))
|
||||
} else if ((strlen(cep->value) != 1) || !(islower(cep->value[0]) || isupper(cep->value[0])))
|
||||
{
|
||||
config_error("%s:%d: snomask must be a single letter",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
strlcat(snomasks_in_use_testing, cep->value, sizeof(snomasks_in_use_testing));
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "channel"))
|
||||
} else if (!strcmp(cep->name, "channel"))
|
||||
{
|
||||
destinations++;
|
||||
/* We need to validate the parameter here as well */
|
||||
@@ -227,11 +224,10 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
{
|
||||
config_error_blank(cep->file->filename, cep->line_number, "set::logging::channel");
|
||||
errors++;
|
||||
} else
|
||||
if (!valid_channelname(cep->value))
|
||||
} else if (!valid_channelname(cep->value))
|
||||
{
|
||||
config_error("%s:%d: Invalid channel name '%s'",
|
||||
cep->file->filename, cep->line_number, cep->value);
|
||||
cep->file->filename, cep->line_number, cep->value);
|
||||
errors++;
|
||||
}
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
@@ -250,8 +246,7 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "file"))
|
||||
} else if (!strcmp(cep->name, "file"))
|
||||
{
|
||||
destinations++;
|
||||
if (!cep->value)
|
||||
@@ -268,24 +263,23 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename,
|
||||
cepp->line_number, "log", cepp->name);
|
||||
cepp->line_number, "log", cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
if (!log_type_stringtoval(cepp->value))
|
||||
{
|
||||
config_error("%s:%i: unknown log type '%s'",
|
||||
cepp->file->filename, cepp->line_number,
|
||||
cepp->value);
|
||||
cepp->file->filename, cepp->line_number,
|
||||
cepp->value);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "maxsize") || !strcmp(cepp->name, "max-size"))
|
||||
} else if (!strcmp(cepp->name, "maxsize") || !strcmp(cepp->name, "max-size"))
|
||||
{
|
||||
if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename,
|
||||
cepp->line_number, "log", cepp->name);
|
||||
cepp->line_number, "log", cepp->name);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
@@ -294,12 +288,10 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "remote"))
|
||||
} else if (!strcmp(cep->name, "remote"))
|
||||
{
|
||||
destinations++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "syslog"))
|
||||
} else if (!strcmp(cep->name, "syslog"))
|
||||
{
|
||||
destinations++;
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
@@ -309,15 +301,15 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename,
|
||||
cepp->line_number, "log", cepp->name);
|
||||
cepp->line_number, "log", cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
if (!log_type_stringtoval(cepp->value))
|
||||
{
|
||||
config_error("%s:%i: unknown log type '%s'",
|
||||
cepp->file->filename, cepp->line_number,
|
||||
cepp->value);
|
||||
cepp->file->filename, cepp->line_number,
|
||||
cepp->value);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
@@ -326,8 +318,7 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "memory"))
|
||||
} else if (!strcmp(cep->name, "memory"))
|
||||
{
|
||||
destinations++;
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
@@ -337,16 +328,15 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename,
|
||||
cepp->line_number, "log", cepp->name);
|
||||
cepp->line_number, "log", cepp->name);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "max-time"))
|
||||
} else if (!strcmp(cepp->name, "max-time"))
|
||||
{
|
||||
if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename,
|
||||
cepp->line_number, "log", cepp->name);
|
||||
cepp->line_number, "log", cepp->name);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
@@ -361,12 +351,12 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: webhook needs a url",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
} else if (strncmp(cep->value, "http://", 7) != 0 && strncmp(cep->value, "https://", 8) != 0)
|
||||
{
|
||||
config_error("%s:%i: webhook url must be a HTTP/HTTPS URL (%s)",
|
||||
cep->file->filename, cep->line_number, cep->value);
|
||||
cep->file->filename, cep->line_number, cep->value);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
@@ -399,19 +389,19 @@ int config_test_log(ConfigFile *conf, ConfigEntry *block)
|
||||
if (!any_sources)
|
||||
{
|
||||
config_error("%s:%d: log block contains no sources. Old log block perhaps?",
|
||||
block->file->filename, block->line_number);
|
||||
block->file->filename, block->line_number);
|
||||
errors++;
|
||||
}
|
||||
if (destinations == 0)
|
||||
{
|
||||
config_error("%s:%d: log block contains no destinations. Old log block perhaps?",
|
||||
block->file->filename, block->line_number);
|
||||
block->file->filename, block->line_number);
|
||||
errors++;
|
||||
}
|
||||
if (destinations > 1)
|
||||
{
|
||||
config_error("%s:%d: log block contains multiple destinations. This is not support... YET!",
|
||||
block->file->filename, block->line_number);
|
||||
block->file->filename, block->line_number);
|
||||
errors++;
|
||||
}
|
||||
return errors;
|
||||
@@ -458,8 +448,7 @@ int config_run_log(ConfigFile *conf, ConfigEntry *block)
|
||||
AddListItem(log, temp_logs[LOG_DEST_OPER]);
|
||||
else
|
||||
AddListItem(log, temp_logs[LOG_DEST_SNOMASK]);
|
||||
} else
|
||||
if (!strcmp(cep->name, "channel"))
|
||||
} else if (!strcmp(cep->name, "channel"))
|
||||
{
|
||||
Log *log = safe_alloc(sizeof(Log));
|
||||
strlcpy(log->destination, cep->value, sizeof(log->destination)); /* destination is the channel */
|
||||
@@ -482,15 +471,13 @@ int config_run_log(ConfigFile *conf, ConfigEntry *block)
|
||||
else if (!strcmp(cepp->name, "oper-only"))
|
||||
log->oper_only = config_checkval(cepp->value, CFG_YESNO);
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "remote"))
|
||||
} else if (!strcmp(cep->name, "remote"))
|
||||
{
|
||||
Log *log = safe_alloc(sizeof(Log));
|
||||
/* destination stays empty */
|
||||
log->sources = sources;
|
||||
AddListItem(log, temp_logs[LOG_DEST_REMOTE]);
|
||||
} else
|
||||
if (!strcmp(cep->name, "file") || !strcmp(cep->name, "syslog"))
|
||||
} else if (!strcmp(cep->name, "file") || !strcmp(cep->name, "syslog"))
|
||||
{
|
||||
Log *log;
|
||||
|
||||
@@ -506,9 +493,9 @@ int config_run_log(ConfigFile *conf, ConfigEntry *block)
|
||||
(log->filefmt && !strcmp(log->filefmt, cep->value)))
|
||||
{
|
||||
config_warn("%s:%d: Ignoring duplicate log block for file '%s'. "
|
||||
"You cannot have multiple log blocks logging to the same file.",
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
"You cannot have multiple log blocks logging to the same file.",
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
free_log_sources(sources);
|
||||
return 0;
|
||||
}
|
||||
@@ -528,22 +515,20 @@ int config_run_log(ConfigFile *conf, ConfigEntry *block)
|
||||
{
|
||||
if (!strcmp(cepp->name, "maxsize") || !strcmp(cepp->name, "max-size"))
|
||||
{
|
||||
log->max_size = config_checkval(cepp->value,CFG_SIZE);
|
||||
}
|
||||
else if (!strcmp(cepp->name, "type"))
|
||||
log->max_size = config_checkval(cepp->value, CFG_SIZE);
|
||||
} else if (!strcmp(cepp->name, "type"))
|
||||
{
|
||||
log->type = log_type_stringtoval(cepp->value);
|
||||
}
|
||||
}
|
||||
AddListItem(log, temp_logs[LOG_DEST_DISK]);
|
||||
} else
|
||||
if (!strcmp(cep->name, "memory"))
|
||||
} else if (!strcmp(cep->name, "memory"))
|
||||
{
|
||||
if (temp_logs[LOG_DEST_MEMORY])
|
||||
{
|
||||
config_warn("%s:%d: Ignoring duplicate log block for memory. "
|
||||
"You cannot have multiple log blocks logging to memory.",
|
||||
cep->file->filename, cep->line_number);
|
||||
"You cannot have multiple log blocks logging to memory.",
|
||||
cep->file->filename, cep->line_number);
|
||||
free_log_sources(sources);
|
||||
return 0;
|
||||
}
|
||||
@@ -555,16 +540,14 @@ int config_run_log(ConfigFile *conf, ConfigEntry *block)
|
||||
{
|
||||
if (!strcmp(cepp->name, "max-lines"))
|
||||
{
|
||||
log->max_lines = config_checkval(cepp->value,CFG_SIZE);
|
||||
}
|
||||
else if (!strcmp(cepp->name, "max-time"))
|
||||
log->max_lines = config_checkval(cepp->value, CFG_SIZE);
|
||||
} else if (!strcmp(cepp->name, "max-time"))
|
||||
{
|
||||
log->max_time = config_checkval(cepp->value,CFG_TIME);
|
||||
log->max_time = config_checkval(cepp->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
AddListItem(log, temp_logs[LOG_DEST_MEMORY]);
|
||||
} else
|
||||
if (!strcmp(cep->name, "webhook"))
|
||||
} else if (!strcmp(cep->name, "webhook"))
|
||||
{
|
||||
Log *log = safe_alloc(sizeof(Log));
|
||||
safe_strdup(log->url, cep->value);
|
||||
@@ -730,7 +713,8 @@ LogData *log_data_tls_error(void)
|
||||
json_object_set_new(j, "error_stack", error_stack);
|
||||
*all_errors = '\0';
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
json_t *obj;
|
||||
|
||||
e = ERR_get_error();
|
||||
@@ -750,7 +734,7 @@ LogData *log_data_tls_error(void)
|
||||
}
|
||||
strlcat(all_errors, buf, sizeof(all_errors));
|
||||
strlcat(all_errors, "\n", sizeof(all_errors));
|
||||
} while(e);
|
||||
} while (e);
|
||||
|
||||
json_object_set_new(j, "all", json_string_unreal(all_errors));
|
||||
|
||||
@@ -829,7 +813,7 @@ void log_data_free(LogData *d)
|
||||
|
||||
const char *log_level_valtostring(LogLevel loglevel)
|
||||
{
|
||||
switch(loglevel)
|
||||
switch (loglevel)
|
||||
{
|
||||
case ULOG_DEBUG:
|
||||
return "debug";
|
||||
@@ -849,23 +833,23 @@ const char *log_level_valtostring(LogLevel loglevel)
|
||||
}
|
||||
|
||||
static NameValue log_colors_irc[] = {
|
||||
{ ULOG_INVALID, "\0030,01" },
|
||||
{ ULOG_DEBUG, "\0030,01" },
|
||||
{ ULOG_INFO, "\00303" },
|
||||
{ ULOG_ADVICE, "\00312" },
|
||||
{ ULOG_WARNING, "\00307" },
|
||||
{ ULOG_ERROR, "\00304" },
|
||||
{ ULOG_FATAL, "\00313" },
|
||||
{ULOG_INVALID, "\0030,01"},
|
||||
{ULOG_DEBUG, "\0030,01"},
|
||||
{ULOG_INFO, "\00303"},
|
||||
{ULOG_ADVICE, "\00312"},
|
||||
{ULOG_WARNING, "\00307"},
|
||||
{ULOG_ERROR, "\00304"},
|
||||
{ULOG_FATAL, "\00313"},
|
||||
};
|
||||
|
||||
static NameValue log_colors_terminal[] = {
|
||||
{ ULOG_INVALID, "\033[90m" },
|
||||
{ ULOG_DEBUG, "\033[37m" },
|
||||
{ ULOG_INFO, "\033[92m" },
|
||||
{ ULOG_ADVICE, "\033[94m" },
|
||||
{ ULOG_WARNING, "\033[93m" },
|
||||
{ ULOG_ERROR, "\033[91m" },
|
||||
{ ULOG_FATAL, "\033[95m" },
|
||||
{ULOG_INVALID, "\033[90m"},
|
||||
{ULOG_DEBUG, "\033[37m"},
|
||||
{ULOG_INFO, "\033[92m"},
|
||||
{ULOG_ADVICE, "\033[94m"},
|
||||
{ULOG_WARNING, "\033[93m"},
|
||||
{ULOG_ERROR, "\033[91m"},
|
||||
{ULOG_FATAL, "\033[95m"},
|
||||
};
|
||||
|
||||
const char *log_level_irc_color(LogLevel loglevel)
|
||||
@@ -895,8 +879,8 @@ LogLevel log_level_stringtoval(const char *str)
|
||||
return ULOG_INVALID;
|
||||
}
|
||||
|
||||
#define valideventidcharacter(x) (isupper((x)) || isdigit((x)) || ((x) == '_'))
|
||||
#define validsubsystemcharacter(x) (islower((x)) || isdigit((x)) || ((x) == '_') || ((x) == '-'))
|
||||
#define valideventidcharacter(x) (isupper((x)) || isdigit((x)) || ((x) == '_'))
|
||||
#define validsubsystemcharacter(x) (islower((x)) || isdigit((x)) || ((x) == '_') || ((x) == '-'))
|
||||
|
||||
int valid_event_id(const char *s)
|
||||
{
|
||||
@@ -978,7 +962,8 @@ void buildlogstring(const char *inbuf, char *outbuf, size_t len, json_t *details
|
||||
}
|
||||
|
||||
/* find termination */
|
||||
for (p=i; validvarcharacter(*p) || ((*p == '.') && validvarcharacter(p[1])); p++);
|
||||
for (p = i; validvarcharacter(*p) || ((*p == '.') && validvarcharacter(p[1])); p++)
|
||||
;
|
||||
|
||||
/* find variable name in list */
|
||||
strlncpy(varname, i, sizeof(varname), p - i);
|
||||
@@ -992,25 +977,24 @@ void buildlogstring(const char *inbuf, char *outbuf, size_t len, json_t *details
|
||||
if (varp)
|
||||
{
|
||||
char *varpp;
|
||||
do {
|
||||
varpp = strchr(varp+1, '.');
|
||||
do
|
||||
{
|
||||
varpp = strchr(varp + 1, '.');
|
||||
if (varpp)
|
||||
*varpp = '\0';
|
||||
/* Fetch explicit object.key */
|
||||
t = json_object_get(t, varp+1);
|
||||
t = json_object_get(t, varp + 1);
|
||||
varp = varpp;
|
||||
} while(t && varpp);
|
||||
} while (t && varpp);
|
||||
if (t)
|
||||
output = json_get_value(t);
|
||||
} else
|
||||
if (!strcmp(varname, "socket_error"))
|
||||
} else if (!strcmp(varname, "socket_error"))
|
||||
{
|
||||
/* Fetch socket_error.error_string */
|
||||
t = json_object_get(t, "error_string");
|
||||
if (t)
|
||||
output = json_get_value(t);
|
||||
} else
|
||||
if (json_is_object(t))
|
||||
} else if (json_is_object(t))
|
||||
{
|
||||
/* Fetch object.name */
|
||||
t = json_object_get(t, "name");
|
||||
@@ -1038,8 +1022,7 @@ void buildlogstring(const char *inbuf, char *outbuf, size_t len, json_t *details
|
||||
if (left <= 0)
|
||||
return; /* return - don't write \0 to 'o'. ensured by strlcpy already */
|
||||
o += strlen(output); /* value entirely written */
|
||||
} else
|
||||
if (opt)
|
||||
} else if (opt)
|
||||
{
|
||||
/* Optional field that is empty: show nothing and eat a
|
||||
* preceding space. */
|
||||
@@ -1056,7 +1039,7 @@ void buildlogstring(const char *inbuf, char *outbuf, size_t len, json_t *details
|
||||
i = p - 1;
|
||||
continue;
|
||||
}
|
||||
literal:
|
||||
literal:
|
||||
if (!left)
|
||||
break;
|
||||
*o++ = *i;
|
||||
@@ -1090,7 +1073,7 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (show_event_console)
|
||||
win_log("* %s.%s%s [%s] %s\n", subsystem, event_id, m->next?"+":"", log_level_valtostring(loglevel), m->line);
|
||||
win_log("* %s.%s%s [%s] %s\n", subsystem, event_id, m->next ? "+" : "", log_level_valtostring(loglevel), m->line);
|
||||
else
|
||||
win_log("* [%s] %s\n", log_level_valtostring(loglevel), m->line);
|
||||
#else
|
||||
@@ -1099,17 +1082,19 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (show_event_console)
|
||||
{
|
||||
fprintf(stderr, "%s%s.%s%s %s[%s]%s %s\n",
|
||||
log_level_terminal_color(ULOG_INVALID), subsystem, event_id, TERMINAL_COLOR_RESET,
|
||||
log_level_terminal_color(loglevel), log_level_valtostring(loglevel), TERMINAL_COLOR_RESET,
|
||||
m->line);
|
||||
} else {
|
||||
log_level_terminal_color(ULOG_INVALID), subsystem, event_id, TERMINAL_COLOR_RESET,
|
||||
log_level_terminal_color(loglevel), log_level_valtostring(loglevel), TERMINAL_COLOR_RESET,
|
||||
m->line);
|
||||
} else
|
||||
{
|
||||
fprintf(stderr, "%s[%s]%s %s\n",
|
||||
log_level_terminal_color(loglevel), log_level_valtostring(loglevel), TERMINAL_COLOR_RESET,
|
||||
m->line);
|
||||
log_level_terminal_color(loglevel), log_level_valtostring(loglevel), TERMINAL_COLOR_RESET,
|
||||
m->line);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (show_event_console)
|
||||
fprintf(stderr, "%s.%s%s [%s] %s\n", subsystem, event_id, m->next?"+":"", log_level_valtostring(loglevel), m->line);
|
||||
fprintf(stderr, "%s.%s%s [%s] %s\n", subsystem, event_id, m->next ? "+" : "", log_level_valtostring(loglevel), m->line);
|
||||
else
|
||||
fprintf(stderr, "[%s] %s\n", log_level_valtostring(loglevel), m->line);
|
||||
}
|
||||
@@ -1132,11 +1117,10 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (l->type == LOG_TYPE_JSON)
|
||||
{
|
||||
syslog(LOG_INFO, "%s", json_serialized);
|
||||
} else
|
||||
if (l->type == LOG_TYPE_TEXT)
|
||||
} else if (l->type == LOG_TYPE_TEXT)
|
||||
{
|
||||
for (m = msg; m; m = m->next)
|
||||
syslog(LOG_INFO, "%s.%s%s %s: %s", subsystem, event_id, m->next?"+":"", log_level_valtostring(loglevel), m->line);
|
||||
syslog(LOG_INFO, "%s.%s%s %s: %s", subsystem, event_id, m->next ? "+" : "", log_level_valtostring(loglevel), m->line);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1162,7 +1146,7 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (l->logfd == -1)
|
||||
{
|
||||
/* Try to open, so we can write the 'Max file size reached' message. */
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT|O_APPEND|O_WRONLY);
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT | O_APPEND | O_WRONLY);
|
||||
}
|
||||
if (l->logfd != -1)
|
||||
{
|
||||
@@ -1186,14 +1170,14 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
/* generic code for opening log if not open yet.. */
|
||||
if (l->logfd == -1)
|
||||
{
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT|O_APPEND|O_WRONLY);
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT | O_APPEND | O_WRONLY);
|
||||
if (l->logfd == -1)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/* Create directory structure and retry */
|
||||
unreal_create_directory_structure_for_file(l->file, 0777);
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT|O_APPEND|O_WRONLY);
|
||||
l->logfd = fd_fileopen(l->file, O_CREAT | O_APPEND | O_WRONLY);
|
||||
}
|
||||
if (l->logfd == -1)
|
||||
{
|
||||
@@ -1201,7 +1185,8 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (!loop.booted)
|
||||
{
|
||||
config_status("WARNING: Unable to write to '%s': %s", l->file, strerror(errno));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (last_log_file_warning + 300 < TStime())
|
||||
{
|
||||
config_status("WARNING: Unable to write to '%s': %s. This warning will not re-appear for at least 5 minutes.", l->file, strerror(errno));
|
||||
@@ -1221,19 +1206,19 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (n < strlen(json_serialized))
|
||||
{
|
||||
write_error = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (write(l->logfd, "\n", 1) < 1) // FIXME: no.. we should do it this way..... and why do we use direct I/O at all?
|
||||
write_error = 1;
|
||||
}
|
||||
} else
|
||||
if (l->type == LOG_TYPE_TEXT)
|
||||
} else if (l->type == LOG_TYPE_TEXT)
|
||||
{
|
||||
for (m = msg; m; m = m->next)
|
||||
{
|
||||
static char text_buf[MAXLOGLENGTH];
|
||||
snprintf(text_buf, sizeof(text_buf), "%s%s %s.%s%s %s: %s\n",
|
||||
timebuf, from_server->name,
|
||||
subsystem, event_id, m->next?"+":"", log_level_valtostring(loglevel), m->line);
|
||||
timebuf, from_server->name,
|
||||
subsystem, event_id, m->next ? "+" : "", log_level_valtostring(loglevel), m->line);
|
||||
n = write(l->logfd, text_buf, strlen(text_buf));
|
||||
if (n < strlen(text_buf))
|
||||
{
|
||||
@@ -1248,7 +1233,8 @@ void do_unreal_log_disk(LogLevel loglevel, const char *subsystem, const char *ev
|
||||
if (!loop.booted)
|
||||
{
|
||||
config_status("WARNING: Unable to write to '%s': %s", l->file, strerror(errno));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (last_log_file_warning + 300 < TStime())
|
||||
{
|
||||
config_status("WARNING: Unable to write to '%s': %s. This warning will not re-appear for at least 5 minutes.", l->file, strerror(errno));
|
||||
@@ -1345,7 +1331,7 @@ const char *log_to_snomask(LogLevel loglevel, const char *subsystem, const char
|
||||
return *snomasks ? snomasks : NULL;
|
||||
}
|
||||
|
||||
#define COLOR_NONE "\xf"
|
||||
#define COLOR_NONE "\xf"
|
||||
#define COLOR_DARKGREY "\00314"
|
||||
|
||||
/** Generic sendto function for logging to IRC. Used for notices to IRCOps and also for sending to individual users on channels */
|
||||
@@ -1373,29 +1359,32 @@ void sendto_log(Client *client, const char *msgtype, const char *destination, in
|
||||
if (show_event)
|
||||
{
|
||||
sendto_one(client, mtags, ":%s %s %s :%s%s.%s%s%s %s[%s]%s %s",
|
||||
from_server->name, msgtype, destination,
|
||||
COLOR_DARKGREY, subsystem, event_id, m->next?"+":"", COLOR_NONE,
|
||||
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
|
||||
m->line);
|
||||
} else {
|
||||
from_server->name, msgtype, destination,
|
||||
COLOR_DARKGREY, subsystem, event_id, m->next ? "+" : "", COLOR_NONE,
|
||||
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
|
||||
m->line);
|
||||
} else
|
||||
{
|
||||
sendto_one(client, mtags, ":%s %s %s :%s[%s]%s %s",
|
||||
from_server->name, msgtype, destination,
|
||||
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
|
||||
m->line);
|
||||
from_server->name, msgtype, destination,
|
||||
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
|
||||
m->line);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (show_event)
|
||||
{
|
||||
sendto_one(client, mtags, ":%s %s %s :%s.%s%s [%s] %s",
|
||||
from_server->name, msgtype, destination,
|
||||
subsystem, event_id, m->next?"+":"",
|
||||
log_level_valtostring(loglevel),
|
||||
m->line);
|
||||
} else {
|
||||
from_server->name, msgtype, destination,
|
||||
subsystem, event_id, m->next ? "+" : "",
|
||||
log_level_valtostring(loglevel),
|
||||
m->line);
|
||||
} else
|
||||
{
|
||||
sendto_one(client, mtags, ":%s %s %s :[%s] %s",
|
||||
from_server->name, msgtype, destination,
|
||||
log_level_valtostring(loglevel),
|
||||
m->line);
|
||||
from_server->name, msgtype, destination,
|
||||
log_level_valtostring(loglevel),
|
||||
m->line);
|
||||
}
|
||||
}
|
||||
safe_free_message_tags(mtags);
|
||||
@@ -1543,7 +1532,7 @@ void webhook_send_async(const char *url, const char *json_data)
|
||||
{
|
||||
OutgoingWebRequest *request;
|
||||
NameValuePrioList *headers = NULL;
|
||||
|
||||
|
||||
request = safe_alloc(sizeof(OutgoingWebRequest));
|
||||
safe_strdup(request->url, url);
|
||||
request->http_method = HTTP_METHOD_POST;
|
||||
@@ -1551,16 +1540,16 @@ void webhook_send_async(const char *url, const char *json_data)
|
||||
add_nvplist(&headers, 0, "Content-Type", "application/json");
|
||||
add_nvplist(&headers, 0, "User-Agent", "UnrealIRCd-Webhook/1.0");
|
||||
request->headers = headers;
|
||||
|
||||
|
||||
if (json_data && *json_data)
|
||||
{
|
||||
safe_strdup(request->body, json_data);
|
||||
}
|
||||
|
||||
|
||||
/* Use default callback that doesn't care about response */
|
||||
request->callback = download_complete_dontcare;
|
||||
request->max_redirects = 3;
|
||||
|
||||
|
||||
url_start_async(request);
|
||||
}
|
||||
|
||||
@@ -1577,10 +1566,8 @@ void do_unreal_log_control(LogLevel loglevel, const char *subsystem, const char
|
||||
if (!strcmp(subsystem, "rawtraffic"))
|
||||
return;
|
||||
|
||||
list_for_each_entry(client, &control_list, lclient_node)
|
||||
if (IsMonitorRehash(client) && IsControl(client))
|
||||
for (m = msg; m; m = m->next)
|
||||
sendto_one(client, NULL, "REPLY [%s] %s", log_level_valtostring(loglevel), m->line);
|
||||
list_for_each_entry(client, &control_list, lclient_node) if (IsMonitorRehash(client) && IsControl(client)) for (m = msg; m; m = m->next)
|
||||
sendto_one(client, NULL, "REPLY [%s] %s", log_level_valtostring(loglevel), m->line);
|
||||
|
||||
if (json_rehash_log)
|
||||
{
|
||||
@@ -1651,8 +1638,7 @@ void log_throttle_init(void)
|
||||
|
||||
static unsigned int hash_log_throttle_entry(const char *event_id)
|
||||
{
|
||||
return (unsigned int)(siphash_nocase(event_id, log_throttle_siphashkey)
|
||||
% LOG_THROTTLE_TABLE_SIZE);
|
||||
return (unsigned int)(siphash_nocase(event_id, log_throttle_siphashkey) % LOG_THROTTLE_TABLE_SIZE);
|
||||
}
|
||||
|
||||
static LogThrottleEntry *find_log_throttle_entry(const char *event_id, unsigned int idx)
|
||||
@@ -1665,8 +1651,8 @@ static LogThrottleEntry *find_log_throttle_entry(const char *event_id, unsigned
|
||||
}
|
||||
|
||||
static LogThrottleEntry *add_log_throttle_entry(const char *event_id, const char *subsystem,
|
||||
int threshold, int period, int unlimited,
|
||||
unsigned int idx)
|
||||
int threshold, int period, int unlimited,
|
||||
unsigned int idx)
|
||||
{
|
||||
LogThrottleEntry *e = safe_alloc(sizeof(LogThrottleEntry));
|
||||
safe_strdup(e->event_id, event_id);
|
||||
@@ -1695,12 +1681,12 @@ static void emit_log_throttle_summary(LogThrottleEntry *e)
|
||||
return;
|
||||
|
||||
unreal_log(ULOG_INFO, "log", "LOG_RATE_LIMIT_SUMMARY", NULL,
|
||||
"Suppressed $count log entries with event_id $throttled_event_id "
|
||||
"(subsystem $throttled_subsystem) over the last $period seconds",
|
||||
log_data_integer("count", suppressed),
|
||||
log_data_string("throttled_event_id", e->event_id),
|
||||
log_data_string("throttled_subsystem", log_throttle_subsystem_or(e)),
|
||||
log_data_integer("period", period));
|
||||
"Suppressed $count log entries with event_id $throttled_event_id "
|
||||
"(subsystem $throttled_subsystem) over the last $period seconds",
|
||||
log_data_integer("count", suppressed),
|
||||
log_data_string("throttled_event_id", e->event_id),
|
||||
log_data_string("throttled_subsystem", log_throttle_subsystem_or(e)),
|
||||
log_data_integer("period", period));
|
||||
}
|
||||
|
||||
/* Returns 1 if this log line should be suppressed.
|
||||
@@ -1785,8 +1771,7 @@ void log_throttle_rehash(void)
|
||||
e->threshold = threshold;
|
||||
e->period = period;
|
||||
e->unlimited = unlimited;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
e->unlimited = 1;
|
||||
}
|
||||
@@ -1878,31 +1863,31 @@ void do_unreal_log_internal(LogLevel loglevel, const char *subsystem, const char
|
||||
if (loglevel_string == NULL)
|
||||
{
|
||||
do_unreal_log_norecursioncheck(ULOG_ERROR, "log", "BUG_LOG_LOGLEVEL", NULL,
|
||||
"[BUG] Next log message had an invalid log level -- corrected to ULOG_ERROR",
|
||||
NULL);
|
||||
"[BUG] Next log message had an invalid log level -- corrected to ULOG_ERROR",
|
||||
NULL);
|
||||
loglevel = ULOG_ERROR;
|
||||
loglevel_string = log_level_valtostring(loglevel);
|
||||
}
|
||||
if (!valid_subsystem(subsystem))
|
||||
{
|
||||
do_unreal_log_norecursioncheck(ULOG_ERROR, "log", "BUG_LOG_SUBSYSTEM", NULL,
|
||||
"[BUG] Next log message had an invalid subsystem -- changed to 'unknown'",
|
||||
NULL);
|
||||
"[BUG] Next log message had an invalid subsystem -- changed to 'unknown'",
|
||||
NULL);
|
||||
subsystem = "unknown";
|
||||
}
|
||||
if (!valid_event_id(event_id))
|
||||
{
|
||||
do_unreal_log_norecursioncheck(ULOG_ERROR, "log", "BUG_LOG_EVENT_ID", NULL,
|
||||
"[BUG] Next log message had an invalid event id -- changed to 'unknown'",
|
||||
NULL);
|
||||
"[BUG] Next log message had an invalid event id -- changed to 'unknown'",
|
||||
NULL);
|
||||
event_id = "unknown";
|
||||
}
|
||||
/* This one is probably temporary since it should not be a real error, actually (but often is) */
|
||||
if (expand_msg && strchr(msg, '%'))
|
||||
{
|
||||
do_unreal_log_norecursioncheck(ULOG_ERROR, "log", "BUG_LOG_MESSAGE_PERCENT", NULL,
|
||||
"[BUG] Next log message contains a percent sign -- possibly accidental format string!",
|
||||
NULL);
|
||||
"[BUG] Next log message contains a percent sign -- possibly accidental format string!",
|
||||
NULL);
|
||||
}
|
||||
|
||||
j = json_object();
|
||||
@@ -1924,7 +1909,7 @@ void do_unreal_log_internal(LogLevel loglevel, const char *subsystem, const char
|
||||
/* Additional details (if any) */
|
||||
while ((d = va_arg(vl, LogData *)))
|
||||
{
|
||||
switch(d->type)
|
||||
switch (d->type)
|
||||
{
|
||||
case LOG_FIELD_INTEGER:
|
||||
json_object_set_new(j_details, d->key, json_integer(d->value.integer));
|
||||
@@ -2029,8 +2014,7 @@ void do_unreal_log_internal(LogLevel loglevel, const char *subsystem, const char
|
||||
if (remote_rehash_client &&
|
||||
((!strcmp(event_id, "CONFIG_ERROR_GENERIC") ||
|
||||
!strcmp(event_id, "CONFIG_WARNING_GENERIC") ||
|
||||
!strcmp(event_id, "CONFIG_INFO_GENERIC"))
|
||||
||
|
||||
!strcmp(event_id, "CONFIG_INFO_GENERIC")) ||
|
||||
(loop.config_status >= CONFIG_STATUS_TEST)) &&
|
||||
strcmp(subsystem, "rawtraffic"))
|
||||
{
|
||||
@@ -2164,7 +2148,7 @@ void config_pre_run_log(void)
|
||||
void log_blocks_switchover(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < NUM_LOG_DESTINATIONS; i++)
|
||||
for (i = 0; i < NUM_LOG_DESTINATIONS; i++)
|
||||
free_log_block(logs[i]);
|
||||
memcpy(logs, temp_logs, sizeof(logs));
|
||||
memset(temp_logs, 0, sizeof(temp_logs));
|
||||
@@ -2242,8 +2226,7 @@ void memory_log_do_add_message(time_t t, LogLevel loglevel, const char *subsyste
|
||||
memory_log_tail->next = e;
|
||||
e->prev = memory_log_tail;
|
||||
memory_log_tail = e;
|
||||
} else
|
||||
if (memory_log != memory_log_tail)
|
||||
} else if (memory_log != memory_log_tail)
|
||||
{
|
||||
/* Impossible: memory_log NULL but memory_log_tail is not NULL, or vice versa */
|
||||
abort();
|
||||
|
||||
+78
-64
@@ -33,7 +33,7 @@ ID_Copyright("(C) 1990 Jarkko Oikarinen");
|
||||
|
||||
u_char touppertab[], tolowertab[];
|
||||
#define tolowertab2 tolowertab
|
||||
#define lc(x) tolowertab2[x]
|
||||
#define lc(x) tolowertab2[x]
|
||||
|
||||
pcre2_match_context *unreal_pcre2_match_ctx = NULL;
|
||||
|
||||
@@ -57,35 +57,35 @@ int match_esc(const char *mask, const char *name)
|
||||
const u_char *ma = NULL;
|
||||
const u_char *na = name;
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
if (*m == '*')
|
||||
{
|
||||
while (*m == '*') /* collapse.. */
|
||||
m++;
|
||||
ma = m;
|
||||
ma = m;
|
||||
na = n;
|
||||
}
|
||||
|
||||
|
||||
if (!*m)
|
||||
{
|
||||
if (!*n)
|
||||
return 1;
|
||||
if (!ma)
|
||||
return 0;
|
||||
for (m--; (m > (const u_char *)mask) && (*m == '?'); m--);
|
||||
for (m--; (m > (const u_char *)mask) && (*m == '?'); m--)
|
||||
;
|
||||
if (*m == '*')
|
||||
return 1;
|
||||
m = ma;
|
||||
n = ++na;
|
||||
} else
|
||||
if (!*n)
|
||||
} else if (!*n)
|
||||
{
|
||||
while (*m == '*') /* collapse.. */
|
||||
m++;
|
||||
return (*m == 0);
|
||||
}
|
||||
|
||||
|
||||
if (*m != '?')
|
||||
{
|
||||
if (*m == '\\')
|
||||
@@ -119,35 +119,35 @@ int match_simple(const char *mask, const char *name)
|
||||
const u_char *ma = NULL;
|
||||
const u_char *na = name;
|
||||
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
if (*m == '*')
|
||||
{
|
||||
while (*m == '*') /* collapse.. */
|
||||
m++;
|
||||
ma = m;
|
||||
ma = m;
|
||||
na = n;
|
||||
}
|
||||
|
||||
|
||||
if (!*m)
|
||||
{
|
||||
if (!*n)
|
||||
return 1;
|
||||
if (!ma)
|
||||
return 0;
|
||||
for (m--; (m > (const u_char *)mask) && (*m == '?'); m--);
|
||||
for (m--; (m > (const u_char *)mask) && (*m == '?'); m--)
|
||||
;
|
||||
if (*m == '*')
|
||||
return 1;
|
||||
m = ma;
|
||||
n = ++na;
|
||||
} else
|
||||
if (!*n)
|
||||
} else if (!*n)
|
||||
{
|
||||
while (*m == '*') /* collapse.. */
|
||||
m++;
|
||||
return (*m == 0);
|
||||
}
|
||||
|
||||
|
||||
if ((lc(*m) != lc(*n)) && !((*m == '_') && (*n == ' ')) && (*m != '?'))
|
||||
{
|
||||
if (!ma)
|
||||
@@ -188,8 +188,7 @@ char *collapse(char *pattern)
|
||||
break;
|
||||
else
|
||||
s++;
|
||||
}
|
||||
else if (*s == '*')
|
||||
} else if (*s == '*')
|
||||
{
|
||||
if (*(t = s1 = s + 1) == '*')
|
||||
while (*t == '*')
|
||||
@@ -214,11 +213,11 @@ char *collapse(char *pattern)
|
||||
* <0, if s1 lexicographically less than s2
|
||||
* >0, if s1 lexicographically greater than s2
|
||||
*/
|
||||
int smycmp(const char *s1, const char *s2)
|
||||
int smycmp(const char *s1, const char *s2)
|
||||
{
|
||||
u_char *str1;
|
||||
u_char *str2;
|
||||
int res;
|
||||
int res;
|
||||
|
||||
str1 = (u_char *)s1;
|
||||
str2 = (u_char *)s2;
|
||||
@@ -412,23 +411,22 @@ Match *unreal_create_match(MatchType type, const char *str, const char **error)
|
||||
|
||||
safe_strdup(m->str, str);
|
||||
m->type = type;
|
||||
|
||||
|
||||
if (m->type == MATCH_SIMPLE)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
else if (m->type == MATCH_PCRE_REGEX)
|
||||
} else if (m->type == MATCH_PCRE_REGEX)
|
||||
{
|
||||
int errorcode = 0;
|
||||
PCRE2_SIZE erroroffset = 0;
|
||||
int options = 0;
|
||||
char buf2[512];
|
||||
|
||||
|
||||
if ((loop.config_status < CONFIG_STATUS_LOAD) ? tempiConf.spamfilter_utf8 : iConf.spamfilter_utf8)
|
||||
options = PCRE2_CASELESS|PCRE2_MATCH_INVALID_UTF;
|
||||
options = PCRE2_CASELESS | PCRE2_MATCH_INVALID_UTF;
|
||||
else
|
||||
options = PCRE2_CASELESS|PCRE2_NEVER_UTF|PCRE2_NEVER_UCP;
|
||||
|
||||
options = PCRE2_CASELESS | PCRE2_NEVER_UTF | PCRE2_NEVER_UCP;
|
||||
|
||||
m->ext.pcre2_expr = pcre2_compile(str, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||
if (m->ext.pcre2_expr == NULL)
|
||||
{
|
||||
@@ -450,8 +448,8 @@ Match *unreal_create_match(MatchType type, const char *str, const char **error)
|
||||
} else if (m->type == MATCH_NONE)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
else {
|
||||
} else
|
||||
{
|
||||
/* Unknown type, how did that happen ? */
|
||||
unreal_delete_match(m);
|
||||
return NULL;
|
||||
@@ -548,7 +546,7 @@ int fast_badword_match(ConfigItem_badword *badword, const char *line)
|
||||
return (our_strcasestr(line, badword->word) ? 1 : 0);
|
||||
|
||||
p = line;
|
||||
while((p = our_strcasestr(p, badword->word)))
|
||||
while ((p = our_strcasestr(p, badword->word)))
|
||||
{
|
||||
if (!(badword->type & BADW_TYPE_FAST_L))
|
||||
{
|
||||
@@ -562,7 +560,7 @@ int fast_badword_match(ConfigItem_badword *badword, const char *line)
|
||||
}
|
||||
/* Looks like it matched */
|
||||
return 1;
|
||||
next:
|
||||
next:
|
||||
p += bwlen;
|
||||
}
|
||||
return 0;
|
||||
@@ -588,7 +586,8 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
int run = 1;
|
||||
int cleaned = 0;
|
||||
|
||||
while(run) {
|
||||
while (run)
|
||||
{
|
||||
pold = our_strcasestr(pold, badword->word);
|
||||
if (!pold)
|
||||
break;
|
||||
@@ -597,15 +596,19 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
if (searchn == -1)
|
||||
searchn = strlen(badword->word);
|
||||
/* Hunt for start of word */
|
||||
if (pold > line) {
|
||||
for (startw = pold; (!iswseperator(*startw) && (startw != line)); startw--);
|
||||
if (pold > line)
|
||||
{
|
||||
for (startw = pold; (!iswseperator(*startw) && (startw != line)); startw--)
|
||||
;
|
||||
if (iswseperator(*startw))
|
||||
startw++; /* Don't point at the space/seperator but at the word! */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
startw = pold;
|
||||
}
|
||||
|
||||
if (!(badword->type & BADW_TYPE_FAST_L) && (pold != startw)) {
|
||||
if (!(badword->type & BADW_TYPE_FAST_L) && (pold != startw))
|
||||
{
|
||||
/* not matched */
|
||||
pold++;
|
||||
continue;
|
||||
@@ -615,9 +618,11 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
* Fix for bug #4909: word will be at least 'searchn' long so we can skip
|
||||
* 'searchn' bytes and avoid stopping half-way the badword.
|
||||
*/
|
||||
for (endw = pold+searchn; ((*endw != '\0') && (!iswseperator(*endw))); endw++);
|
||||
for (endw = pold + searchn; ((*endw != '\0') && (!iswseperator(*endw))); endw++)
|
||||
;
|
||||
|
||||
if (!(badword->type & BADW_TYPE_FAST_R) && (pold+searchn != endw)) {
|
||||
if (!(badword->type & BADW_TYPE_FAST_R) && (pold + searchn != endw))
|
||||
{
|
||||
/* not matched */
|
||||
pold++;
|
||||
continue;
|
||||
@@ -626,9 +631,11 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
cleaned = 1; /* still too soon? Syzop/20050227 */
|
||||
|
||||
/* Do we have any not-copied-yet data? */
|
||||
if (poldx != startw) {
|
||||
if (poldx != startw)
|
||||
{
|
||||
int tmp_n = startw - poldx;
|
||||
if (pnew + tmp_n >= c_eol) {
|
||||
if (pnew + tmp_n >= c_eol)
|
||||
{
|
||||
/* Partial copy and return... */
|
||||
memcpy(pnew, poldx, c_eol - pnew);
|
||||
*c_eol = '\0';
|
||||
@@ -640,8 +647,10 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
}
|
||||
/* Now update the word in buf (pnew is now something like startw-in-new-buffer */
|
||||
|
||||
if (replacen) {
|
||||
if ((pnew + replacen) >= c_eol) {
|
||||
if (replacen)
|
||||
{
|
||||
if ((pnew + replacen) >= c_eol)
|
||||
{
|
||||
/* Partial copy and return... */
|
||||
memcpy(pnew, replacew, c_eol - pnew);
|
||||
*c_eol = '\0';
|
||||
@@ -653,10 +662,12 @@ int fast_badword_replace(ConfigItem_badword *badword, const char *line, char *bu
|
||||
poldx = pold = endw;
|
||||
}
|
||||
/* Copy the last part */
|
||||
if (*poldx) {
|
||||
if (*poldx)
|
||||
{
|
||||
strncpy(pnew, poldx, c_eol - pnew);
|
||||
*(c_eol) = '\0';
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
*pnew = '\0';
|
||||
}
|
||||
return cleaned;
|
||||
@@ -699,8 +710,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
*blocked = 1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
int n;
|
||||
/* fast_badword_replace() does size checking so we can use 512 here instead of 4096 */
|
||||
@@ -710,8 +720,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
strcpy(cleanstr, buf);
|
||||
memset(buf, 0, sizeof(buf)); /* regexp likes this somehow */
|
||||
}
|
||||
} else
|
||||
if (this_word->type & BADW_TYPE_REGEX)
|
||||
} else if (this_word->type & BADW_TYPE_REGEX)
|
||||
{
|
||||
if (this_word->action == BADWORD_BLOCK)
|
||||
{
|
||||
@@ -725,8 +734,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
*blocked = 1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
pcre2_match_data *md;
|
||||
int ret;
|
||||
@@ -734,7 +742,8 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
int start, end;
|
||||
|
||||
ptr = cleanstr; /* set pointer to start of string */
|
||||
while(1) {
|
||||
while (1)
|
||||
{
|
||||
md = pcre2_match_data_create(9, NULL);
|
||||
/* ^^ we need to free 'md' in ALL circumstances.
|
||||
* remember this if you break or continue in this loop!
|
||||
@@ -745,7 +754,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
dd = pcre2_get_ovector_pointer(md);
|
||||
start = (int)dd[0];
|
||||
end = (int)dd[1];
|
||||
if ((start < 0) || (end < 0) || (start > strlen(ptr)) || (end > strlen(ptr)+1))
|
||||
if ((start < 0) || (end < 0) || (start > strlen(ptr)) || (end > strlen(ptr) + 1))
|
||||
{
|
||||
unreal_log(ULOG_FATAL, "main", "BUG_STRIPBADWORDS_PCRE2_MATCH_OOB", NULL,
|
||||
"[BUG] pcre2_match() returned an ovector with OOB start/end: $start/$end, len $length: '$buf'",
|
||||
@@ -765,7 +774,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
matchlen += m;
|
||||
strlncat(buf, ptr, sizeof buf, start);
|
||||
if (this_word->replace)
|
||||
strlcat(buf, this_word->replace, sizeof buf);
|
||||
strlcat(buf, this_word->replace, sizeof buf);
|
||||
else
|
||||
strlcat(buf, REPLACEWORD, sizeof buf);
|
||||
ptr += end; /* Set pointer after the match pos */
|
||||
@@ -776,7 +785,7 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
break; /* NOMATCH: we are done! */
|
||||
}
|
||||
/* All the better to eat you with! */
|
||||
strlcat(buf, ptr, sizeof buf);
|
||||
strlcat(buf, ptr, sizeof buf);
|
||||
memcpy(cleanstr, buf, sizeof cleanstr);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (matchlen == stringlen)
|
||||
@@ -798,14 +807,16 @@ const char *stripbadwords(const char *str, ConfigItem_badword *start_bw, int *bl
|
||||
*/
|
||||
const char *badword_config_check_regex(const char *str, int fastsupport, int check_broadness)
|
||||
{
|
||||
int regex=0;
|
||||
int regex = 0;
|
||||
const char *tmp;
|
||||
static char errorbuf[512];
|
||||
|
||||
if (fastsupport)
|
||||
{
|
||||
for (tmp = str; *tmp; tmp++) {
|
||||
if (!isalnum(*tmp) && !(*tmp >= 128)) {
|
||||
for (tmp = str; *tmp; tmp++)
|
||||
{
|
||||
if (!isalnum(*tmp) && !(*tmp >= 128))
|
||||
{
|
||||
if ((str == tmp) && (*tmp == '*'))
|
||||
continue;
|
||||
if ((*(tmp + 1) == '\0') && (*tmp == '*'))
|
||||
@@ -823,7 +834,7 @@ const char *badword_config_check_regex(const char *str, int fastsupport, int che
|
||||
int options = 0;
|
||||
char buf2[512];
|
||||
|
||||
options = PCRE2_CASELESS|PCRE2_NEVER_UTF|PCRE2_NEVER_UCP;
|
||||
options = PCRE2_CASELESS | PCRE2_NEVER_UTF | PCRE2_NEVER_UCP;
|
||||
|
||||
expr = pcre2_compile(str, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||
if (expr == NULL)
|
||||
@@ -849,13 +860,17 @@ int badword_config_process(ConfigItem_badword *ca, const char *str)
|
||||
/* The fast badwords routine can do: "blah" "*blah" "blah*" and "*blah*",
|
||||
* in all other cases use regex.
|
||||
*/
|
||||
for (tmp = str; *tmp; tmp++) {
|
||||
if (!isalnum(*tmp) && !(*tmp >= 128)) {
|
||||
if ((str == tmp) && (*tmp == '*')) {
|
||||
for (tmp = str; *tmp; tmp++)
|
||||
{
|
||||
if (!isalnum(*tmp) && !(*tmp >= 128))
|
||||
{
|
||||
if ((str == tmp) && (*tmp == '*'))
|
||||
{
|
||||
ast_l = 1; /* Asterisk at the left */
|
||||
continue;
|
||||
}
|
||||
if ((*(tmp + 1) == '\0') && (*tmp == '*')) {
|
||||
if ((*(tmp + 1) == '\0') && (*tmp == '*'))
|
||||
{
|
||||
ast_r = 1; /* Asterisk at the right */
|
||||
continue;
|
||||
}
|
||||
@@ -872,7 +887,7 @@ int badword_config_process(ConfigItem_badword *ca, const char *str)
|
||||
ca->type = BADW_TYPE_REGEX;
|
||||
safe_strdup(ca->word, str);
|
||||
|
||||
options = PCRE2_CASELESS|PCRE2_NEVER_UTF|PCRE2_NEVER_UCP;
|
||||
options = PCRE2_CASELESS | PCRE2_NEVER_UTF | PCRE2_NEVER_UCP;
|
||||
|
||||
ca->pcre2_expr = pcre2_compile(str, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||
if (ca->pcre2_expr == NULL)
|
||||
@@ -884,8 +899,7 @@ int badword_config_process(ConfigItem_badword *ca, const char *str)
|
||||
abort();
|
||||
}
|
||||
pcre2_jit_compile(ca->pcre2_expr, PCRE2_JIT_COMPLETE);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
char *tmpw;
|
||||
ca->type = BADW_TYPE_FAST;
|
||||
|
||||
+352
-338
@@ -56,23 +56,23 @@ void mp_pool_init(void)
|
||||
|
||||
mp_pool_t *mp_pool_new(size_t sz, size_t ignored)
|
||||
{
|
||||
mp_pool_t *m = safe_alloc(sizeof(mp_pool_t));
|
||||
mp_pool_t *m = safe_alloc(sizeof(mp_pool_t));
|
||||
/* We (mis)use the item_alloc_size. It has a slightly different
|
||||
* meaning in the real mempool code where it's aligned, rounded, etc.
|
||||
* That is something we don't want as it would hide small overflows.
|
||||
*/
|
||||
m->item_alloc_size = sz;
|
||||
return m;
|
||||
m->item_alloc_size = sz;
|
||||
return m;
|
||||
}
|
||||
|
||||
void *mp_pool_get(mp_pool_t *pool)
|
||||
{
|
||||
return malloc(pool->item_alloc_size);
|
||||
return malloc(pool->item_alloc_size);
|
||||
}
|
||||
|
||||
void mp_pool_release(void *item)
|
||||
{
|
||||
safe_free(item);
|
||||
safe_free(item);
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -80,40 +80,40 @@ void mp_pool_release(void *item)
|
||||
static int
|
||||
tor_log2(uint64_t u64)
|
||||
{
|
||||
int r = 0;
|
||||
int r = 0;
|
||||
|
||||
if (u64 >= (1ULL << 32))
|
||||
{
|
||||
u64 >>= 32;
|
||||
r = 32;
|
||||
}
|
||||
if (u64 >= (1ULL << 16))
|
||||
{
|
||||
u64 >>= 16;
|
||||
r += 16;
|
||||
}
|
||||
if (u64 >= (1ULL << 8))
|
||||
{
|
||||
u64 >>= 8;
|
||||
r += 8;
|
||||
}
|
||||
if (u64 >= (1ULL << 4))
|
||||
{
|
||||
u64 >>= 4;
|
||||
r += 4;
|
||||
}
|
||||
if (u64 >= (1ULL << 2))
|
||||
{
|
||||
u64 >>= 2;
|
||||
r += 2;
|
||||
}
|
||||
if (u64 >= (1ULL << 1))
|
||||
{
|
||||
u64 >>= 1;
|
||||
r += 1;
|
||||
}
|
||||
if (u64 >= (1ULL << 32))
|
||||
{
|
||||
u64 >>= 32;
|
||||
r = 32;
|
||||
}
|
||||
if (u64 >= (1ULL << 16))
|
||||
{
|
||||
u64 >>= 16;
|
||||
r += 16;
|
||||
}
|
||||
if (u64 >= (1ULL << 8))
|
||||
{
|
||||
u64 >>= 8;
|
||||
r += 8;
|
||||
}
|
||||
if (u64 >= (1ULL << 4))
|
||||
{
|
||||
u64 >>= 4;
|
||||
r += 4;
|
||||
}
|
||||
if (u64 >= (1ULL << 2))
|
||||
{
|
||||
u64 >>= 2;
|
||||
r += 2;
|
||||
}
|
||||
if (u64 >= (1ULL << 1))
|
||||
{
|
||||
u64 >>= 1;
|
||||
r += 1;
|
||||
}
|
||||
|
||||
return r;
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Return the power of 2 in range [1,UINT64_MAX] closest to <b>u64</b>. If
|
||||
@@ -121,24 +121,24 @@ tor_log2(uint64_t u64)
|
||||
static uint64_t
|
||||
round_to_power_of_2(uint64_t u64)
|
||||
{
|
||||
int lg2;
|
||||
uint64_t low;
|
||||
uint64_t high;
|
||||
int lg2;
|
||||
uint64_t low;
|
||||
uint64_t high;
|
||||
|
||||
if (u64 == 0)
|
||||
return 1;
|
||||
if (u64 == 0)
|
||||
return 1;
|
||||
|
||||
lg2 = tor_log2(u64);
|
||||
low = 1ULL << lg2;
|
||||
lg2 = tor_log2(u64);
|
||||
low = 1ULL << lg2;
|
||||
|
||||
if (lg2 == 63)
|
||||
return low;
|
||||
if (lg2 == 63)
|
||||
return low;
|
||||
|
||||
high = 1ULL << (lg2 + 1);
|
||||
if (high - u64 < u64 - low)
|
||||
return high;
|
||||
else
|
||||
return low;
|
||||
high = 1ULL << (lg2 + 1);
|
||||
if (high - u64 < u64 - low)
|
||||
return high;
|
||||
else
|
||||
return low;
|
||||
}
|
||||
|
||||
/* OVERVIEW:
|
||||
@@ -193,13 +193,13 @@ round_to_power_of_2(uint64_t u64)
|
||||
/* Tuning parameters */
|
||||
/** Largest type that we need to ensure returned memory items are aligned to.
|
||||
* Change this to "double" if we need to be safe for structs with doubles. */
|
||||
#define ALIGNMENT_TYPE void *
|
||||
#define ALIGNMENT_TYPE void *
|
||||
/** Increment that we need to align allocated. */
|
||||
#define ALIGNMENT sizeof(ALIGNMENT_TYPE)
|
||||
#define ALIGNMENT sizeof(ALIGNMENT_TYPE)
|
||||
/** Largest memory chunk that we should allocate. */
|
||||
#define MAX_CHUNK (8 *(1L << 20))
|
||||
#define MAX_CHUNK (8 * (1L << 20))
|
||||
/** Smallest memory chunk size that we should allocate. */
|
||||
#define MIN_CHUNK 4096
|
||||
#define MIN_CHUNK 4096
|
||||
|
||||
typedef struct mp_allocated_t mp_allocated_t;
|
||||
typedef struct mp_chunk_t mp_chunk_t;
|
||||
@@ -209,59 +209,58 @@ struct mp_allocated_t {
|
||||
/** The chunk that this item is allocated in. This adds overhead to each
|
||||
* allocated item, thus making this implementation inappropriate for
|
||||
* very small items. */
|
||||
mp_chunk_t *in_chunk;
|
||||
mp_chunk_t *in_chunk;
|
||||
|
||||
union {
|
||||
union {
|
||||
/** If this item is free, the next item on the free list. */
|
||||
mp_allocated_t *next_free;
|
||||
mp_allocated_t *next_free;
|
||||
|
||||
/** If this item is not free, the actual memory contents of this item.
|
||||
* (Not actual size.) */
|
||||
char mem[1];
|
||||
char mem[1];
|
||||
|
||||
/** An extra element to the union to insure correct alignment. */
|
||||
ALIGNMENT_TYPE dummy_;
|
||||
} u;
|
||||
ALIGNMENT_TYPE dummy_;
|
||||
} u;
|
||||
};
|
||||
|
||||
/** 'Magic' value used to detect memory corruption. */
|
||||
#define MP_CHUNK_MAGIC 0x09870123
|
||||
#define MP_CHUNK_MAGIC 0x09870123
|
||||
|
||||
/** A chunk of memory. Chunks come from malloc; we use them */
|
||||
struct mp_chunk_t {
|
||||
uint32_t magic; /**< Must be MP_CHUNK_MAGIC if this chunk is valid. */
|
||||
mp_chunk_t *next; /**< The next free, used, or full chunk in sequence. */
|
||||
mp_chunk_t *prev; /**< The previous free, used, or full chunk in sequence. */
|
||||
mp_pool_t *pool; /**< The pool that this chunk is part of. */
|
||||
uint32_t magic; /**< Must be MP_CHUNK_MAGIC if this chunk is valid. */
|
||||
mp_chunk_t *next; /**< The next free, used, or full chunk in sequence. */
|
||||
mp_chunk_t *prev; /**< The previous free, used, or full chunk in sequence. */
|
||||
mp_pool_t *pool; /**< The pool that this chunk is part of. */
|
||||
|
||||
/** First free item in the freelist for this chunk. Note that this may be
|
||||
* NULL even if this chunk is not at capacity: if so, the free memory at
|
||||
* next_mem has not yet been carved into items.
|
||||
*/
|
||||
mp_allocated_t *first_free;
|
||||
int n_allocated; /**< Number of currently allocated items in this chunk. */
|
||||
int capacity; /**< Number of items that can be fit into this chunk. */
|
||||
size_t mem_size; /**< Number of usable bytes in mem. */
|
||||
char *next_mem; /**< Pointer into part of <b>mem</b> not yet carved up. */
|
||||
char mem[]; /**< Storage for this chunk. */
|
||||
mp_allocated_t *first_free;
|
||||
int n_allocated; /**< Number of currently allocated items in this chunk. */
|
||||
int capacity; /**< Number of items that can be fit into this chunk. */
|
||||
size_t mem_size; /**< Number of usable bytes in mem. */
|
||||
char *next_mem; /**< Pointer into part of <b>mem</b> not yet carved up. */
|
||||
char mem[]; /**< Storage for this chunk. */
|
||||
};
|
||||
|
||||
static mp_pool_t *mp_allocated_pools = NULL;
|
||||
|
||||
/** Number of extra bytes needed beyond mem_size to allocate a chunk. */
|
||||
#define CHUNK_OVERHEAD offsetof(mp_chunk_t, mem[0])
|
||||
#define CHUNK_OVERHEAD offsetof(mp_chunk_t, mem[0])
|
||||
|
||||
/** Given a pointer to a mp_allocated_t, return a pointer to the memory
|
||||
* item it holds. */
|
||||
#define A2M(a) (&(a)->u.mem)
|
||||
#define A2M(a) (&(a)->u.mem)
|
||||
/** Given a pointer to a memory_item_t, return a pointer to its enclosing
|
||||
* mp_allocated_t. */
|
||||
#define M2A(p) (((char *)p) - offsetof(mp_allocated_t, u.mem))
|
||||
#define M2A(p) (((char *)p) - offsetof(mp_allocated_t, u.mem))
|
||||
|
||||
void
|
||||
mp_pool_init(void)
|
||||
void mp_pool_init(void)
|
||||
{
|
||||
EventAdd(NULL, "mp_pool_garbage_collect", &mp_pool_garbage_collect, NULL, 119*1000, 0);
|
||||
EventAdd(NULL, "mp_pool_garbage_collect", &mp_pool_garbage_collect, NULL, 119 * 1000, 0);
|
||||
}
|
||||
|
||||
/** Helper: Allocate and return a new memory chunk for <b>pool</b>. Does not
|
||||
@@ -269,18 +268,18 @@ mp_pool_init(void)
|
||||
static mp_chunk_t *
|
||||
mp_chunk_new(mp_pool_t *pool)
|
||||
{
|
||||
size_t sz = pool->new_chunk_capacity * pool->item_alloc_size;
|
||||
mp_chunk_t *chunk = safe_alloc(CHUNK_OVERHEAD + sz);
|
||||
size_t sz = pool->new_chunk_capacity * pool->item_alloc_size;
|
||||
mp_chunk_t *chunk = safe_alloc(CHUNK_OVERHEAD + sz);
|
||||
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_chunks_allocated;
|
||||
#endif
|
||||
chunk->magic = MP_CHUNK_MAGIC;
|
||||
chunk->capacity = pool->new_chunk_capacity;
|
||||
chunk->mem_size = sz;
|
||||
chunk->next_mem = chunk->mem;
|
||||
chunk->pool = pool;
|
||||
return chunk;
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_chunks_allocated;
|
||||
#endif
|
||||
chunk->magic = MP_CHUNK_MAGIC;
|
||||
chunk->capacity = pool->new_chunk_capacity;
|
||||
chunk->mem_size = sz;
|
||||
chunk->next_mem = chunk->mem;
|
||||
chunk->pool = pool;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
/** Take a <b>chunk</b> that has just been allocated or removed from
|
||||
@@ -289,161 +288,168 @@ mp_chunk_new(mp_pool_t *pool)
|
||||
static void
|
||||
add_newly_used_chunk_to_used_list(mp_pool_t *pool, mp_chunk_t *chunk)
|
||||
{
|
||||
chunk->next = pool->used_chunks;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->used_chunks = chunk;
|
||||
assert(!chunk->prev);
|
||||
chunk->next = pool->used_chunks;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->used_chunks = chunk;
|
||||
assert(!chunk->prev);
|
||||
}
|
||||
|
||||
/** Return a newly allocated item from <b>pool</b>. */
|
||||
void *
|
||||
mp_pool_get(mp_pool_t *pool)
|
||||
{
|
||||
mp_chunk_t *chunk;
|
||||
mp_allocated_t *allocated;
|
||||
mp_chunk_t *chunk;
|
||||
mp_allocated_t *allocated;
|
||||
|
||||
if (pool->used_chunks != NULL) {
|
||||
if (pool->used_chunks != NULL)
|
||||
{
|
||||
/*
|
||||
* Common case: there is some chunk that is neither full nor empty. Use
|
||||
* that one. (We can't use the full ones, obviously, and we should fill
|
||||
* up the used ones before we start on any empty ones.
|
||||
*/
|
||||
chunk = pool->used_chunks;
|
||||
chunk = pool->used_chunks;
|
||||
|
||||
} else if (pool->empty_chunks) {
|
||||
} else if (pool->empty_chunks)
|
||||
{
|
||||
/*
|
||||
* We have no used chunks, but we have an empty chunk that we haven't
|
||||
* freed yet: use that. (We pull from the front of the list, which should
|
||||
* get us the most recently emptied chunk.)
|
||||
*/
|
||||
chunk = pool->empty_chunks;
|
||||
chunk = pool->empty_chunks;
|
||||
|
||||
/* Remove the chunk from the empty list. */
|
||||
pool->empty_chunks = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = NULL;
|
||||
pool->empty_chunks = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = NULL;
|
||||
|
||||
/* Put the chunk on the 'used' list*/
|
||||
add_newly_used_chunk_to_used_list(pool, chunk);
|
||||
add_newly_used_chunk_to_used_list(pool, chunk);
|
||||
|
||||
assert(!chunk->prev);
|
||||
--pool->n_empty_chunks;
|
||||
if (pool->n_empty_chunks < pool->min_empty_chunks)
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
} else {
|
||||
assert(!chunk->prev);
|
||||
--pool->n_empty_chunks;
|
||||
if (pool->n_empty_chunks < pool->min_empty_chunks)
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
} else
|
||||
{
|
||||
/* We have no used or empty chunks: allocate a new chunk. */
|
||||
chunk = mp_chunk_new(pool);
|
||||
chunk = mp_chunk_new(pool);
|
||||
|
||||
/* Add the new chunk to the used list. */
|
||||
add_newly_used_chunk_to_used_list(pool, chunk);
|
||||
}
|
||||
add_newly_used_chunk_to_used_list(pool, chunk);
|
||||
}
|
||||
|
||||
assert(chunk->n_allocated < chunk->capacity);
|
||||
assert(chunk->n_allocated < chunk->capacity);
|
||||
|
||||
if (chunk->first_free) {
|
||||
if (chunk->first_free)
|
||||
{
|
||||
/* If there's anything on the chunk's freelist, unlink it and use it. */
|
||||
allocated = chunk->first_free;
|
||||
chunk->first_free = allocated->u.next_free;
|
||||
allocated->u.next_free = NULL; /* For debugging; not really needed. */
|
||||
assert(allocated->in_chunk == chunk);
|
||||
} else {
|
||||
allocated = chunk->first_free;
|
||||
chunk->first_free = allocated->u.next_free;
|
||||
allocated->u.next_free = NULL; /* For debugging; not really needed. */
|
||||
assert(allocated->in_chunk == chunk);
|
||||
} else
|
||||
{
|
||||
/* Otherwise, the chunk had better have some free space left on it. */
|
||||
assert(chunk->next_mem + pool->item_alloc_size <=
|
||||
chunk->mem + chunk->mem_size);
|
||||
assert(chunk->next_mem + pool->item_alloc_size <=
|
||||
chunk->mem + chunk->mem_size);
|
||||
|
||||
/* Good, it did. Let's carve off a bit of that free space, and use
|
||||
* that. */
|
||||
allocated = (void *)chunk->next_mem;
|
||||
chunk->next_mem += pool->item_alloc_size;
|
||||
allocated->in_chunk = chunk;
|
||||
allocated->u.next_free = NULL; /* For debugging; not really needed. */
|
||||
}
|
||||
allocated = (void *)chunk->next_mem;
|
||||
chunk->next_mem += pool->item_alloc_size;
|
||||
allocated->in_chunk = chunk;
|
||||
allocated->u.next_free = NULL; /* For debugging; not really needed. */
|
||||
}
|
||||
|
||||
++chunk->n_allocated;
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_items_allocated;
|
||||
#endif
|
||||
++chunk->n_allocated;
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_items_allocated;
|
||||
#endif
|
||||
|
||||
if (chunk->n_allocated == chunk->capacity) {
|
||||
if (chunk->n_allocated == chunk->capacity)
|
||||
{
|
||||
/* This chunk just became full. */
|
||||
assert(chunk == pool->used_chunks);
|
||||
assert(chunk->prev == NULL);
|
||||
assert(chunk == pool->used_chunks);
|
||||
assert(chunk->prev == NULL);
|
||||
|
||||
/* Take it off the used list. */
|
||||
pool->used_chunks = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = NULL;
|
||||
pool->used_chunks = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = NULL;
|
||||
|
||||
/* Put it on the full list. */
|
||||
chunk->next = pool->full_chunks;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->full_chunks = chunk;
|
||||
}
|
||||
chunk->next = pool->full_chunks;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->full_chunks = chunk;
|
||||
}
|
||||
/* And return the memory portion of the mp_allocated_t. */
|
||||
return A2M(allocated);
|
||||
return A2M(allocated);
|
||||
}
|
||||
|
||||
/** Return an allocated memory item to its memory pool. */
|
||||
void
|
||||
mp_pool_release(void *item)
|
||||
void mp_pool_release(void *item)
|
||||
{
|
||||
mp_allocated_t *allocated = (void *)M2A(item);
|
||||
mp_chunk_t *chunk = allocated->in_chunk;
|
||||
mp_allocated_t *allocated = (void *)M2A(item);
|
||||
mp_chunk_t *chunk = allocated->in_chunk;
|
||||
|
||||
assert(chunk);
|
||||
assert(chunk->magic == MP_CHUNK_MAGIC);
|
||||
assert(chunk->n_allocated > 0);
|
||||
assert(chunk);
|
||||
assert(chunk->magic == MP_CHUNK_MAGIC);
|
||||
assert(chunk->n_allocated > 0);
|
||||
|
||||
allocated->u.next_free = chunk->first_free;
|
||||
chunk->first_free = allocated;
|
||||
allocated->u.next_free = chunk->first_free;
|
||||
chunk->first_free = allocated;
|
||||
|
||||
if (chunk->n_allocated == chunk->capacity) {
|
||||
if (chunk->n_allocated == chunk->capacity)
|
||||
{
|
||||
/* This chunk was full and is about to be used. */
|
||||
mp_pool_t *pool = chunk->pool;
|
||||
mp_pool_t *pool = chunk->pool;
|
||||
/* unlink from the full list */
|
||||
if (chunk->prev)
|
||||
chunk->prev->next = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk->prev;
|
||||
if (chunk == pool->full_chunks)
|
||||
pool->full_chunks = chunk->next;
|
||||
if (chunk->prev)
|
||||
chunk->prev->next = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk->prev;
|
||||
if (chunk == pool->full_chunks)
|
||||
pool->full_chunks = chunk->next;
|
||||
|
||||
/* link to the used list. */
|
||||
chunk->next = pool->used_chunks;
|
||||
chunk->prev = NULL;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->used_chunks = chunk;
|
||||
} else if (chunk->n_allocated == 1) {
|
||||
chunk->next = pool->used_chunks;
|
||||
chunk->prev = NULL;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->used_chunks = chunk;
|
||||
} else if (chunk->n_allocated == 1)
|
||||
{
|
||||
/* This was used and is about to be empty. */
|
||||
mp_pool_t *pool = chunk->pool;
|
||||
mp_pool_t *pool = chunk->pool;
|
||||
|
||||
/* Unlink from the used list */
|
||||
if (chunk->prev)
|
||||
chunk->prev->next = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk->prev;
|
||||
if (chunk == pool->used_chunks)
|
||||
pool->used_chunks = chunk->next;
|
||||
if (chunk->prev)
|
||||
chunk->prev->next = chunk->next;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk->prev;
|
||||
if (chunk == pool->used_chunks)
|
||||
pool->used_chunks = chunk->next;
|
||||
|
||||
/* Link to the empty list */
|
||||
chunk->next = pool->empty_chunks;
|
||||
chunk->prev = NULL;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->empty_chunks = chunk;
|
||||
chunk->next = pool->empty_chunks;
|
||||
chunk->prev = NULL;
|
||||
if (chunk->next)
|
||||
chunk->next->prev = chunk;
|
||||
pool->empty_chunks = chunk;
|
||||
|
||||
/* Reset the guts of this chunk to defragment it, in case it gets
|
||||
* used again. */
|
||||
chunk->first_free = NULL;
|
||||
chunk->next_mem = chunk->mem;
|
||||
chunk->first_free = NULL;
|
||||
chunk->next_mem = chunk->mem;
|
||||
|
||||
++pool->n_empty_chunks;
|
||||
}
|
||||
++pool->n_empty_chunks;
|
||||
}
|
||||
|
||||
--chunk->n_allocated;
|
||||
--chunk->n_allocated;
|
||||
}
|
||||
|
||||
/** Allocate a new memory pool to hold items of size <b>item_size</b>. We'll
|
||||
@@ -451,62 +457,63 @@ mp_pool_release(void *item)
|
||||
mp_pool_t *
|
||||
mp_pool_new(size_t item_size, size_t chunk_capacity)
|
||||
{
|
||||
mp_pool_t *pool;
|
||||
size_t alloc_size, new_chunk_cap;
|
||||
mp_pool_t *pool;
|
||||
size_t alloc_size, new_chunk_cap;
|
||||
|
||||
/* assert(item_size < SIZE_T_CEILING);
|
||||
assert(chunk_capacity < SIZE_T_CEILING);
|
||||
assert(SIZE_T_CEILING / item_size > chunk_capacity);
|
||||
*/
|
||||
pool = safe_alloc(sizeof(mp_pool_t));
|
||||
pool = safe_alloc(sizeof(mp_pool_t));
|
||||
/*
|
||||
* First, we figure out how much space to allow per item. We'll want to
|
||||
* use make sure we have enough for the overhead plus the item size.
|
||||
*/
|
||||
alloc_size = (size_t)(offsetof(mp_allocated_t, u.mem) + item_size);
|
||||
alloc_size = (size_t)(offsetof(mp_allocated_t, u.mem) + item_size);
|
||||
/*
|
||||
* If the item_size is less than sizeof(next_free), we need to make
|
||||
* the allocation bigger.
|
||||
*/
|
||||
if (alloc_size < sizeof(mp_allocated_t))
|
||||
alloc_size = sizeof(mp_allocated_t);
|
||||
if (alloc_size < sizeof(mp_allocated_t))
|
||||
alloc_size = sizeof(mp_allocated_t);
|
||||
|
||||
/* If we're not an even multiple of ALIGNMENT, round up. */
|
||||
if (alloc_size % ALIGNMENT) {
|
||||
alloc_size = alloc_size + ALIGNMENT - (alloc_size % ALIGNMENT);
|
||||
}
|
||||
if (alloc_size < ALIGNMENT)
|
||||
alloc_size = ALIGNMENT;
|
||||
assert((alloc_size % ALIGNMENT) == 0);
|
||||
if (alloc_size % ALIGNMENT)
|
||||
{
|
||||
alloc_size = alloc_size + ALIGNMENT - (alloc_size % ALIGNMENT);
|
||||
}
|
||||
if (alloc_size < ALIGNMENT)
|
||||
alloc_size = ALIGNMENT;
|
||||
assert((alloc_size % ALIGNMENT) == 0);
|
||||
|
||||
/*
|
||||
* Now we figure out how many items fit in each chunk. We need to fit at
|
||||
* least 2 items per chunk. No chunk can be more than MAX_CHUNK bytes long,
|
||||
* or less than MIN_CHUNK.
|
||||
*/
|
||||
if (chunk_capacity > MAX_CHUNK)
|
||||
chunk_capacity = MAX_CHUNK;
|
||||
if (chunk_capacity > MAX_CHUNK)
|
||||
chunk_capacity = MAX_CHUNK;
|
||||
|
||||
/*
|
||||
* Try to be around a power of 2 in size, since that's what allocators like
|
||||
* handing out. 512K-1 byte is a lot better than 512K+1 byte.
|
||||
*/
|
||||
chunk_capacity = (size_t) round_to_power_of_2(chunk_capacity);
|
||||
while (chunk_capacity < alloc_size * 2 + CHUNK_OVERHEAD)
|
||||
chunk_capacity *= 2;
|
||||
if (chunk_capacity < MIN_CHUNK)
|
||||
chunk_capacity = MIN_CHUNK;
|
||||
chunk_capacity = (size_t)round_to_power_of_2(chunk_capacity);
|
||||
while (chunk_capacity < alloc_size * 2 + CHUNK_OVERHEAD)
|
||||
chunk_capacity *= 2;
|
||||
if (chunk_capacity < MIN_CHUNK)
|
||||
chunk_capacity = MIN_CHUNK;
|
||||
|
||||
new_chunk_cap = (chunk_capacity-CHUNK_OVERHEAD) / alloc_size;
|
||||
assert(new_chunk_cap < INT_MAX);
|
||||
pool->new_chunk_capacity = (int)new_chunk_cap;
|
||||
new_chunk_cap = (chunk_capacity - CHUNK_OVERHEAD) / alloc_size;
|
||||
assert(new_chunk_cap < INT_MAX);
|
||||
pool->new_chunk_capacity = (int)new_chunk_cap;
|
||||
|
||||
pool->item_alloc_size = alloc_size;
|
||||
pool->item_alloc_size = alloc_size;
|
||||
|
||||
pool->next = mp_allocated_pools;
|
||||
mp_allocated_pools = pool;
|
||||
pool->next = mp_allocated_pools;
|
||||
mp_allocated_pools = pool;
|
||||
|
||||
return pool;
|
||||
return pool;
|
||||
}
|
||||
|
||||
/** Helper function for qsort: used to sort pointers to mp_chunk_t into
|
||||
@@ -514,9 +521,9 @@ mp_pool_new(size_t item_size, size_t chunk_capacity)
|
||||
static int
|
||||
mp_pool_sort_used_chunks_helper(const void *_a, const void *_b)
|
||||
{
|
||||
mp_chunk_t *a = *(mp_chunk_t * const *)_a;
|
||||
mp_chunk_t *b = *(mp_chunk_t * const *)_b;
|
||||
return b->n_allocated - a->n_allocated;
|
||||
mp_chunk_t *a = *(mp_chunk_t *const *)_a;
|
||||
mp_chunk_t *b = *(mp_chunk_t *const *)_b;
|
||||
return b->n_allocated - a->n_allocated;
|
||||
}
|
||||
|
||||
/** Sort the used chunks in <b>pool</b> into descending order of fullness,
|
||||
@@ -525,35 +532,37 @@ mp_pool_sort_used_chunks_helper(const void *_a, const void *_b)
|
||||
static void
|
||||
mp_pool_sort_used_chunks(mp_pool_t *pool)
|
||||
{
|
||||
int i, n = 0, inverted = 0;
|
||||
mp_chunk_t **chunks, *chunk;
|
||||
int i, n = 0, inverted = 0;
|
||||
mp_chunk_t **chunks, *chunk;
|
||||
|
||||
for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
|
||||
++n;
|
||||
if (chunk->next && chunk->next->n_allocated > chunk->n_allocated)
|
||||
++inverted;
|
||||
}
|
||||
for (chunk = pool->used_chunks; chunk; chunk = chunk->next)
|
||||
{
|
||||
++n;
|
||||
if (chunk->next && chunk->next->n_allocated > chunk->n_allocated)
|
||||
++inverted;
|
||||
}
|
||||
|
||||
if (!inverted)
|
||||
return;
|
||||
if (!inverted)
|
||||
return;
|
||||
|
||||
chunks = safe_alloc(sizeof(mp_chunk_t *) * n);
|
||||
chunks = safe_alloc(sizeof(mp_chunk_t *) * n);
|
||||
|
||||
for (i=0,chunk = pool->used_chunks; chunk; chunk = chunk->next)
|
||||
chunks[i++] = chunk;
|
||||
for (i = 0, chunk = pool->used_chunks; chunk; chunk = chunk->next)
|
||||
chunks[i++] = chunk;
|
||||
|
||||
qsort(chunks, n, sizeof(mp_chunk_t *), mp_pool_sort_used_chunks_helper);
|
||||
pool->used_chunks = chunks[0];
|
||||
chunks[0]->prev = NULL;
|
||||
qsort(chunks, n, sizeof(mp_chunk_t *), mp_pool_sort_used_chunks_helper);
|
||||
pool->used_chunks = chunks[0];
|
||||
chunks[0]->prev = NULL;
|
||||
|
||||
for (i = 1; i < n; ++i) {
|
||||
chunks[i - 1]->next = chunks[i];
|
||||
chunks[i]->prev = chunks[i - 1];
|
||||
}
|
||||
for (i = 1; i < n; ++i)
|
||||
{
|
||||
chunks[i - 1]->next = chunks[i];
|
||||
chunks[i]->prev = chunks[i - 1];
|
||||
}
|
||||
|
||||
chunks[n - 1]->next = NULL;
|
||||
safe_free(chunks);
|
||||
mp_pool_assert_ok(pool);
|
||||
chunks[n - 1]->next = NULL;
|
||||
safe_free(chunks);
|
||||
mp_pool_assert_ok(pool);
|
||||
}
|
||||
|
||||
/** If there are more than <b>n</b> empty chunks in <b>pool</b>, free the
|
||||
@@ -561,158 +570,163 @@ mp_pool_sort_used_chunks(mp_pool_t *pool)
|
||||
* <b>keep_recently_used</b> is true, do not free chunks unless they have been
|
||||
* empty since the last call to this function.
|
||||
**/
|
||||
void
|
||||
mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used)
|
||||
void mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used)
|
||||
{
|
||||
mp_chunk_t *chunk, **first_to_free;
|
||||
mp_chunk_t *chunk, **first_to_free;
|
||||
|
||||
mp_pool_sort_used_chunks(pool);
|
||||
assert(n_to_keep >= 0);
|
||||
mp_pool_sort_used_chunks(pool);
|
||||
assert(n_to_keep >= 0);
|
||||
|
||||
if (keep_recently_used) {
|
||||
int n_recently_used = pool->n_empty_chunks - pool->min_empty_chunks;
|
||||
if (n_to_keep < n_recently_used)
|
||||
n_to_keep = n_recently_used;
|
||||
}
|
||||
if (keep_recently_used)
|
||||
{
|
||||
int n_recently_used = pool->n_empty_chunks - pool->min_empty_chunks;
|
||||
if (n_to_keep < n_recently_used)
|
||||
n_to_keep = n_recently_used;
|
||||
}
|
||||
|
||||
assert(n_to_keep >= 0);
|
||||
assert(n_to_keep >= 0);
|
||||
|
||||
first_to_free = &pool->empty_chunks;
|
||||
while (*first_to_free && n_to_keep > 0) {
|
||||
first_to_free = &(*first_to_free)->next;
|
||||
--n_to_keep;
|
||||
}
|
||||
if (!*first_to_free) {
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
return;
|
||||
}
|
||||
first_to_free = &pool->empty_chunks;
|
||||
while (*first_to_free && n_to_keep > 0)
|
||||
{
|
||||
first_to_free = &(*first_to_free)->next;
|
||||
--n_to_keep;
|
||||
}
|
||||
if (!*first_to_free)
|
||||
{
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
return;
|
||||
}
|
||||
|
||||
chunk = *first_to_free;
|
||||
while (chunk) {
|
||||
mp_chunk_t *next = chunk->next;
|
||||
chunk->magic = 0xdeadbeef;
|
||||
safe_free(chunk);
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_chunks_freed;
|
||||
#endif
|
||||
--pool->n_empty_chunks;
|
||||
chunk = next;
|
||||
}
|
||||
chunk = *first_to_free;
|
||||
while (chunk)
|
||||
{
|
||||
mp_chunk_t *next = chunk->next;
|
||||
chunk->magic = 0xdeadbeef;
|
||||
safe_free(chunk);
|
||||
#ifdef MEMPOOL_STATS
|
||||
++pool->total_chunks_freed;
|
||||
#endif
|
||||
--pool->n_empty_chunks;
|
||||
chunk = next;
|
||||
}
|
||||
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
*first_to_free = NULL;
|
||||
pool->min_empty_chunks = pool->n_empty_chunks;
|
||||
*first_to_free = NULL;
|
||||
}
|
||||
|
||||
/** Helper: Given a list of chunks, free all the chunks in the list. */
|
||||
static void destroy_chunks(mp_chunk_t *chunk)
|
||||
{
|
||||
mp_chunk_t *next;
|
||||
mp_chunk_t *next;
|
||||
|
||||
while (chunk) {
|
||||
chunk->magic = 0xd3adb33f;
|
||||
next = chunk->next;
|
||||
safe_free(chunk);
|
||||
chunk = next;
|
||||
}
|
||||
while (chunk)
|
||||
{
|
||||
chunk->magic = 0xd3adb33f;
|
||||
next = chunk->next;
|
||||
safe_free(chunk);
|
||||
chunk = next;
|
||||
}
|
||||
}
|
||||
|
||||
/** Helper: make sure that a given chunk list is not corrupt. */
|
||||
static int
|
||||
assert_chunks_ok(mp_pool_t *pool, mp_chunk_t *chunk, int empty, int full)
|
||||
{
|
||||
mp_allocated_t *allocated;
|
||||
int n = 0;
|
||||
mp_allocated_t *allocated;
|
||||
int n = 0;
|
||||
|
||||
if (chunk)
|
||||
assert(chunk->prev == NULL);
|
||||
if (chunk)
|
||||
assert(chunk->prev == NULL);
|
||||
|
||||
while (chunk) {
|
||||
n++;
|
||||
assert(chunk->magic == MP_CHUNK_MAGIC);
|
||||
assert(chunk->pool == pool);
|
||||
for (allocated = chunk->first_free; allocated;
|
||||
allocated = allocated->u.next_free) {
|
||||
assert(allocated->in_chunk == chunk);
|
||||
}
|
||||
if (empty)
|
||||
assert(chunk->n_allocated == 0);
|
||||
else if (full)
|
||||
assert(chunk->n_allocated == chunk->capacity);
|
||||
else
|
||||
assert(chunk->n_allocated > 0 && chunk->n_allocated < chunk->capacity);
|
||||
while (chunk)
|
||||
{
|
||||
n++;
|
||||
assert(chunk->magic == MP_CHUNK_MAGIC);
|
||||
assert(chunk->pool == pool);
|
||||
for (allocated = chunk->first_free; allocated;
|
||||
allocated = allocated->u.next_free)
|
||||
{
|
||||
assert(allocated->in_chunk == chunk);
|
||||
}
|
||||
if (empty)
|
||||
assert(chunk->n_allocated == 0);
|
||||
else if (full)
|
||||
assert(chunk->n_allocated == chunk->capacity);
|
||||
else
|
||||
assert(chunk->n_allocated > 0 && chunk->n_allocated < chunk->capacity);
|
||||
|
||||
assert(chunk->capacity == pool->new_chunk_capacity);
|
||||
assert(chunk->capacity == pool->new_chunk_capacity);
|
||||
|
||||
assert(chunk->mem_size ==
|
||||
pool->new_chunk_capacity * pool->item_alloc_size);
|
||||
assert(chunk->mem_size ==
|
||||
pool->new_chunk_capacity * pool->item_alloc_size);
|
||||
|
||||
assert(chunk->next_mem >= chunk->mem &&
|
||||
chunk->next_mem <= chunk->mem + chunk->mem_size);
|
||||
assert(chunk->next_mem >= chunk->mem &&
|
||||
chunk->next_mem <= chunk->mem + chunk->mem_size);
|
||||
|
||||
if (chunk->next)
|
||||
assert(chunk->next->prev == chunk);
|
||||
if (chunk->next)
|
||||
assert(chunk->next->prev == chunk);
|
||||
|
||||
chunk = chunk->next;
|
||||
}
|
||||
chunk = chunk->next;
|
||||
}
|
||||
|
||||
return n;
|
||||
return n;
|
||||
}
|
||||
|
||||
/** Fail with an assertion if <b>pool</b> is not internally consistent. */
|
||||
void
|
||||
mp_pool_assert_ok(mp_pool_t *pool)
|
||||
void mp_pool_assert_ok(mp_pool_t *pool)
|
||||
{
|
||||
int n_empty;
|
||||
int n_empty;
|
||||
|
||||
n_empty = assert_chunks_ok(pool, pool->empty_chunks, 1, 0);
|
||||
assert_chunks_ok(pool, pool->full_chunks, 0, 1);
|
||||
assert_chunks_ok(pool, pool->used_chunks, 0, 0);
|
||||
n_empty = assert_chunks_ok(pool, pool->empty_chunks, 1, 0);
|
||||
assert_chunks_ok(pool, pool->full_chunks, 0, 1);
|
||||
assert_chunks_ok(pool, pool->used_chunks, 0, 0);
|
||||
|
||||
assert(pool->n_empty_chunks == n_empty);
|
||||
assert(pool->n_empty_chunks == n_empty);
|
||||
}
|
||||
|
||||
void
|
||||
mp_pool_garbage_collect(void *arg)
|
||||
void mp_pool_garbage_collect(void *arg)
|
||||
{
|
||||
mp_pool_t *pool = mp_allocated_pools;
|
||||
mp_pool_t *pool = mp_allocated_pools;
|
||||
|
||||
for (; pool; pool = pool->next)
|
||||
mp_pool_clean(pool, 0, 1);
|
||||
for (; pool; pool = pool->next)
|
||||
mp_pool_clean(pool, 0, 1);
|
||||
}
|
||||
|
||||
/** Dump information about <b>pool</b>'s memory usage to the Tor log at level
|
||||
* <b>severity</b>. */
|
||||
void
|
||||
mp_pool_log_status(mp_pool_t *pool)
|
||||
void mp_pool_log_status(mp_pool_t *pool)
|
||||
{
|
||||
unsigned long long bytes_used = 0;
|
||||
unsigned long long bytes_allocated = 0;
|
||||
unsigned long long bu = 0, ba = 0;
|
||||
mp_chunk_t *chunk;
|
||||
int n_full = 0, n_used = 0;
|
||||
unsigned long long bytes_used = 0;
|
||||
unsigned long long bytes_allocated = 0;
|
||||
unsigned long long bu = 0, ba = 0;
|
||||
mp_chunk_t *chunk;
|
||||
int n_full = 0, n_used = 0;
|
||||
|
||||
assert(pool);
|
||||
assert(pool);
|
||||
|
||||
for (chunk = pool->empty_chunks; chunk; chunk = chunk->next)
|
||||
bytes_allocated += chunk->mem_size;
|
||||
for (chunk = pool->empty_chunks; chunk; chunk = chunk->next)
|
||||
bytes_allocated += chunk->mem_size;
|
||||
|
||||
for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
|
||||
++n_used;
|
||||
bu += chunk->n_allocated * pool->item_alloc_size;
|
||||
ba += chunk->mem_size;
|
||||
}
|
||||
for (chunk = pool->used_chunks; chunk; chunk = chunk->next)
|
||||
{
|
||||
++n_used;
|
||||
bu += chunk->n_allocated * pool->item_alloc_size;
|
||||
ba += chunk->mem_size;
|
||||
}
|
||||
|
||||
bytes_used += bu;
|
||||
bytes_allocated += ba;
|
||||
bu = ba = 0;
|
||||
bytes_used += bu;
|
||||
bytes_allocated += ba;
|
||||
bu = ba = 0;
|
||||
|
||||
for (chunk = pool->full_chunks; chunk; chunk = chunk->next) {
|
||||
++n_full;
|
||||
bu += chunk->n_allocated * pool->item_alloc_size;
|
||||
ba += chunk->mem_size;
|
||||
}
|
||||
for (chunk = pool->full_chunks; chunk; chunk = chunk->next)
|
||||
{
|
||||
++n_full;
|
||||
bu += chunk->n_allocated * pool->item_alloc_size;
|
||||
ba += chunk->mem_size;
|
||||
}
|
||||
|
||||
bytes_used += bu;
|
||||
bytes_allocated += ba;
|
||||
bytes_used += bu;
|
||||
bytes_allocated += ba;
|
||||
}
|
||||
#endif
|
||||
|
||||
+197
-189
@@ -44,18 +44,34 @@ static const char *weekdays[] = {
|
||||
/* clang-format on */
|
||||
|
||||
static const char *short_months[12] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
};
|
||||
|
||||
static const char *short_weekdays[7] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
||||
"Sun",
|
||||
"Mon",
|
||||
"Tue",
|
||||
"Wed",
|
||||
"Thu",
|
||||
"Fri",
|
||||
"Sat",
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int value; /** Unique integer value of item */
|
||||
char character; /** Unique character assigned to item */
|
||||
char *name; /** Name of item */
|
||||
int value; /** Unique integer value of item */
|
||||
char character; /** Unique character assigned to item */
|
||||
char *name; /** Name of item */
|
||||
char config_only;
|
||||
} BanActTable;
|
||||
|
||||
@@ -89,10 +105,10 @@ static BanActTable banacttable[] = {
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct {
|
||||
int value; /** Unique integer value of item */
|
||||
char character; /** Unique character assigned to item */
|
||||
char *name; /** Name of item */
|
||||
char *irccommand; /** Raw IRC command of item (not unique!) */
|
||||
int value; /** Unique integer value of item */
|
||||
char character; /** Unique character assigned to item */
|
||||
char *name; /** Name of item */
|
||||
char *irccommand; /** Raw IRC command of item (not unique!) */
|
||||
} SpamfilterTargetTable;
|
||||
|
||||
/* clang-format off */
|
||||
@@ -122,7 +138,7 @@ const char *long_date(time_t clock)
|
||||
static char buf[80], plus;
|
||||
struct tm *lt, *gm;
|
||||
struct tm gmbuf;
|
||||
int minswest;
|
||||
int minswest;
|
||||
|
||||
if (!clock)
|
||||
time(&clock);
|
||||
@@ -133,7 +149,7 @@ const char *long_date(time_t clock)
|
||||
#ifndef _WIN32
|
||||
if (lt->tm_yday == gm->tm_yday)
|
||||
minswest = (gm->tm_hour - lt->tm_hour) * 60 +
|
||||
(gm->tm_min - lt->tm_min);
|
||||
(gm->tm_min - lt->tm_min);
|
||||
else if (lt->tm_yday > gm->tm_yday)
|
||||
minswest = (gm->tm_hour - (lt->tm_hour + 24)) * 60;
|
||||
else
|
||||
@@ -145,9 +161,9 @@ const char *long_date(time_t clock)
|
||||
if (minswest < 0)
|
||||
minswest = -minswest;
|
||||
ircsnprintf(buf, sizeof(buf), "%s %s %d %d -- %02d:%02d %c%02d:%02d",
|
||||
weekdays[lt->tm_wday], months[lt->tm_mon], lt->tm_mday,
|
||||
1900 + lt->tm_year,
|
||||
lt->tm_hour, lt->tm_min, plus, minswest / 60, minswest % 60);
|
||||
weekdays[lt->tm_wday], months[lt->tm_mon], lt->tm_mday,
|
||||
1900 + lt->tm_year,
|
||||
lt->tm_hour, lt->tm_min, plus, minswest / 60, minswest % 60);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -232,9 +248,9 @@ char *make_user_host(const char *name, const char *host)
|
||||
{
|
||||
static char namebuf[USERLEN + HOSTLEN + 6];
|
||||
|
||||
strlncpy(namebuf, check_string(name), sizeof(namebuf), USERLEN+1);
|
||||
strlncpy(namebuf, check_string(name), sizeof(namebuf), USERLEN + 1);
|
||||
strlcat(namebuf, "@", sizeof(namebuf));
|
||||
strlncat(namebuf, check_string(host), sizeof(namebuf), HOSTLEN+1);
|
||||
strlncat(namebuf, check_string(host), sizeof(namebuf), HOSTLEN + 1);
|
||||
return namebuf;
|
||||
}
|
||||
|
||||
@@ -244,11 +260,11 @@ char *make_user_host(const char *name, const char *host)
|
||||
*/
|
||||
char *make_nick_user_host_r(char *namebuf, size_t namebuflen, const char *nick, const char *name, const char *host)
|
||||
{
|
||||
strlncpy(namebuf, check_string(nick), namebuflen, NICKLEN+1);
|
||||
strlncpy(namebuf, check_string(nick), namebuflen, NICKLEN + 1);
|
||||
strlcat(namebuf, "!", namebuflen);
|
||||
strlncat(namebuf, check_string(name), namebuflen, USERLEN+1);
|
||||
strlncat(namebuf, check_string(name), namebuflen, USERLEN + 1);
|
||||
strlcat(namebuf, "@", namebuflen);
|
||||
strlncat(namebuf, check_string(host), namebuflen, HOSTLEN+1);
|
||||
strlncat(namebuf, check_string(host), namebuflen, HOSTLEN + 1);
|
||||
return namebuf;
|
||||
}
|
||||
|
||||
@@ -351,14 +367,15 @@ const char *get_client_name(Client *client, int showip)
|
||||
if (showip)
|
||||
{
|
||||
ircsnprintf(nbuf, sizeof(nbuf), "%s[%s@%s.%d]",
|
||||
client->name,
|
||||
IsIdentSuccess(client) ? client->ident : "",
|
||||
client->ip ? client->ip : "???",
|
||||
get_client_port(client));
|
||||
} else {
|
||||
client->name,
|
||||
IsIdentSuccess(client) ? client->ident : "",
|
||||
client->ip ? client->ip : "???",
|
||||
get_client_port(client));
|
||||
} else
|
||||
{
|
||||
if (mycmp(client->name, client->local->sockhost))
|
||||
ircsnprintf(nbuf, sizeof(nbuf), "%s[%s]",
|
||||
client->name, client->local->sockhost);
|
||||
client->name, client->local->sockhost);
|
||||
else
|
||||
return client->name;
|
||||
}
|
||||
@@ -376,9 +393,9 @@ const char *get_client_host(Client *client)
|
||||
if (!client->local->hostp)
|
||||
return get_client_name(client, FALSE);
|
||||
ircsnprintf(nbuf, sizeof(nbuf), "%s[%-.*s@%-.*s]",
|
||||
client->name, USERLEN,
|
||||
IsIdentSuccess(client) ? client->ident : "",
|
||||
HOSTLEN, client->local->hostp->h_name);
|
||||
client->name, USERLEN,
|
||||
IsIdentSuccess(client) ? client->ident : "",
|
||||
HOSTLEN, client->local->hostp->h_name);
|
||||
return nbuf;
|
||||
}
|
||||
|
||||
@@ -400,7 +417,7 @@ int on_dccallow_list(Client *to, Client *from)
|
||||
{
|
||||
Link *lp;
|
||||
|
||||
for(lp = to->user->dccallow; lp; lp = lp->next)
|
||||
for (lp = to->user->dccallow; lp; lp = lp->next)
|
||||
if (lp->flags == DCC_LINK_ME && lp->value.client == from)
|
||||
return 1;
|
||||
return 0;
|
||||
@@ -456,11 +473,12 @@ int valid_host(const char *host, int strict)
|
||||
|
||||
if (strict)
|
||||
{
|
||||
for (p=host; *p; p++)
|
||||
for (p = host; *p; p++)
|
||||
if (!isalnum(*p) && !strchr("_-.", *p))
|
||||
return 0;
|
||||
} else {
|
||||
for (p=host; *p; p++)
|
||||
} else
|
||||
{
|
||||
for (p = host; *p; p++)
|
||||
if (!isalnum(*p) && !strchr("_-.:/", *p))
|
||||
return 0;
|
||||
}
|
||||
@@ -500,7 +518,7 @@ int valid_vhost(const char *userhost)
|
||||
char uhost[512], *p;
|
||||
const char *host = userhost;
|
||||
|
||||
strlcpy(uhost, userhost, sizeof(uhost));
|
||||
strlcpy(uhost, userhost, sizeof(uhost));
|
||||
|
||||
if ((p = strchr(uhost, '@')))
|
||||
{
|
||||
@@ -565,33 +583,29 @@ int parse_ban_action_set(const char *str, char **var, VarActionValue *op, int *v
|
||||
{
|
||||
*op = VAR_ACT_INCREASE;
|
||||
*p = '\0';
|
||||
p+=2;
|
||||
p += 2;
|
||||
*value = 1;
|
||||
} else
|
||||
if (!strncmp(p, "--", 2))
|
||||
} else if (!strncmp(p, "--", 2))
|
||||
{
|
||||
*op = VAR_ACT_DECREASE;
|
||||
*p = '\0';
|
||||
p+=2;
|
||||
p += 2;
|
||||
*value = 1;
|
||||
} else
|
||||
if (!strncmp(p, "+=", 2))
|
||||
} else if (!strncmp(p, "+=", 2))
|
||||
{
|
||||
*op = VAR_ACT_INCREASE;
|
||||
*p = '\0';
|
||||
p+=2;
|
||||
} else
|
||||
if (!strncmp(p, "-=", 2))
|
||||
p += 2;
|
||||
} else if (!strncmp(p, "-=", 2))
|
||||
{
|
||||
*op = VAR_ACT_DECREASE;
|
||||
*p = '\0';
|
||||
p+=2;
|
||||
} else
|
||||
if (!strncmp(p, "=", 1))
|
||||
p += 2;
|
||||
} else if (!strncmp(p, "=", 1))
|
||||
{
|
||||
*op = VAR_ACT_SET;
|
||||
*p = '\0';
|
||||
p+=1;
|
||||
p += 1;
|
||||
} else
|
||||
{
|
||||
*error = "Unknown set action, should be one of: ++, --, +=, -= or =";
|
||||
@@ -624,14 +638,14 @@ int test_ban_action_config_helper(ConfigEntry *ce, const char *name, const char
|
||||
if (!action)
|
||||
{
|
||||
config_error("%s:%d: unknown action: %s",
|
||||
ce->file->filename, ce->line_number, name);
|
||||
ce->file->filename, ce->line_number, name);
|
||||
errors++;
|
||||
} else if (action == BAN_ACT_SET)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
config_error("%s:%d: action set is missing a value",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
} else
|
||||
{
|
||||
@@ -642,7 +656,7 @@ int test_ban_action_config_helper(ConfigEntry *ce, const char *name, const char
|
||||
if (!parse_ban_action_set(value, &var, &op, &varvalue, &error))
|
||||
{
|
||||
config_error("%s:%d: action: %s",
|
||||
ce->file->filename, ce->line_number, error);
|
||||
ce->file->filename, ce->line_number, error);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -667,8 +681,7 @@ int test_ban_action_config(ConfigEntry *ce)
|
||||
/* action { xxx; } */
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
errors += test_ban_action_config_helper(cep, cep->name, cep->value);
|
||||
} else
|
||||
if (!ce->value)
|
||||
} else if (!ce->value)
|
||||
{
|
||||
config_error("%s:%d: action has no value", ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
@@ -701,8 +714,7 @@ BanAction *parse_ban_action_config_helper(const char *name, const char *value)
|
||||
safe_strdup(action->var, var);
|
||||
action->value = varvalue;
|
||||
action->var_action = op;
|
||||
} else
|
||||
if (action->action == BAN_ACT_REPORT)
|
||||
} else if (action->action == BAN_ACT_REPORT)
|
||||
{
|
||||
safe_strdup(action->var, value); // can be NULL, means all
|
||||
}
|
||||
@@ -738,8 +750,7 @@ void parse_ban_action_config(ConfigEntry *ce, BanAction **store_actions)
|
||||
if (action)
|
||||
append_ListItem((ListStruct *)action, (ListStruct **)store_actions);
|
||||
}
|
||||
} else
|
||||
if (ce->value)
|
||||
} else if (ce->value)
|
||||
{
|
||||
/* action xxx; */
|
||||
action = parse_ban_action_config_helper(ce->value, NULL);
|
||||
@@ -858,7 +869,7 @@ const char *ban_actions_to_string(BanAction *actions)
|
||||
|
||||
/* Cut off trailing "," */
|
||||
if (*buf)
|
||||
buf[strlen(buf)-1] = '\0';
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -926,8 +937,8 @@ BanAction *duplicate_ban_actions(BanAction *actions)
|
||||
/** Extract target flags from string 's'. */
|
||||
int spamfilter_gettargets(const char *s, Client *client)
|
||||
{
|
||||
SpamfilterTargetTable *e;
|
||||
int flags = 0;
|
||||
SpamfilterTargetTable *e;
|
||||
int flags = 0;
|
||||
|
||||
for (; *s; s++)
|
||||
{
|
||||
@@ -949,7 +960,7 @@ int flags = 0;
|
||||
/** Convert a string with a targetname to an integer value */
|
||||
int spamfilter_getconftargets(const char *s)
|
||||
{
|
||||
SpamfilterTargetTable *e;
|
||||
SpamfilterTargetTable *e;
|
||||
|
||||
for (e = &spamfiltertargettable[0]; e->value; e++)
|
||||
if (!strcmp(s, e->name))
|
||||
@@ -979,17 +990,17 @@ char *unreal_decodespace(const char *s)
|
||||
const char *i;
|
||||
static char buf[512], *o;
|
||||
|
||||
for (i = s, o = buf; (*i) && (o < buf+510); i++)
|
||||
for (i = s, o = buf; (*i) && (o < buf + 510); i++)
|
||||
if (*i == '_')
|
||||
{
|
||||
if (i[1] != '_')
|
||||
*o++ = ' ';
|
||||
else {
|
||||
else
|
||||
{
|
||||
*o++ = '_';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
*o++ = *i;
|
||||
*o = '\0';
|
||||
return buf;
|
||||
@@ -1006,7 +1017,7 @@ char *unreal_encodespace(const char *s)
|
||||
if (!s)
|
||||
return NULL; /* NULL in = NULL out */
|
||||
|
||||
for (i = s, o = buf; (*i) && (o < buf+509); i++)
|
||||
for (i = s, o = buf; (*i) && (o < buf + 509); i++)
|
||||
{
|
||||
if (*i == ' ')
|
||||
*o++ = '_';
|
||||
@@ -1014,8 +1025,7 @@ char *unreal_encodespace(const char *s)
|
||||
{
|
||||
*o++ = '_';
|
||||
*o++ = '_';
|
||||
}
|
||||
else
|
||||
} else
|
||||
*o++ = *i;
|
||||
}
|
||||
*o = '\0';
|
||||
@@ -1055,8 +1065,7 @@ void unreal_add_names(NameList **n, ConfigEntry *ce)
|
||||
ConfigEntry *cep;
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
_add_name_list(n, cep->value ? cep->value : cep->name);
|
||||
} else
|
||||
if (ce->value)
|
||||
} else if (ce->value)
|
||||
{
|
||||
_add_name_list(n, ce->value);
|
||||
}
|
||||
@@ -1070,8 +1079,7 @@ void unreal_add_name_values(NameValuePrioList **n, const char *name, ConfigEntry
|
||||
ConfigEntry *cep;
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
add_nvplist(n, 0, name, cep->value ? cep->value : cep->name);
|
||||
} else
|
||||
if (ce->value)
|
||||
} else if (ce->value)
|
||||
{
|
||||
add_nvplist(n, 0, name, ce->value);
|
||||
}
|
||||
@@ -1110,7 +1118,7 @@ const char *namevalue_nospaces(NameValuePrioList *n)
|
||||
snprintf(buf, sizeof(buf), "%s:%s", n->name, n->value);
|
||||
|
||||
/* Replace spaces with underscores */
|
||||
for (p=buf; *p; p++)
|
||||
for (p = buf; *p; p++)
|
||||
if (*p == ' ')
|
||||
*p = '_';
|
||||
|
||||
@@ -1137,7 +1145,7 @@ char *our_strcasestr(const char *haystack, const char *needle)
|
||||
|
||||
for (i = 0; i <= (hlength - nlength); i++)
|
||||
{
|
||||
if (strncasecmp (haystack + i, needle, nlength) == 0)
|
||||
if (strncasecmp(haystack + i, needle, nlength) == 0)
|
||||
return (char *)(haystack + i);
|
||||
}
|
||||
|
||||
@@ -1170,10 +1178,10 @@ int swhois_add(Client *client, const char *tag, int priority, const char *swhois
|
||||
AddListItemPrio(s, client->user->swhois, s->priority);
|
||||
|
||||
sendto_server(skip, 0, PROTO_EXTSWHOIS, NULL, ":%s SWHOIS %s :%s",
|
||||
from->id, client->id, swhois);
|
||||
from->id, client->id, swhois);
|
||||
|
||||
sendto_server(skip, PROTO_EXTSWHOIS, 0, NULL, ":%s SWHOIS %s + %s %d :%s",
|
||||
from->id, client->id, tag, priority, swhois);
|
||||
from->id, client->id, tag, priority, swhois);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1198,8 +1206,8 @@ int swhois_delete(Client *client, const char *tag, const char *swhois, Client *f
|
||||
s_next = s->next;
|
||||
|
||||
/* If ( same swhois or "*" ) AND same tag */
|
||||
if ( ((!strcmp(s->line, swhois) || !strcmp(swhois, "*")) &&
|
||||
!strcmp(s->setby, tag)))
|
||||
if (((!strcmp(s->line, swhois) || !strcmp(swhois, "*")) &&
|
||||
!strcmp(s->setby, tag)))
|
||||
{
|
||||
DelListItem(s, client->user->swhois);
|
||||
safe_free(s->line);
|
||||
@@ -1207,10 +1215,10 @@ int swhois_delete(Client *client, const char *tag, const char *swhois, Client *f
|
||||
safe_free(s);
|
||||
|
||||
sendto_server(skip, 0, PROTO_EXTSWHOIS, NULL, ":%s SWHOIS %s :",
|
||||
from->id, client->id);
|
||||
from->id, client->id);
|
||||
|
||||
sendto_server(skip, PROTO_EXTSWHOIS, 0, NULL, ":%s SWHOIS %s - %s %d :%s",
|
||||
from->id, client->id, tag, 0, swhois);
|
||||
from->id, client->id, tag, 0, swhois);
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
@@ -1426,7 +1434,8 @@ void new_message_special(Client *sender, MessageTag *recv_mtags, MessageTag **mt
|
||||
void parse_message_tags_default_handler(Client *client, char **str, MessageTag **mtag_list)
|
||||
{
|
||||
/* Just skip everything until the space character */
|
||||
for (; **str && **str != ' '; *str = *str + 1);
|
||||
for (; **str && **str != ' '; *str = *str + 1)
|
||||
;
|
||||
}
|
||||
|
||||
/** Default handler for mtags_to_string().
|
||||
@@ -1686,7 +1695,8 @@ time_t my_timegm(struct tm *tm)
|
||||
{
|
||||
setenv("TZ", tz, 1);
|
||||
safe_free(tz);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
unsetenv("TZ");
|
||||
}
|
||||
tzset();
|
||||
@@ -1710,13 +1720,13 @@ time_t server_time_to_unix_time(const char *tbuf)
|
||||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
ret = sscanf(tbuf, "%d-%d-%dT%d:%d:%d.%dZ",
|
||||
&tm.tm_year,
|
||||
&tm.tm_mon,
|
||||
&tm.tm_mday,
|
||||
&tm.tm_hour,
|
||||
&tm.tm_min,
|
||||
&tm.tm_sec,
|
||||
&dontcare);
|
||||
&tm.tm_year,
|
||||
&tm.tm_mon,
|
||||
&tm.tm_mday,
|
||||
&tm.tm_hour,
|
||||
&tm.tm_min,
|
||||
&tm.tm_sec,
|
||||
&dontcare);
|
||||
|
||||
if (ret != 7)
|
||||
return 0;
|
||||
@@ -1752,7 +1762,7 @@ time_t rfc2616_time_to_unix_time(const char *tbuf)
|
||||
if (ret < 6)
|
||||
return 0;
|
||||
|
||||
for (i=0; i < 12; i++)
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
if (!strcmp(short_months[i], month))
|
||||
{
|
||||
@@ -1776,7 +1786,7 @@ const char *rfc2616_time(time_t clock)
|
||||
static char buf[80], plus;
|
||||
struct tm *lt, *gm;
|
||||
struct tm gmbuf;
|
||||
int minswest;
|
||||
int minswest;
|
||||
|
||||
if (!clock)
|
||||
time(&clock);
|
||||
@@ -1950,7 +1960,7 @@ void binarytohex(void *data, size_t len, char *str)
|
||||
char *datastr = (char *)data;
|
||||
int i, n = 0;
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
str[n++] = hexchars[(datastr[i] >> 4) & 0xF];
|
||||
str[n++] = hexchars[datastr[i] & 0xF];
|
||||
@@ -2060,7 +2070,7 @@ const char *sha256sum_file(const char *fname)
|
||||
char buf[2048];
|
||||
SHA256_CTX hash;
|
||||
char binaryhash[SHA256_DIGEST_LENGTH];
|
||||
static char hexhash[SHA256_DIGEST_LENGTH*2+1];
|
||||
static char hexhash[SHA256_DIGEST_LENGTH * 2 + 1];
|
||||
int n;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
unsigned int md_len;
|
||||
@@ -2137,10 +2147,11 @@ char *filename_strip_suffix(const char *fname, const char *suffix)
|
||||
int suffix_len = strlen(suffix);
|
||||
if (buf_len >= suffix_len)
|
||||
{
|
||||
if (!strncmp(buf+buf_len-suffix_len, suffix, suffix_len))
|
||||
buf[buf_len-suffix_len] = '\0';
|
||||
if (!strncmp(buf + buf_len - suffix_len, suffix, suffix_len))
|
||||
buf[buf_len - suffix_len] = '\0';
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
char *p = strrchr(buf, '.');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
@@ -2277,13 +2288,14 @@ MultiLine *line2multiline(const char *str)
|
||||
|
||||
strlcpy(buf, str, sizeof(buf));
|
||||
p = buf;
|
||||
do {
|
||||
do
|
||||
{
|
||||
p2 = strchr(p, '\n');
|
||||
if (p2)
|
||||
*p2++ = '\0';
|
||||
addmultiline(&ml, p);
|
||||
p = p2;
|
||||
} while(p2 && *p2);
|
||||
} while (p2 && *p2);
|
||||
return ml;
|
||||
}
|
||||
|
||||
@@ -2308,7 +2320,7 @@ const char *sendtype_to_cmd(SendType sendtype)
|
||||
int check_password_strength(const char *pass, int min_length, int strict, char **err)
|
||||
{
|
||||
static char buf[256];
|
||||
char has_lowercase=0, has_uppercase=0, has_digit=0;
|
||||
char has_lowercase = 0, has_uppercase = 0, has_digit = 0;
|
||||
const char *p;
|
||||
|
||||
if (err)
|
||||
@@ -2324,7 +2336,7 @@ int check_password_strength(const char *pass, int min_length, int strict, char *
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (p=pass; *p; p++)
|
||||
for (p = pass; *p; p++)
|
||||
{
|
||||
if (islower(*p))
|
||||
has_lowercase = 1;
|
||||
@@ -2341,14 +2353,12 @@ int check_password_strength(const char *pass, int min_length, int strict, char *
|
||||
if (err)
|
||||
*err = "Password must contain at least 1 lowercase character";
|
||||
return 0;
|
||||
} else
|
||||
if (!has_uppercase)
|
||||
} else if (!has_uppercase)
|
||||
{
|
||||
if (err)
|
||||
*err = "Password must contain at least 1 UPPERcase character";
|
||||
return 0;
|
||||
} else
|
||||
if (!has_digit)
|
||||
} else if (!has_digit)
|
||||
{
|
||||
if (err)
|
||||
*err = "Password must contain at least 1 digit (number)";
|
||||
@@ -2418,7 +2428,8 @@ int terminal_supports_color(void)
|
||||
/** Skip whitespace (if any) */
|
||||
void skip_whitespace(char **p)
|
||||
{
|
||||
for (; **p == ' ' || **p == '\t'; *p = *p + 1);
|
||||
for (; **p == ' ' || **p == '\t'; *p = *p + 1)
|
||||
;
|
||||
}
|
||||
|
||||
/** Keep reading '*p' until we hit any of the 'stopchars'.
|
||||
@@ -2427,16 +2438,17 @@ void skip_whitespace(char **p)
|
||||
*/
|
||||
void read_until(char **p, char *stopchars)
|
||||
{
|
||||
for (; **p && !strchr(stopchars, **p); *p = *p + 1);
|
||||
for (; **p && !strchr(stopchars, **p); *p = *p + 1)
|
||||
;
|
||||
}
|
||||
|
||||
void write_pidfile_failed(void)
|
||||
{
|
||||
char *errstr = strerror(errno);
|
||||
unreal_log(ULOG_WARNING, "config", "WRITE_PID_FILE_FAILED", NULL,
|
||||
"Unable to write to pid file '$filename': $system_error",
|
||||
log_data_string("filename", conf_files->pid_file),
|
||||
log_data_string("system_error", errstr));
|
||||
"Unable to write to pid file '$filename': $system_error",
|
||||
log_data_string("filename", conf_files->pid_file),
|
||||
log_data_string("system_error", errstr));
|
||||
}
|
||||
|
||||
/** Write PID file */
|
||||
@@ -2534,8 +2546,7 @@ char *url_getfilename(const char *url)
|
||||
if (!*c)
|
||||
return raw_strdup(start);
|
||||
else
|
||||
return raw_strldup(start, c-start+1);
|
||||
|
||||
return raw_strldup(start, c - start + 1);
|
||||
}
|
||||
return raw_strdup("-");
|
||||
}
|
||||
@@ -2554,7 +2565,8 @@ int is_file_readable(const char *file, const char *dir)
|
||||
{
|
||||
char *filename = strdup(file);
|
||||
convert_to_absolute_path(&filename, dir);
|
||||
if (access(filename, R_OK)){
|
||||
if (access(filename, R_OK))
|
||||
{
|
||||
safe_free(filename);
|
||||
return 0;
|
||||
}
|
||||
@@ -2637,12 +2649,11 @@ void s_die()
|
||||
loop.terminating = 1;
|
||||
unload_all_modules();
|
||||
|
||||
list_for_each_entry(client, &lclient_list, lclient_node)
|
||||
(void) send_queued(client);
|
||||
list_for_each_entry(client, &lclient_list, lclient_node)(void) send_queued(client);
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
else {
|
||||
} else
|
||||
{
|
||||
SERVICE_STATUS status;
|
||||
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_STOP);
|
||||
@@ -2705,10 +2716,10 @@ void ignore_this_signal()
|
||||
(void)sigaddset(&act.sa_mask, SIGPIPE);
|
||||
(void)sigaction(SIGALRM, &act, (struct sigaction *)NULL);
|
||||
(void)sigaction(SIGPIPE, &act, (struct sigaction *)NULL);
|
||||
#ifdef SIGWINCH
|
||||
#ifdef SIGWINCH
|
||||
(void)sigaddset(&act.sa_mask, SIGWINCH);
|
||||
(void)sigaction(SIGWINCH, &act, (struct sigaction *)NULL);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif /* #ifndef _WIN32 */
|
||||
|
||||
@@ -2721,8 +2732,7 @@ void server_reboot(const char *mesg)
|
||||
"Restarting server: $reason",
|
||||
log_data_string("reason", mesg));
|
||||
|
||||
list_for_each_entry(client, &lclient_list, lclient_node)
|
||||
(void) send_queued(client);
|
||||
list_for_each_entry(client, &lclient_list, lclient_node)(void) send_queued(client);
|
||||
|
||||
/*
|
||||
* ** fd 0 must be 'preserved' if either the -d or -i options have
|
||||
@@ -2763,14 +2773,13 @@ void server_reboot(const char *mesg)
|
||||
SetServiceStatus(IRCDStatusHandle, &IRCDStatus);
|
||||
GetModuleFileName(GetModuleHandle(NULL), fname, MAX_PATH);
|
||||
CreateProcess(fname, "restartsvc", NULL, NULL, FALSE,
|
||||
0, NULL, NULL, &si, &pi);
|
||||
0, NULL, NULL, &si, &pi);
|
||||
IRCDStatus.dwCurrentState = SERVICE_STOPPED;
|
||||
SetServiceStatus(IRCDStatusHandle, &IRCDStatus);
|
||||
ExitProcess(0);
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
exit(-1);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/** Check if at least 'minimum' seconds passed by since last run.
|
||||
@@ -2789,7 +2798,7 @@ int minimum_msec_since_last_run(struct timeval *tv_old, long minimum)
|
||||
tv_old->tv_usec = timeofday_tv.tv_usec;
|
||||
return 0;
|
||||
}
|
||||
v = ((timeofday_tv.tv_sec - tv_old->tv_sec) * 1000) + ((timeofday_tv.tv_usec - tv_old->tv_usec)/1000);
|
||||
v = ((timeofday_tv.tv_sec - tv_old->tv_sec) * 1000) + ((timeofday_tv.tv_usec - tv_old->tv_usec) / 1000);
|
||||
if (v >= minimum)
|
||||
{
|
||||
tv_old->tv_sec = timeofday_tv.tv_sec;
|
||||
@@ -2808,10 +2817,10 @@ int minimum_msec_since_last_run(struct timeval *tv_old, long minimum)
|
||||
*/
|
||||
const char *StripControlCodesEx(const char *text, char *output, size_t outputlen, int strip_flags)
|
||||
{
|
||||
int i = 0, len = strlen(text), save_len=0;
|
||||
int i = 0, len = strlen(text), save_len = 0;
|
||||
char nc = 0, col = 0, rgb = 0;
|
||||
char *o = output;
|
||||
const char *save_text=NULL;
|
||||
const char *save_text = NULL;
|
||||
|
||||
/* Handle special cases first.. */
|
||||
|
||||
@@ -2827,7 +2836,7 @@ const char *StripControlCodesEx(const char *text, char *output, size_t outputlen
|
||||
/* Reserve room for the NUL byte */
|
||||
outputlen--;
|
||||
|
||||
while (len > 0)
|
||||
while (len > 0)
|
||||
{
|
||||
if ((col && isdigit(*text) && nc < 2) ||
|
||||
((col == 1) && (*text == ',') && isdigit(text[1]) && (nc > 0) && (nc < 3)))
|
||||
@@ -2848,8 +2857,7 @@ const char *StripControlCodesEx(const char *text, char *output, size_t outputlen
|
||||
nc++;
|
||||
if (*text == ',')
|
||||
nc = 0;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
if (col)
|
||||
col = 0;
|
||||
@@ -2857,8 +2865,8 @@ const char *StripControlCodesEx(const char *text, char *output, size_t outputlen
|
||||
{
|
||||
if (nc != 6)
|
||||
{
|
||||
text = save_text+1;
|
||||
len = save_len-1;
|
||||
text = save_text + 1;
|
||||
len = save_len - 1;
|
||||
rgb = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -2866,63 +2874,62 @@ const char *StripControlCodesEx(const char *text, char *output, size_t outputlen
|
||||
}
|
||||
switch (*text)
|
||||
{
|
||||
case 3:
|
||||
/* color */
|
||||
col = 1;
|
||||
nc = 0;
|
||||
break;
|
||||
case 4:
|
||||
/* RGB */
|
||||
save_text = text;
|
||||
save_len = len;
|
||||
rgb = 1;
|
||||
nc = 0;
|
||||
break;
|
||||
case 2:
|
||||
/* bold */
|
||||
break;
|
||||
case 31:
|
||||
/* underline */
|
||||
break;
|
||||
case 22:
|
||||
/* reverse */
|
||||
break;
|
||||
case 15:
|
||||
/* plain */
|
||||
break;
|
||||
case 29:
|
||||
/* italic */
|
||||
break;
|
||||
case 30:
|
||||
/* strikethrough */
|
||||
break;
|
||||
case 17:
|
||||
/* monospace */
|
||||
break;
|
||||
case 0xe2:
|
||||
if (!strncmp(text+1, "\x80\x8b", 2))
|
||||
{
|
||||
/* +2 means we skip 3 */
|
||||
text += 2;
|
||||
len -= 2;
|
||||
case 3:
|
||||
/* color */
|
||||
col = 1;
|
||||
nc = 0;
|
||||
break;
|
||||
}
|
||||
/*fallthrough*/
|
||||
default:
|
||||
if ((*text >= ' ') ||
|
||||
!(strip_flags & UNRL_STRIP_LOW_ASCII) ||
|
||||
((strip_flags & UNRL_STRIP_KEEP_LF) && (*text == '\n'))
|
||||
)
|
||||
{
|
||||
*o++ = *text;
|
||||
outputlen--;
|
||||
if (outputlen == 0)
|
||||
case 4:
|
||||
/* RGB */
|
||||
save_text = text;
|
||||
save_len = len;
|
||||
rgb = 1;
|
||||
nc = 0;
|
||||
break;
|
||||
case 2:
|
||||
/* bold */
|
||||
break;
|
||||
case 31:
|
||||
/* underline */
|
||||
break;
|
||||
case 22:
|
||||
/* reverse */
|
||||
break;
|
||||
case 15:
|
||||
/* plain */
|
||||
break;
|
||||
case 29:
|
||||
/* italic */
|
||||
break;
|
||||
case 30:
|
||||
/* strikethrough */
|
||||
break;
|
||||
case 17:
|
||||
/* monospace */
|
||||
break;
|
||||
case 0xe2:
|
||||
if (!strncmp(text + 1, "\x80\x8b", 2))
|
||||
{
|
||||
*o = '\0';
|
||||
return output;
|
||||
/* +2 means we skip 3 */
|
||||
text += 2;
|
||||
len -= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*fallthrough*/
|
||||
default:
|
||||
if ((*text >= ' ') ||
|
||||
!(strip_flags & UNRL_STRIP_LOW_ASCII) ||
|
||||
((strip_flags & UNRL_STRIP_KEEP_LF) && (*text == '\n')))
|
||||
{
|
||||
*o++ = *text;
|
||||
outputlen--;
|
||||
if (outputlen == 0)
|
||||
{
|
||||
*o = '\0';
|
||||
return output;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
text++;
|
||||
@@ -3045,9 +3052,9 @@ void free_outgoingwebrequest(OutgoingWebRequest *r)
|
||||
safe_free(r->apicallback);
|
||||
safe_free(r->url);
|
||||
safe_free(r->actual_url);
|
||||
safe_free(r->body);
|
||||
safe_free_nvplist(r->headers);
|
||||
safe_free(r);
|
||||
safe_free(r->body);
|
||||
safe_free_nvplist(r->headers);
|
||||
safe_free(r);
|
||||
}
|
||||
|
||||
/** Safely duplicate an OutgoingWebRequest struct (eg for https redirects) */
|
||||
@@ -3157,7 +3164,8 @@ void synchronous_http_request_handle_response(OutgoingWebRequest *request, Outgo
|
||||
{
|
||||
strlcpy(synchronous_http_request_tmpfile, response->file, sizeof(synchronous_http_request_tmpfile));
|
||||
synchronous_http_request_in_progress = 0;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error("%s: Unexpected error, no error but no file", request->url);
|
||||
synchronous_http_request_in_progress = -1;
|
||||
}
|
||||
|
||||
+125
-129
@@ -7,13 +7,12 @@
|
||||
#include "unrealircd.h"
|
||||
#ifndef _WIN32
|
||||
|
||||
#define MODULEMANAGER_CONNECT_TIMEOUT 7
|
||||
#define MODULEMANAGER_TRANSFER_TIMEOUT 20
|
||||
#define MODULEMANAGER_CONNECT_TIMEOUT 7
|
||||
#define MODULEMANAGER_TRANSFER_TIMEOUT 20
|
||||
|
||||
typedef struct ManagedModule ManagedModule;
|
||||
|
||||
struct ManagedModule
|
||||
{
|
||||
struct ManagedModule {
|
||||
ManagedModule *prev, *next;
|
||||
char *repo_url;
|
||||
char *name;
|
||||
@@ -44,24 +43,29 @@ static int no_make_install = 0;
|
||||
|
||||
/* Forward declarations */
|
||||
int mm_valid_module_name(char *name);
|
||||
#define safe_free_managed_module(x) do { free_managed_module(x); x = NULL; } while(0)
|
||||
#define safe_free_managed_module(x) \
|
||||
do \
|
||||
{ \
|
||||
free_managed_module(x); \
|
||||
x = NULL; \
|
||||
} while (0)
|
||||
void free_managed_module(ManagedModule *m);
|
||||
|
||||
typedef enum ParseModuleHeaderStage {
|
||||
PMH_STAGE_LOOKING = 0,
|
||||
PMH_STAGE_MODULEHEADER = 1,
|
||||
PMH_STAGE_MOD_HEADER = 2,
|
||||
PMH_STAGE_GOT_NAME = 3,
|
||||
PMH_STAGE_GOT_VERSION = 4,
|
||||
PMH_STAGE_GOT_DESCRIPTION = 5,
|
||||
PMH_STAGE_GOT_AUTHOR = 6,
|
||||
PMT_STAGE_DONE = 7,
|
||||
PMH_STAGE_LOOKING = 0,
|
||||
PMH_STAGE_MODULEHEADER = 1,
|
||||
PMH_STAGE_MOD_HEADER = 2,
|
||||
PMH_STAGE_GOT_NAME = 3,
|
||||
PMH_STAGE_GOT_VERSION = 4,
|
||||
PMH_STAGE_GOT_DESCRIPTION = 5,
|
||||
PMH_STAGE_GOT_AUTHOR = 6,
|
||||
PMT_STAGE_DONE = 7,
|
||||
} ParseModuleHeaderStage;
|
||||
|
||||
typedef enum ParseModuleConfigStage {
|
||||
PMC_STAGE_LOOKING = 0,
|
||||
PMC_STAGE_STARTED = 1,
|
||||
PMC_STAGE_FINISHED = 2,
|
||||
PMC_STAGE_LOOKING = 0,
|
||||
PMC_STAGE_STARTED = 1,
|
||||
PMC_STAGE_FINISHED = 2,
|
||||
} ParseModuleConfigStage;
|
||||
|
||||
int parse_quoted_string(char *buf, char *dest, size_t destlen)
|
||||
@@ -73,19 +77,24 @@ int parse_quoted_string(char *buf, char *dest, size_t destlen)
|
||||
p = strchr(buf, '"');
|
||||
if (!p)
|
||||
return 0;
|
||||
p2 = strrchr(p+1, '"');
|
||||
p2 = strrchr(p + 1, '"');
|
||||
if (!p2)
|
||||
return 0;
|
||||
max = p2 - p;
|
||||
if (max > destlen)
|
||||
max = destlen;
|
||||
strlcpy(dest, p+1, max);
|
||||
strlcpy(dest, p + 1, max);
|
||||
unreal_del_quotes(dest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#undef CheckNull
|
||||
#define CheckNull(x) if ((!(x)->value) || (!(*((x)->value)))) { config_error("%s:%i: missing parameter", m->name, (x)->line_number); return 0; }
|
||||
#undef CheckNull
|
||||
#define CheckNull(x) \
|
||||
if ((!(x)->value) || (!(*((x)->value)))) \
|
||||
{ \
|
||||
config_error("%s:%i: missing parameter", m->name, (x)->line_number); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
/** Parse a module { } line from a module (not repo!!) */
|
||||
int mm_module_file_config(ManagedModule *m, ConfigEntry *ce)
|
||||
@@ -95,7 +104,7 @@ int mm_module_file_config(ManagedModule *m, ConfigEntry *ce)
|
||||
if (ce->value)
|
||||
{
|
||||
config_error("%s:%d: module { } block should not have a name.",
|
||||
m->name, ce->line_number);
|
||||
m->name, ce->line_number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,47 +113,41 @@ int mm_module_file_config(ManagedModule *m, ConfigEntry *ce)
|
||||
if (!strcmp(cep->name, "source") ||
|
||||
!strcmp(cep->name, "version") ||
|
||||
!strcmp(cep->name, "author") ||
|
||||
!strcmp(cep->name, "sha256sum") ||
|
||||
!strcmp(cep->name, "description")
|
||||
)
|
||||
!strcmp(cep->name, "sha256sum") ||
|
||||
!strcmp(cep->name, "description"))
|
||||
{
|
||||
config_error("%s:%d: module::%s should not be in here (it only exists in repository entries)",
|
||||
m->name, cep->line_number, cep->name);
|
||||
m->name, cep->line_number, cep->name);
|
||||
return 0;
|
||||
}
|
||||
else if (!strcmp(cep->name, "troubleshooting"))
|
||||
} else if (!strcmp(cep->name, "troubleshooting"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->troubleshooting, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "documentation"))
|
||||
} else if (!strcmp(cep->name, "documentation"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->documentation, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "min-unrealircd-version"))
|
||||
} else if (!strcmp(cep->name, "min-unrealircd-version"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->min_unrealircd_version, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "max-unrealircd-version"))
|
||||
} else if (!strcmp(cep->name, "max-unrealircd-version"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->max_unrealircd_version, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "compile-flags"))
|
||||
} else if (!strcmp(cep->name, "compile-flags"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->compile_flags, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "post-install-text"))
|
||||
} else if (!strcmp(cep->name, "post-install-text"))
|
||||
{
|
||||
if (cep->items)
|
||||
{
|
||||
ConfigEntry *cepp;
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
addmultiline(&m->post_install_text, cepp->name);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
CheckNull(cep);
|
||||
addmultiline(&m->post_install_text, cep->value);
|
||||
}
|
||||
@@ -177,7 +180,7 @@ int mm_module_file_config(ManagedModule *m, ConfigEntry *ce)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#undef CheckNull
|
||||
#undef CheckNull
|
||||
|
||||
int mm_parse_module_file(ManagedModule *m, char *buf, unsigned int line_offset)
|
||||
{
|
||||
@@ -204,7 +207,7 @@ int mm_parse_module_file(ManagedModule *m, char *buf, unsigned int line_offset)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define MODULECONFIGBUFFER 16384
|
||||
#define MODULECONFIGBUFFER 16384
|
||||
ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
{
|
||||
char buf[1024];
|
||||
@@ -231,7 +234,7 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
if (!fd)
|
||||
{
|
||||
fprintf(stderr, "Unable to open module '%s', file '%s': %s\n",
|
||||
modulename, fname, strerror(errno));
|
||||
modulename, fname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -276,7 +279,8 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
switch (parse_module_config)
|
||||
{
|
||||
case PMC_STAGE_LOOKING:
|
||||
if (strstr(buf, "<<<MODULE MANAGER START>>>")){
|
||||
if (strstr(buf, "<<<MODULE MANAGER START>>>"))
|
||||
{
|
||||
module_config_start_line = linenr;
|
||||
parse_module_config = PMC_STAGE_STARTED;
|
||||
}
|
||||
@@ -309,7 +313,7 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
if (strcmp(module_header_name, modulename))
|
||||
{
|
||||
fprintf(stderr, "ERROR: Mismatch in module name in header (%s) and filename (%s)\n",
|
||||
module_header_name, modulename);
|
||||
module_header_name, modulename);
|
||||
safe_free(moduleconfig);
|
||||
return NULL;
|
||||
}
|
||||
@@ -319,7 +323,7 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
if (!silent)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Module does not contain module config data (<<<MODULE MANAGER START>>>)\n"
|
||||
"This means it is not meant to be managed by the module manager\n");
|
||||
"This means it is not meant to be managed by the module manager\n");
|
||||
}
|
||||
safe_free(moduleconfig);
|
||||
return NULL;
|
||||
@@ -336,12 +340,12 @@ ManagedModule *mm_parse_module_c_file(char *modulename, char *fname, int silent)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Problem with module manager data block within the %s module C source file.\n"
|
||||
"You are suggested to contact the module author and paste the above to him/her\n",
|
||||
m->name);
|
||||
m->name);
|
||||
safe_free_managed_module(m);
|
||||
safe_free(moduleconfig);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
safe_free(moduleconfig);
|
||||
return m;
|
||||
}
|
||||
@@ -363,7 +367,7 @@ char *mm_sourceslist_file(void)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Neither '%s' nor '%s' exist.\n"
|
||||
"No module repositories configured.\n",
|
||||
buf1, buf2);
|
||||
buf1, buf2);
|
||||
print_documentation();
|
||||
exit(-1);
|
||||
}
|
||||
@@ -407,8 +411,13 @@ int mm_valid_module_name(char *name)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#undef CheckNull
|
||||
#define CheckNull(x) if ((!(x)->value) || (!(*((x)->value)))) { config_error("%s:%i: missing parameter", repo_url, (x)->line_number); goto fail_mm_repo_module_config; }
|
||||
#undef CheckNull
|
||||
#define CheckNull(x) \
|
||||
if ((!(x)->value) || (!(*((x)->value)))) \
|
||||
{ \
|
||||
config_error("%s:%i: missing parameter", repo_url, (x)->line_number); \
|
||||
goto fail_mm_repo_module_config; \
|
||||
}
|
||||
|
||||
/** Parse a module { } line from a repository */
|
||||
ManagedModule *mm_repo_module_config(char *repo_url, ConfigEntry *ce)
|
||||
@@ -419,19 +428,19 @@ ManagedModule *mm_repo_module_config(char *repo_url, ConfigEntry *ce)
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%d: module { } with no name",
|
||||
repo_url, ce->line_number);
|
||||
repo_url, ce->line_number);
|
||||
goto fail_mm_repo_module_config;
|
||||
}
|
||||
if (!str_starts_with_case_sensitive(ce->value, "third/"))
|
||||
{
|
||||
config_error("%s:%d: module { } name must start with: third/",
|
||||
repo_url, ce->line_number);
|
||||
repo_url, ce->line_number);
|
||||
goto fail_mm_repo_module_config;
|
||||
}
|
||||
if (!mm_valid_module_name(ce->value))
|
||||
{
|
||||
config_error("%s:%d: module { } with illegal name: %s",
|
||||
repo_url, ce->line_number, ce->value);
|
||||
repo_url, ce->line_number, ce->value);
|
||||
goto fail_mm_repo_module_config;
|
||||
}
|
||||
safe_strdup(m->name, ce->value);
|
||||
@@ -443,60 +452,51 @@ ManagedModule *mm_repo_module_config(char *repo_url, ConfigEntry *ce)
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->source, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "sha256sum"))
|
||||
} else if (!strcmp(cep->name, "sha256sum"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->sha256sum, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "version"))
|
||||
} else if (!strcmp(cep->name, "version"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->version, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "author"))
|
||||
} else if (!strcmp(cep->name, "author"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->author, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "troubleshooting"))
|
||||
} else if (!strcmp(cep->name, "troubleshooting"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->troubleshooting, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "documentation"))
|
||||
} else if (!strcmp(cep->name, "documentation"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->documentation, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "min-unrealircd-version"))
|
||||
} else if (!strcmp(cep->name, "min-unrealircd-version"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->min_unrealircd_version, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "max-unrealircd-version"))
|
||||
} else if (!strcmp(cep->name, "max-unrealircd-version"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->max_unrealircd_version, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "compile-flags"))
|
||||
} else if (!strcmp(cep->name, "compile-flags"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->compile_flags, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "description"))
|
||||
} else if (!strcmp(cep->name, "description"))
|
||||
{
|
||||
CheckNull(cep);
|
||||
safe_strdup(m->description, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "post-install-text"))
|
||||
} else if (!strcmp(cep->name, "post-install-text"))
|
||||
{
|
||||
if (cep->items)
|
||||
{
|
||||
ConfigEntry *cepp;
|
||||
for (cepp = cep->items; cepp; cepp = cepp->next)
|
||||
addmultiline(&m->post_install_text, cepp->name);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
CheckNull(cep);
|
||||
addmultiline(&m->post_install_text, cep->value);
|
||||
}
|
||||
@@ -554,7 +554,7 @@ fail_mm_repo_module_config:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#undef CheckNull
|
||||
#undef CheckNull
|
||||
|
||||
int mm_parse_repo_db(char *url, const char *filename)
|
||||
{
|
||||
@@ -595,7 +595,7 @@ int mm_refresh_repository(void)
|
||||
|
||||
if (!file_exists(TMPDIR))
|
||||
{
|
||||
(void)mkdir(TMPDIR, S_IRUSR|S_IWUSR|S_IXUSR); /* Create the tmp dir, if it doesn't exist */
|
||||
(void)mkdir(TMPDIR, S_IRUSR | S_IWUSR | S_IXUSR); /* Create the tmp dir, if it doesn't exist */
|
||||
if (!file_exists(TMPDIR))
|
||||
{
|
||||
/* This is possible if the directory structure does not exist,
|
||||
@@ -630,7 +630,7 @@ int mm_refresh_repository(void)
|
||||
if (!str_starts_with_case_sensitive(line, "https://"))
|
||||
{
|
||||
fprintf(stderr, "ERROR in %s on line %d: URL should start with https://",
|
||||
sourceslist, linenr);
|
||||
sourceslist, linenr);
|
||||
fclose(fd);
|
||||
return 0;
|
||||
}
|
||||
@@ -660,9 +660,9 @@ int mm_refresh_repository(void)
|
||||
return success ? 1 : 0;
|
||||
}
|
||||
|
||||
#define COLUMN_STATUS 0
|
||||
#define COLUMN_NAME 1
|
||||
#define COLUMN_VERSION 2
|
||||
#define COLUMN_STATUS 0
|
||||
#define COLUMN_NAME 1
|
||||
#define COLUMN_VERSION 2
|
||||
|
||||
void mm_list_print(char *status, char *name, char *version, char *description, int largest_column[3])
|
||||
{
|
||||
@@ -710,10 +710,10 @@ int mm_check_module_compatibility(ManagedModule *m)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define MMMS_INSTALLED 0x0001
|
||||
#define MMMS_UPGRADE_AVAILABLE 0x0002
|
||||
#define MMMS_UNAVAILABLE 0x0004
|
||||
#define MMMS_LOCAL_VERSION_IS_NEWER 0x0008
|
||||
#define MMMS_INSTALLED 0x0001
|
||||
#define MMMS_UPGRADE_AVAILABLE 0x0002
|
||||
#define MMMS_UNAVAILABLE 0x0004
|
||||
#define MMMS_LOCAL_VERSION_IS_NEWER 0x0008
|
||||
|
||||
int mm_get_module_status(ManagedModule *m)
|
||||
{
|
||||
@@ -736,7 +736,7 @@ int mm_get_module_status(ManagedModule *m)
|
||||
if (our_module && our_module->version && (strnatcasecmp(m->version, our_module->version) < 0))
|
||||
{
|
||||
safe_free_managed_module(our_module);
|
||||
return MMMS_INSTALLED|MMMS_LOCAL_VERSION_IS_NEWER;
|
||||
return MMMS_INSTALLED | MMMS_LOCAL_VERSION_IS_NEWER;
|
||||
}
|
||||
|
||||
safe_free_managed_module(our_module);
|
||||
@@ -745,9 +745,9 @@ int mm_get_module_status(ManagedModule *m)
|
||||
return MMMS_INSTALLED;
|
||||
|
||||
if (!mm_check_module_compatibility(m))
|
||||
return MMMS_INSTALLED|MMMS_UNAVAILABLE;
|
||||
return MMMS_INSTALLED | MMMS_UNAVAILABLE;
|
||||
|
||||
return MMMS_INSTALLED|MMMS_UPGRADE_AVAILABLE;
|
||||
return MMMS_INSTALLED | MMMS_UPGRADE_AVAILABLE;
|
||||
}
|
||||
|
||||
char *mm_get_module_status_string(ManagedModule *m)
|
||||
@@ -759,11 +759,11 @@ char *mm_get_module_status_string(ManagedModule *m)
|
||||
return "unav";
|
||||
else if (status == MMMS_INSTALLED)
|
||||
return "inst";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_UNAVAILABLE))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_UNAVAILABLE))
|
||||
return "inst/UNAV";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_UPGRADE_AVAILABLE))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_UPGRADE_AVAILABLE))
|
||||
return "inst/UPD";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_LOCAL_VERSION_IS_NEWER))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_LOCAL_VERSION_IS_NEWER))
|
||||
return "inst/LOCAL";
|
||||
return "UNKNOWN?";
|
||||
}
|
||||
@@ -777,11 +777,11 @@ char *mm_get_module_status_string_long(ManagedModule *m)
|
||||
return "Unavailable for your UnrealIRCd version";
|
||||
else if (status == MMMS_INSTALLED)
|
||||
return "Installed and up to date";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_UNAVAILABLE))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_UNAVAILABLE))
|
||||
return "Installed, an upgrade is available but not for your UnrealIRCd version";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_UPGRADE_AVAILABLE))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_UPGRADE_AVAILABLE))
|
||||
return "Installed, upgrade available";
|
||||
else if (status == (MMMS_INSTALLED|MMMS_LOCAL_VERSION_IS_NEWER))
|
||||
else if (status == (MMMS_INSTALLED | MMMS_LOCAL_VERSION_IS_NEWER))
|
||||
return "Installed, local version is newer than online version";
|
||||
return "UNKNOWN?";
|
||||
}
|
||||
@@ -940,7 +940,6 @@ void mm_list(char *searchname)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Helper to get compile flags. Do not return NULL but "" here if none */
|
||||
const char *mm_get_compile_flags(ManagedModule *m)
|
||||
{
|
||||
@@ -953,7 +952,7 @@ const char *mm_get_compile_flags(ManagedModule *m)
|
||||
/* Simple as-is for now */
|
||||
flags = m->compile_flags;
|
||||
|
||||
unreal_add_quotes_r(flags, retbuf, sizeof(retbuf)-1);
|
||||
unreal_add_quotes_r(flags, retbuf, sizeof(retbuf) - 1);
|
||||
return retbuf;
|
||||
}
|
||||
|
||||
@@ -994,8 +993,7 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test, int upgrade)
|
||||
"cd \"%s\"; $MAKE custommodule MODULEFILE=\"%s\" EXLIBS=\"%s\"",
|
||||
BUILDDIR,
|
||||
filename_strip_suffix(basename, ".c"),
|
||||
mm_get_compile_flags(m)
|
||||
);
|
||||
mm_get_compile_flags(m));
|
||||
fd = popen(cmd, "r");
|
||||
if (!fd)
|
||||
{
|
||||
@@ -1003,7 +1001,7 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test, int upgrade)
|
||||
unlink(newpath);
|
||||
return 0;
|
||||
}
|
||||
while((fgets(buf, sizeof(buf), fd)))
|
||||
while ((fgets(buf, sizeof(buf), fd)))
|
||||
{
|
||||
printf("%s", buf);
|
||||
}
|
||||
@@ -1014,7 +1012,7 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test, int upgrade)
|
||||
/* Remove the XXXXXXX.modname.c file */
|
||||
unlink(newpath);
|
||||
/* Remove the XXXXXXX.modname.so file */
|
||||
newpath[strlen(newpath)-2] = '\0'; // cut off .c
|
||||
newpath[strlen(newpath) - 2] = '\0'; // cut off .c
|
||||
strlcat(newpath, ".so", sizeof(newpath));
|
||||
unlink(newpath);
|
||||
}
|
||||
@@ -1026,7 +1024,7 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test, int upgrade)
|
||||
if (m->author && m->troubleshooting)
|
||||
{
|
||||
fprintf(stderr, "You are suggested to contact the author (%s) of this module %s:\n%s\n",
|
||||
m->author, m->name, m->troubleshooting);
|
||||
m->author, m->name, m->troubleshooting);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1071,7 +1069,8 @@ int mm_compile_all(int argc, char *args[])
|
||||
m->unmanaged = 1;
|
||||
n = mm_compile(m, NULL, 0, 0);
|
||||
safe_free_managed_module(m);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
n = mm_compile(m, NULL, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1117,10 +1116,10 @@ int mm_install_module(ManagedModule *m)
|
||||
fprintf(stderr, "ERROR: SHA256 Checksum mismatch\n"
|
||||
"Expected (value in repository list): %s\n"
|
||||
"Received (value of downloaded file): %s\n",
|
||||
m->sha256sum, sha256);
|
||||
m->sha256sum, sha256);
|
||||
fprintf(stderr, "Fatal error encountered, see above. Try running the command again in 5-10 minutes.\n"
|
||||
"If the issue persists, contact the repository manager of %s\n",
|
||||
m->repo_url);
|
||||
m->repo_url);
|
||||
return 0;
|
||||
}
|
||||
if (!mm_compile(m, tmpfile, 1, 1))
|
||||
@@ -1223,9 +1222,9 @@ int mm_install(int argc, char *args[], int upgrade)
|
||||
fprintf(stderr, "ERROR: Module '%s' exists, but is not compatible with your UnrealIRCd version:\n"
|
||||
"Your UnrealIRCd version : %s\n"
|
||||
"Minimum version required : %s\n",
|
||||
name,
|
||||
VERSIONONLY,
|
||||
m->min_unrealircd_version);
|
||||
name,
|
||||
VERSIONONLY,
|
||||
m->min_unrealircd_version);
|
||||
if (m->max_unrealircd_version)
|
||||
fprintf(stderr, "Maximum version : %s\n", m->max_unrealircd_version);
|
||||
return 0;
|
||||
@@ -1236,7 +1235,7 @@ int mm_install(int argc, char *args[], int upgrade)
|
||||
printf("Module %s is the latest version, no upgrade needed\n", m->name);
|
||||
return 1;
|
||||
}
|
||||
if (upgrade && (status == (MMMS_INSTALLED|MMMS_LOCAL_VERSION_IS_NEWER)))
|
||||
if (upgrade && (status == (MMMS_INSTALLED | MMMS_LOCAL_VERSION_IS_NEWER)))
|
||||
{
|
||||
/* If updating, and we are already on latest version, then don't upgrade */
|
||||
printf("Module %s: local version is newer than the online version, not upgrading.\n", m->name);
|
||||
@@ -1252,7 +1251,8 @@ int mm_install(int argc, char *args[], int upgrade)
|
||||
for (l = m->post_install_text; l; l = l->next)
|
||||
printf(" %s\n", l->line);
|
||||
printf("---\n");
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
printf("Don't forget to add a 'loadmodule' line for the module and rehash\n");
|
||||
}
|
||||
return 1;
|
||||
@@ -1309,19 +1309,17 @@ void mm_upgrade(int argc, char *args[])
|
||||
for (m = managed_modules; m; m = m->next)
|
||||
{
|
||||
int status = mm_get_module_status(m);
|
||||
if (status == (MMMS_INSTALLED|MMMS_UPGRADE_AVAILABLE))
|
||||
if (status == (MMMS_INSTALLED | MMMS_UPGRADE_AVAILABLE))
|
||||
{
|
||||
args[1] = m->name;
|
||||
if (mm_install(1, args, 1))
|
||||
upgraded++;
|
||||
else
|
||||
failed++;
|
||||
} else
|
||||
if ((status == MMMS_INSTALLED) || (status == (MMMS_INSTALLED|MMMS_LOCAL_VERSION_IS_NEWER)))
|
||||
} else if ((status == MMMS_INSTALLED) || (status == (MMMS_INSTALLED | MMMS_LOCAL_VERSION_IS_NEWER)))
|
||||
{
|
||||
uptodate_already++;
|
||||
} else
|
||||
if (status == (MMMS_INSTALLED|MMMS_UNAVAILABLE))
|
||||
} else if (status == (MMMS_INSTALLED | MMMS_UNAVAILABLE))
|
||||
{
|
||||
update_unavailable++;
|
||||
}
|
||||
@@ -1334,10 +1332,11 @@ void mm_upgrade(int argc, char *args[])
|
||||
if (failed)
|
||||
{
|
||||
printf("There was %d FAILED module upgrade. %d module(s) upgraded, %d already up-to-date\n",
|
||||
failed, upgraded, uptodate_already);
|
||||
} else {
|
||||
failed, upgraded, uptodate_already);
|
||||
} else
|
||||
{
|
||||
printf("All actions were successful. %d module(s) upgraded, %d already up-to-date\n",
|
||||
upgraded, uptodate_already);
|
||||
upgraded, uptodate_already);
|
||||
}
|
||||
if (update_unavailable)
|
||||
printf("%d module(s) have updates but not for your UnrealIRCd version\n", update_unavailable);
|
||||
@@ -1468,7 +1467,7 @@ void mm_generate_repository(int argc, char *args[])
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((strlen(urlbasepath) < 2) || (urlbasepath[strlen(urlbasepath)-1] != '/'))
|
||||
if ((strlen(urlbasepath) < 2) || (urlbasepath[strlen(urlbasepath) - 1] != '/'))
|
||||
{
|
||||
fprintf(stderr, "Error: the URL base path must end with a slash\n");
|
||||
mm_generate_repository_usage();
|
||||
@@ -1602,16 +1601,17 @@ void mm_self_test(void)
|
||||
if (!file_exists(BUILDDIR))
|
||||
{
|
||||
fprintf(stderr, "ERROR: Directory %s does not exist.\n"
|
||||
"The UnrealIRCd source is required for the module manager to work!\n",
|
||||
BUILDDIR);
|
||||
"The UnrealIRCd source is required for the module manager to work!\n",
|
||||
BUILDDIR);
|
||||
exit(-1);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
snprintf(name, sizeof(name), "%s/src/modules/third/Makefile", BUILDDIR);
|
||||
if (!file_exists(name))
|
||||
{
|
||||
fprintf(stderr, "ERROR: Directory %s exists, but your UnrealIRCd is not compiled yet.\n"
|
||||
"You must compile your UnrealIRCd first (run './Config', then 'make install')\n",
|
||||
BUILDDIR);
|
||||
"You must compile your UnrealIRCd first (run './Config', then 'make install')\n",
|
||||
BUILDDIR);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@@ -1633,18 +1633,15 @@ void modulemanager(int argc, char *args[])
|
||||
{
|
||||
mm_uninstall(argc, args);
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcasecmp(args[0], "generate-repository"))
|
||||
} else if (!strcasecmp(args[0], "generate-repository"))
|
||||
{
|
||||
mm_generate_repository(argc, args);
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcasecmp(args[0], "parse-c-file"))
|
||||
} else if (!strcasecmp(args[0], "parse-c-file"))
|
||||
{
|
||||
mm_parse_c_file(argc, args);
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcasecmp(args[0], "compile-all"))
|
||||
} else if (!strcasecmp(args[0], "compile-all"))
|
||||
{
|
||||
mm_compile_all(argc, args);
|
||||
exit(0);
|
||||
@@ -1678,8 +1675,7 @@ void modulemanager(int argc, char *args[])
|
||||
fprintf(stderr, "All actions were successful.\n");
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
else if (!strcasecmp(args[0], "upgrade"))
|
||||
} else if (!strcasecmp(args[0], "upgrade"))
|
||||
mm_upgrade(argc, args);
|
||||
else
|
||||
mm_usage();
|
||||
|
||||
+210
-187
@@ -23,32 +23,32 @@
|
||||
#define UNREALCORE
|
||||
#include "unrealircd.h"
|
||||
#ifdef _WIN32
|
||||
#define RTLD_NOW 0
|
||||
#define RTLD_NOW 0
|
||||
#elif defined(HPUX)
|
||||
#include <dl.h>
|
||||
#define RTLD_NOW BIND_IMMEDIATE
|
||||
#include <dl.h>
|
||||
#define RTLD_NOW BIND_IMMEDIATE
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#ifndef RTLD_NOW
|
||||
#define RTLD_NOW RTLD_LAZY
|
||||
#define RTLD_NOW RTLD_LAZY
|
||||
#endif
|
||||
#include "modversion.h"
|
||||
|
||||
Hook *Hooks[MAXHOOKTYPES];
|
||||
Hooktype Hooktypes[MAXCUSTOMHOOKS];
|
||||
Callback *Callbacks[MAXCALLBACKS]; /* Callback objects for modules, used for rehashing etc (can be multiple) */
|
||||
Callback *RCallbacks[MAXCALLBACKS]; /* 'Real' callback function, used for callback function calls */
|
||||
MODVAR Module *Modules = NULL;
|
||||
MODVAR Versionflag *Versionflags = NULL;
|
||||
Hook *Hooks[MAXHOOKTYPES];
|
||||
Hooktype Hooktypes[MAXCUSTOMHOOKS];
|
||||
Callback *Callbacks[MAXCALLBACKS]; /* Callback objects for modules, used for rehashing etc (can be multiple) */
|
||||
Callback *RCallbacks[MAXCALLBACKS]; /* 'Real' callback function, used for callback function calls */
|
||||
MODVAR Module *Modules = NULL;
|
||||
MODVAR Versionflag *Versionflags = NULL;
|
||||
|
||||
Module *Module_make(ModuleHeader *header,
|
||||
Module *Module_make(ModuleHeader *header,
|
||||
#ifdef _WIN32
|
||||
HMODULE mod
|
||||
HMODULE mod
|
||||
#else
|
||||
void *mod
|
||||
void *mod
|
||||
#endif
|
||||
);
|
||||
);
|
||||
|
||||
#ifdef UNDERSCORE
|
||||
/* dlsym for OpenBSD */
|
||||
@@ -79,7 +79,7 @@ void deletetmp(const char *path)
|
||||
|
||||
void DeleteTempModules(void)
|
||||
{
|
||||
char tempbuf[PATH_MAX+1];
|
||||
char tempbuf[PATH_MAX + 1];
|
||||
#ifndef _WIN32
|
||||
DIR *fd = opendir(TMPDIR);
|
||||
struct dirent *dir;
|
||||
@@ -87,10 +87,10 @@ void DeleteTempModules(void)
|
||||
if (!fd) /* Ouch.. this is NOT good!! */
|
||||
{
|
||||
config_error("Unable to open temp directory %s: %s, please create one with the appropriate permissions",
|
||||
TMPDIR, strerror(errno));
|
||||
TMPDIR, strerror(errno));
|
||||
if (!loop.booted)
|
||||
exit(7);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
while ((dir = readdir(fd)))
|
||||
@@ -108,9 +108,9 @@ void DeleteTempModules(void)
|
||||
#else
|
||||
WIN32_FIND_DATA hData;
|
||||
HANDLE hFile;
|
||||
|
||||
|
||||
snprintf(tempbuf, sizeof(tempbuf), "%s/*", TMPDIR);
|
||||
|
||||
|
||||
hFile = FindFirstFile(tempbuf, &hData);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -128,13 +128,13 @@ void DeleteTempModules(void)
|
||||
deletetmp(tempbuf);
|
||||
}
|
||||
FindClose(hFile);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
Module *Module_Find(const char *name)
|
||||
{
|
||||
Module *p;
|
||||
|
||||
|
||||
for (p = Modules; p; p = p->next)
|
||||
{
|
||||
if (!(p->options & MOD_OPT_PERM) &&
|
||||
@@ -146,7 +146,6 @@ Module *Module_Find(const char *name)
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
int parse_modsys_version(const char *version)
|
||||
@@ -165,11 +164,11 @@ void make_compiler_string(char *buf, size_t buflen, unsigned int ver)
|
||||
strlcpy(buf, "0", buflen);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
maj = ver >> 16;
|
||||
min = (ver >> 8) & 0xff;
|
||||
plevel = ver & 0xff;
|
||||
|
||||
|
||||
if (plevel == 0)
|
||||
snprintf(buf, buflen, "%d.%d", maj, min);
|
||||
else
|
||||
@@ -190,7 +189,8 @@ const char *Module_TransformPath(const char *path_)
|
||||
if ((*path_ != '/') && (*path_ != '\\') && !(*path_ && (path_[1] == ':')))
|
||||
{
|
||||
snprintf(path, sizeof(path), "%s/%s", MODULESDIR, path_);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
strlcpy(path, path_, sizeof(path));
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ static const char *validate_mod_header(const char *relpath, ModuleHeader *mod_he
|
||||
if (strcmp(mod_header->name, relpath))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "Module has path '%s' but uses name '%s' in MOD_HEADER. These should be the same!",
|
||||
relpath, mod_header->name);
|
||||
relpath, mod_header->name);
|
||||
return buf;
|
||||
}
|
||||
/* This too, just to be sure.. we never ever want other characters
|
||||
@@ -309,21 +309,21 @@ const char *is_module_deprecated(const char *name)
|
||||
const char *Module_Create(const char *path_)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HMODULE Mod;
|
||||
HMODULE Mod;
|
||||
#else /* _WIN32 */
|
||||
void *Mod;
|
||||
void *Mod;
|
||||
#endif /* _WIN32 */
|
||||
int (*Mod_Test)();
|
||||
int (*Mod_Init)();
|
||||
int (*Mod_Load)();
|
||||
int (*Mod_Unload)();
|
||||
char *Mod_Version;
|
||||
static char errorbuf[1024];
|
||||
const char *path, *relpath, *tmppath;
|
||||
ModuleHeader *mod_header = NULL;
|
||||
int ret = 0;
|
||||
const char *reterr;
|
||||
Module *mod = NULL, **Mod_Handle = NULL;
|
||||
int (*Mod_Test)();
|
||||
int (*Mod_Init)();
|
||||
int (*Mod_Load)();
|
||||
int (*Mod_Unload)();
|
||||
char *Mod_Version;
|
||||
static char errorbuf[1024];
|
||||
const char *path, *relpath, *tmppath;
|
||||
ModuleHeader *mod_header = NULL;
|
||||
int ret = 0;
|
||||
const char *reterr;
|
||||
Module *mod = NULL, **Mod_Handle = NULL;
|
||||
char *expectedmodversion = our_mod_version;
|
||||
long modsys_ver = 0;
|
||||
|
||||
@@ -359,7 +359,8 @@ const char *Module_Create(const char *path_)
|
||||
{
|
||||
/* For './unrealircd configtest' we don't have to do any copying and shit */
|
||||
tmppath = path;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
tmppath = unreal_mktemp(TMPDIR, unreal_getmodfilename(path));
|
||||
if (!tmppath)
|
||||
return "Unable to create temporary file!";
|
||||
@@ -393,7 +394,7 @@ const char *Module_Create(const char *path_)
|
||||
if (!Mod_Version)
|
||||
{
|
||||
snprintf(errorbuf, sizeof(errorbuf),
|
||||
"Module is lacking Mod_Version. Perhaps a very old one you forgot to recompile?");
|
||||
"Module is lacking Mod_Version. Perhaps a very old one you forgot to recompile?");
|
||||
irc_dlclose(Mod);
|
||||
deletetmp(tmppath);
|
||||
return errorbuf;
|
||||
@@ -414,20 +415,20 @@ const char *Module_Create(const char *path_)
|
||||
if (!(modsys_ver = parse_modsys_version(mod_header->modversion)))
|
||||
{
|
||||
snprintf(errorbuf, 1023, "Unsupported module system version '%s'",
|
||||
mod_header->modversion);
|
||||
mod_header->modversion);
|
||||
irc_dlclose(Mod);
|
||||
deletetmp(tmppath);
|
||||
return(errorbuf);
|
||||
return (errorbuf);
|
||||
}
|
||||
if ((reterr = validate_mod_header(relpath, mod_header)))
|
||||
{
|
||||
irc_dlclose(Mod);
|
||||
deletetmp(tmppath);
|
||||
return(reterr);
|
||||
return (reterr);
|
||||
}
|
||||
if (Module_Find(mod_header->name))
|
||||
{
|
||||
irc_dlclose(Mod);
|
||||
irc_dlclose(Mod);
|
||||
deletetmp(tmppath);
|
||||
return (NULL);
|
||||
}
|
||||
@@ -452,7 +453,7 @@ const char *Module_Create(const char *path_)
|
||||
if (!Mod_Load)
|
||||
{
|
||||
Module_free(mod);
|
||||
return ("Unable to locate Mod_Load");
|
||||
return ("Unable to locate Mod_Load");
|
||||
}
|
||||
irc_dlsym(Mod, "Mod_Handle", Mod_Handle);
|
||||
if (Mod_Handle)
|
||||
@@ -470,10 +471,9 @@ const char *Module_Create(const char *path_)
|
||||
return (errorbuf);
|
||||
}
|
||||
}
|
||||
mod->flags = MODFLAG_TESTING;
|
||||
mod->flags = MODFLAG_TESTING;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
/* Return the error .. */
|
||||
return irc_dlerror();
|
||||
@@ -490,16 +490,16 @@ void Module_DelayChildren(Module *m)
|
||||
}
|
||||
}
|
||||
|
||||
Module *Module_make(ModuleHeader *header,
|
||||
Module *Module_make(ModuleHeader *header,
|
||||
#ifdef _WIN32
|
||||
HMODULE mod
|
||||
HMODULE mod
|
||||
#else
|
||||
void *mod
|
||||
void *mod
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
Module *modp = NULL;
|
||||
|
||||
|
||||
modp = safe_alloc(sizeof(Module));
|
||||
modp->header = header;
|
||||
modp->dll = mod;
|
||||
@@ -510,13 +510,13 @@ Module *Module_make(ModuleHeader *header,
|
||||
modp->modinfo.size = sizeof(ModuleInfo);
|
||||
modp->modinfo.module_load = 0;
|
||||
modp->modinfo.handle = modp;
|
||||
|
||||
|
||||
return (modp);
|
||||
}
|
||||
|
||||
void Init_all_testing_modules(void)
|
||||
{
|
||||
|
||||
|
||||
Module *mi, *next;
|
||||
int ret;
|
||||
iFP Mod_Init;
|
||||
@@ -526,76 +526,77 @@ void Init_all_testing_modules(void)
|
||||
if (!(mi->flags & MODFLAG_TESTING))
|
||||
continue;
|
||||
irc_dlsym(mi->dll, "Mod_Init", Mod_Init);
|
||||
if ((ret = (*Mod_Init)(&mi->modinfo)) < MOD_SUCCESS) {
|
||||
if ((ret = (*Mod_Init)(&mi->modinfo)) < MOD_SUCCESS)
|
||||
{
|
||||
config_error("Error loading %s: Mod_Init returned %i",
|
||||
mi->header->name, ret);
|
||||
mi->header->name, ret);
|
||||
Module_free(mi);
|
||||
continue;
|
||||
}
|
||||
mi->flags = MODFLAG_INIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FreeModObj(ModuleObject *obj, Module *m)
|
||||
{
|
||||
if (obj->type == MOBJ_EVENT) {
|
||||
if (obj->type == MOBJ_EVENT)
|
||||
{
|
||||
EventDel(obj->object.event);
|
||||
}
|
||||
else if (obj->type == MOBJ_HOOK) {
|
||||
} else if (obj->type == MOBJ_HOOK)
|
||||
{
|
||||
HookDel(obj->object.hook);
|
||||
}
|
||||
else if (obj->type == MOBJ_COMMAND) {
|
||||
} else if (obj->type == MOBJ_COMMAND)
|
||||
{
|
||||
CommandDel(obj->object.command);
|
||||
}
|
||||
else if (obj->type == MOBJ_HOOKTYPE) {
|
||||
} else if (obj->type == MOBJ_HOOKTYPE)
|
||||
{
|
||||
//HooktypeDel(obj->object.hooktype, m); -- reinstate if we audited this code
|
||||
}
|
||||
else if (obj->type == MOBJ_VERSIONFLAG) {
|
||||
} else if (obj->type == MOBJ_VERSIONFLAG)
|
||||
{
|
||||
VersionflagDel(obj->object.versionflag, m);
|
||||
}
|
||||
else if (obj->type == MOBJ_UMODE) {
|
||||
} else if (obj->type == MOBJ_UMODE)
|
||||
{
|
||||
UmodeDel(obj->object.umode);
|
||||
}
|
||||
else if (obj->type == MOBJ_CMODE) {
|
||||
} else if (obj->type == MOBJ_CMODE)
|
||||
{
|
||||
CmodeDel(obj->object.cmode);
|
||||
}
|
||||
else if (obj->type == MOBJ_COMMANDOVERRIDE) {
|
||||
} else if (obj->type == MOBJ_COMMANDOVERRIDE)
|
||||
{
|
||||
CommandOverrideDel(obj->object.cmdoverride);
|
||||
}
|
||||
else if (obj->type == MOBJ_EXTBAN) {
|
||||
} else if (obj->type == MOBJ_EXTBAN)
|
||||
{
|
||||
ExtbanDel(obj->object.extban);
|
||||
}
|
||||
else if (obj->type == MOBJ_CALLBACK) {
|
||||
} else if (obj->type == MOBJ_CALLBACK)
|
||||
{
|
||||
CallbackDel(obj->object.callback);
|
||||
}
|
||||
else if (obj->type == MOBJ_EFUNCTION) {
|
||||
} else if (obj->type == MOBJ_EFUNCTION)
|
||||
{
|
||||
EfunctionDel(obj->object.efunction);
|
||||
}
|
||||
else if (obj->type == MOBJ_ISUPPORT) {
|
||||
} else if (obj->type == MOBJ_ISUPPORT)
|
||||
{
|
||||
ISupportDel(obj->object.isupport);
|
||||
}
|
||||
else if (obj->type == MOBJ_MODDATA) {
|
||||
} else if (obj->type == MOBJ_MODDATA)
|
||||
{
|
||||
ModDataDel(obj->object.moddata);
|
||||
}
|
||||
else if (obj->type == MOBJ_VALIDATOR) {
|
||||
} else if (obj->type == MOBJ_VALIDATOR)
|
||||
{
|
||||
OperClassValidatorDel(obj->object.validator);
|
||||
}
|
||||
else if (obj->type == MOBJ_CLICAP) {
|
||||
} else if (obj->type == MOBJ_CLICAP)
|
||||
{
|
||||
ClientCapabilityDel(obj->object.clicap);
|
||||
}
|
||||
else if (obj->type == MOBJ_MTAG) {
|
||||
} else if (obj->type == MOBJ_MTAG)
|
||||
{
|
||||
MessageTagHandlerDel(obj->object.mtag);
|
||||
}
|
||||
else if (obj->type == MOBJ_HISTORY_BACKEND) {
|
||||
} else if (obj->type == MOBJ_HISTORY_BACKEND)
|
||||
{
|
||||
HistoryBackendDel(obj->object.history_backend);
|
||||
}
|
||||
else if (obj->type == MOBJ_RPC) {
|
||||
} else if (obj->type == MOBJ_RPC)
|
||||
{
|
||||
RPCHandlerDel(obj->object.rpc);
|
||||
}
|
||||
else if (obj->type == MOBJ_API_CALLBACK) {
|
||||
} else if (obj->type == MOBJ_API_CALLBACK)
|
||||
{
|
||||
APICallbackDel(obj->object.apicallback);
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_FATAL, "module", "FREEMODOBJ_UNKNOWN_TYPE", NULL,
|
||||
"[BUG] FreeModObj() called for unknown object (type $type)",
|
||||
@@ -627,17 +628,18 @@ void Unload_all_loaded_modules(void)
|
||||
Module_DelayChildren(mi);
|
||||
}
|
||||
}
|
||||
for (objs = mi->objects; objs; objs = objnext) {
|
||||
for (objs = mi->objects; objs; objs = objnext)
|
||||
{
|
||||
objnext = objs->next;
|
||||
FreeModObj(objs, mi);
|
||||
}
|
||||
for (child = mi->children; child; child = childnext)
|
||||
{
|
||||
childnext = child->next;
|
||||
DelListItem(child,mi->children);
|
||||
DelListItem(child, mi->children);
|
||||
safe_free(child);
|
||||
}
|
||||
DelListItem(mi,Modules);
|
||||
DelListItem(mi, Modules);
|
||||
irc_dlclose(mi->dll);
|
||||
deletetmp(mi->tmp_file);
|
||||
safe_free(mi->tmp_file);
|
||||
@@ -657,17 +659,18 @@ void Unload_all_testing_modules(void)
|
||||
next = mi->next;
|
||||
if (!(mi->flags & MODFLAG_TESTING))
|
||||
continue;
|
||||
for (objs = mi->objects; objs; objs = objnext) {
|
||||
for (objs = mi->objects; objs; objs = objnext)
|
||||
{
|
||||
objnext = objs->next;
|
||||
FreeModObj(objs, mi);
|
||||
}
|
||||
for (child = mi->children; child; child = childnext)
|
||||
{
|
||||
childnext = child->next;
|
||||
DelListItem(child,mi->children);
|
||||
DelListItem(child, mi->children);
|
||||
safe_free(child);
|
||||
}
|
||||
DelListItem(mi,Modules);
|
||||
DelListItem(mi, Modules);
|
||||
irc_dlclose(mi->dll);
|
||||
deletetmp(mi->tmp_file);
|
||||
safe_free(mi->tmp_file);
|
||||
@@ -680,7 +683,7 @@ void Unload_all_testing_modules(void)
|
||||
* Returns -1 if you cannot unload due to children still alive
|
||||
* Returns 1 if successful
|
||||
*/
|
||||
int Module_free(Module *mod)
|
||||
int Module_free(Module *mod)
|
||||
{
|
||||
Module *p;
|
||||
ModuleChild *cp, *cpnext;
|
||||
@@ -691,7 +694,8 @@ int Module_free(Module *mod)
|
||||
{
|
||||
Module_Unload(cp->child->header->name);
|
||||
}
|
||||
for (objs = mod->objects; objs; objs = next) {
|
||||
for (objs = mod->objects; objs; objs = next)
|
||||
{
|
||||
next = objs->next;
|
||||
FreeModObj(objs, mod);
|
||||
}
|
||||
@@ -728,15 +732,15 @@ int Module_free(Module *mod)
|
||||
int Module_Unload(const char *name)
|
||||
{
|
||||
Module *m;
|
||||
int (*Mod_Unload)();
|
||||
int ret;
|
||||
int (*Mod_Unload)();
|
||||
int ret;
|
||||
for (m = Modules; m; m = m->next)
|
||||
{
|
||||
if (!strcmp(m->header->name, name))
|
||||
{
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!m)
|
||||
return -1;
|
||||
irc_dlsym(m->dll, "Mod_Unload", Mod_Unload);
|
||||
@@ -763,9 +767,9 @@ int Module_Unload(const char *name)
|
||||
|
||||
void module_loadall(void)
|
||||
{
|
||||
iFP fp;
|
||||
iFP fp;
|
||||
Module *mi, *next;
|
||||
|
||||
|
||||
loop.config_status = CONFIG_STATUS_LOAD;
|
||||
|
||||
/* Run through all modules and check for module load */
|
||||
@@ -780,28 +784,27 @@ void module_loadall(void)
|
||||
{
|
||||
config_status("cannot load module %s", mi->header->name);
|
||||
Module_free(mi);
|
||||
}
|
||||
else
|
||||
} else
|
||||
mi->flags = MODFLAG_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
int Module_IsAlreadyChild(Module *parent, Module *child)
|
||||
int Module_IsAlreadyChild(Module *parent, Module *child)
|
||||
{
|
||||
ModuleChild *mcp;
|
||||
|
||||
|
||||
for (mcp = parent->children; mcp; mcp = mcp->next)
|
||||
{
|
||||
if (mcp->child == child)
|
||||
if (mcp->child == child)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Module_AddAsChild(Module *parent, Module *child)
|
||||
void Module_AddAsChild(Module *parent, Module *child)
|
||||
{
|
||||
ModuleChild *childp = NULL;
|
||||
|
||||
ModuleChild *childp = NULL;
|
||||
|
||||
childp = safe_alloc(sizeof(ModuleChild));
|
||||
childp->child = child;
|
||||
AddListItem(childp, parent->children);
|
||||
@@ -856,31 +859,31 @@ CMD_FUNC(cmd_module)
|
||||
strlcat(tmp, "[PERM] ", sizeof(tmp));
|
||||
if (!(mi->options & MOD_OPT_OFFICIAL))
|
||||
strlcat(tmp, "[3RD] ", sizeof(tmp));
|
||||
if (!ValidatePermissionsForPath("server:module",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:module", client, NULL, NULL, NULL))
|
||||
sendtxtnumeric(client, "*** %s - %s - by %s %s",
|
||||
mi->header->name,
|
||||
mi->header->description,
|
||||
mi->header->author,
|
||||
mi->options & MOD_OPT_OFFICIAL ? "" : "[3RD]");
|
||||
mi->header->name,
|
||||
mi->header->description,
|
||||
mi->header->author,
|
||||
mi->options & MOD_OPT_OFFICIAL ? "" : "[3RD]");
|
||||
else
|
||||
sendtxtnumeric(client, "*** %s %s - %s - by %s %s",
|
||||
mi->header->name,
|
||||
mi->header->version,
|
||||
mi->header->description,
|
||||
mi->header->author,
|
||||
tmp);
|
||||
mi->header->name,
|
||||
mi->header->version,
|
||||
mi->header->description,
|
||||
mi->header->author,
|
||||
tmp);
|
||||
}
|
||||
|
||||
sendtxtnumeric(client, "End of module list");
|
||||
|
||||
if (!ValidatePermissionsForPath("server:module",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:module", client, NULL, NULL, NULL))
|
||||
return;
|
||||
|
||||
/* The rest are extra details (oper-only)... */
|
||||
|
||||
tmp[0] = '\0';
|
||||
p = tmp;
|
||||
for (i=0; i < MAXHOOKTYPES; i++)
|
||||
for (i = 0; i < MAXHOOKTYPES; i++)
|
||||
{
|
||||
if (!Hooks[i])
|
||||
continue;
|
||||
@@ -897,14 +900,14 @@ CMD_FUNC(cmd_module)
|
||||
|
||||
tmp[0] = '\0';
|
||||
p = tmp;
|
||||
for (i=0; i < 256; i++)
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
for (mptr = CommandHash[i]; mptr; mptr = mptr->next)
|
||||
if (mptr->overriders)
|
||||
{
|
||||
ircsnprintf(p, sizeof(tmp)-strlen(tmp), "%s ", mptr->cmd);
|
||||
ircsnprintf(p, sizeof(tmp) - strlen(tmp), "%s ", mptr->cmd);
|
||||
p += strlen(p);
|
||||
if (p > tmp+380)
|
||||
if (p > tmp + 380)
|
||||
{
|
||||
sendtxtnumeric(client, "Override: %s", tmp);
|
||||
tmp[0] = '\0';
|
||||
@@ -917,9 +920,11 @@ CMD_FUNC(cmd_module)
|
||||
moddatatype_dump(client);
|
||||
}
|
||||
|
||||
Hooktype *HooktypeFind(const char *string) {
|
||||
Hooktype *HooktypeFind(const char *string)
|
||||
{
|
||||
Hooktype *hooktype;
|
||||
for (hooktype = Hooktypes; hooktype->string ;hooktype++) {
|
||||
for (hooktype = Hooktypes; hooktype->string; hooktype++)
|
||||
{
|
||||
if (!strcasecmp(hooktype->string, string))
|
||||
return hooktype;
|
||||
}
|
||||
@@ -949,7 +954,8 @@ Versionflag *VersionflagAdd(Module *module, char flag)
|
||||
if ((vflag = VersionflagFind(flag)))
|
||||
{
|
||||
ModuleChild *child;
|
||||
for (child = vflag->parents; child; child = child->next) {
|
||||
for (child = vflag->parents; child; child = child->next)
|
||||
{
|
||||
if (child->child == module)
|
||||
break;
|
||||
}
|
||||
@@ -957,7 +963,8 @@ Versionflag *VersionflagAdd(Module *module, char flag)
|
||||
{
|
||||
parent = safe_alloc(sizeof(ModuleChild));
|
||||
parent->child = module;
|
||||
if (module) {
|
||||
if (module)
|
||||
{
|
||||
ModuleObject *vflagobj;
|
||||
vflagobj = safe_alloc(sizeof(ModuleObject));
|
||||
vflagobj->type = MOBJ_VERSIONFLAG;
|
||||
@@ -965,7 +972,7 @@ Versionflag *VersionflagAdd(Module *module, char flag)
|
||||
AddListItem(vflagobj, module->objects);
|
||||
module->errorcode = MODERR_NOERROR;
|
||||
}
|
||||
AddListItem(parent,vflag->parents);
|
||||
AddListItem(parent, vflag->parents);
|
||||
}
|
||||
return vflag;
|
||||
}
|
||||
@@ -983,11 +990,11 @@ Versionflag *VersionflagAdd(Module *module, char flag)
|
||||
module->errorcode = MODERR_NOERROR;
|
||||
}
|
||||
flag_add(flag);
|
||||
AddListItem(parent,vflag->parents);
|
||||
AddListItem(parent, vflag->parents);
|
||||
AddListItem(vflag, Versionflags);
|
||||
return vflag;
|
||||
}
|
||||
|
||||
|
||||
/** Delete a version flag.
|
||||
* @param vflag The version flag to delete
|
||||
* @param module The module that owns this version flag
|
||||
@@ -1004,7 +1011,7 @@ void VersionflagDel(Versionflag *vflag, Module *module)
|
||||
{
|
||||
if (owner->child == module)
|
||||
{
|
||||
DelListItem(owner,vflag->parents);
|
||||
DelListItem(owner, vflag->parents);
|
||||
safe_free(owner);
|
||||
break;
|
||||
}
|
||||
@@ -1012,9 +1019,11 @@ void VersionflagDel(Versionflag *vflag, Module *module)
|
||||
if (module)
|
||||
{
|
||||
ModuleObject *objs;
|
||||
for (objs = module->objects; objs; objs = objs->next) {
|
||||
if (objs->type == MOBJ_VERSIONFLAG && objs->object.versionflag == vflag) {
|
||||
DelListItem(objs,module->objects);
|
||||
for (objs = module->objects; objs; objs = objs->next)
|
||||
{
|
||||
if (objs->type == MOBJ_VERSIONFLAG && objs->object.versionflag == vflag)
|
||||
{
|
||||
DelListItem(objs, module->objects);
|
||||
safe_free(objs);
|
||||
break;
|
||||
}
|
||||
@@ -1031,8 +1040,8 @@ void VersionflagDel(Versionflag *vflag, Module *module)
|
||||
Hook *HookAddMain(Module *module, int hooktype, int priority, int (*func)(), void (*vfunc)(), char *(*stringfunc)(), const char *(*conststringfunc)())
|
||||
{
|
||||
Hook *p;
|
||||
|
||||
p = (Hook *) safe_alloc(sizeof(Hook));
|
||||
|
||||
p = (Hook *)safe_alloc(sizeof(Hook));
|
||||
if (func)
|
||||
p->func.intfunc = func;
|
||||
if (vfunc)
|
||||
@@ -1045,14 +1054,15 @@ Hook *HookAddMain(Module *module, int hooktype, int priority, int (*func)(), voi
|
||||
p->owner = module;
|
||||
p->priority = priority;
|
||||
|
||||
if (module) {
|
||||
if (module)
|
||||
{
|
||||
ModuleObject *hookobj = (ModuleObject *)safe_alloc(sizeof(ModuleObject));
|
||||
hookobj->object.hook = p;
|
||||
hookobj->type = MOBJ_HOOK;
|
||||
AddListItem(hookobj, module->objects);
|
||||
module->errorcode = MODERR_NOERROR;
|
||||
}
|
||||
|
||||
|
||||
AddListItemPrio(p, Hooks[hooktype], p->priority);
|
||||
|
||||
return p;
|
||||
@@ -1067,14 +1077,19 @@ Hook *HookAddMain(Module *module, int hooktype, int priority, int (*func)(), voi
|
||||
Hook *HookDel(Hook *hook)
|
||||
{
|
||||
Hook *p, *q;
|
||||
for (p = Hooks[hook->type]; p; p = p->next) {
|
||||
if (p == hook) {
|
||||
for (p = Hooks[hook->type]; p; p = p->next)
|
||||
{
|
||||
if (p == hook)
|
||||
{
|
||||
q = p->next;
|
||||
DelListItem(p, Hooks[hook->type]);
|
||||
if (p->owner) {
|
||||
if (p->owner)
|
||||
{
|
||||
ModuleObject *hookobj;
|
||||
for (hookobj = p->owner->objects; hookobj; hookobj = hookobj->next) {
|
||||
if (hookobj->type == MOBJ_HOOK && hookobj->object.hook == p) {
|
||||
for (hookobj = p->owner->objects; hookobj; hookobj = hookobj->next)
|
||||
{
|
||||
if (hookobj->type == MOBJ_HOOK && hookobj->object.hook == p)
|
||||
{
|
||||
DelListItem(hookobj, hook->owner->objects);
|
||||
safe_free(hookobj);
|
||||
break;
|
||||
@@ -1090,13 +1105,13 @@ Hook *HookDel(Hook *hook)
|
||||
|
||||
static int num_callbacks(int cbtype)
|
||||
{
|
||||
Callback *e;
|
||||
int cnt = 0;
|
||||
Callback *e;
|
||||
int cnt = 0;
|
||||
|
||||
for (e = Callbacks[cbtype]; e; e = e->next)
|
||||
if (!e->willberemoved)
|
||||
cnt++;
|
||||
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@@ -1116,14 +1131,14 @@ int cnt = 0;
|
||||
Callback *CallbackAddMain(Module *module, int cbtype, int (*func)(), void (*vfunc)(), void *(*pvfunc)(), char *(*stringfunc)(), const char *(*conststringfunc)())
|
||||
{
|
||||
Callback *p;
|
||||
|
||||
|
||||
if (num_callbacks(cbtype) > 0)
|
||||
{
|
||||
if (module)
|
||||
module->errorcode = MODERR_EXISTS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
p = safe_alloc(sizeof(Callback));
|
||||
if (func)
|
||||
p->func.intfunc = func;
|
||||
@@ -1138,7 +1153,8 @@ Callback *CallbackAddMain(Module *module, int cbtype, int (*func)(), void (*vfun
|
||||
p->type = cbtype;
|
||||
p->owner = module;
|
||||
AddListItem(p, Callbacks[cbtype]);
|
||||
if (module) {
|
||||
if (module)
|
||||
{
|
||||
ModuleObject *cbobj = safe_alloc(sizeof(ModuleObject));
|
||||
cbobj->object.callback = p;
|
||||
cbobj->type = MOBJ_CALLBACK;
|
||||
@@ -1157,16 +1173,21 @@ Callback *CallbackAddMain(Module *module, int cbtype, int (*func)(), void (*vfun
|
||||
Callback *CallbackDel(Callback *cb)
|
||||
{
|
||||
Callback *p, *q;
|
||||
for (p = Callbacks[cb->type]; p; p = p->next) {
|
||||
if (p == cb) {
|
||||
for (p = Callbacks[cb->type]; p; p = p->next)
|
||||
{
|
||||
if (p == cb)
|
||||
{
|
||||
q = p->next;
|
||||
DelListItem(p, Callbacks[cb->type]);
|
||||
if (RCallbacks[cb->type] == p)
|
||||
RCallbacks[cb->type] = NULL;
|
||||
if (p->owner) {
|
||||
if (p->owner)
|
||||
{
|
||||
ModuleObject *cbobj;
|
||||
for (cbobj = p->owner->objects; cbobj; cbobj = cbobj->next) {
|
||||
if ((cbobj->type == MOBJ_CALLBACK) && (cbobj->object.callback == p)) {
|
||||
for (cbobj = p->owner->objects; cbobj; cbobj = cbobj->next)
|
||||
{
|
||||
if ((cbobj->type == MOBJ_CALLBACK) && (cbobj->object.callback == p))
|
||||
{
|
||||
DelListItem(cbobj, cb->owner->objects);
|
||||
safe_free(cbobj);
|
||||
break;
|
||||
@@ -1211,7 +1232,7 @@ CommandOverride *CommandOverrideAdd(Module *module, const char *name, int priori
|
||||
module->errorcode = MODERR_NOTFOUND;
|
||||
return NULL;
|
||||
}
|
||||
for (ovr=p->overriders; ovr; ovr=ovr->next)
|
||||
for (ovr = p->overriders; ovr; ovr = ovr->next)
|
||||
{
|
||||
if ((ovr->owner == module) && (ovr->func == function))
|
||||
{
|
||||
@@ -1294,7 +1315,7 @@ void CallCommandOverride(CommandOverride *ovr, ClientContext *clictx, Client *cl
|
||||
EVENT(e_unload_module_delayed)
|
||||
{
|
||||
char *name = (char *)data;
|
||||
int i;
|
||||
int i;
|
||||
isupport_snapshot();
|
||||
i = Module_Unload(name);
|
||||
if (i == 1)
|
||||
@@ -1313,7 +1334,7 @@ EVENT(e_unload_module_delayed)
|
||||
void unload_all_modules(void)
|
||||
{
|
||||
Module *m;
|
||||
int (*Mod_Unload)();
|
||||
int (*Mod_Unload)();
|
||||
for (m = Modules; m; m = m->next)
|
||||
{
|
||||
#ifdef DEBUGMODE
|
||||
@@ -1336,7 +1357,8 @@ void ModuleSetOptions(Module *module, unsigned int options, int action)
|
||||
{
|
||||
DelListItem(module, Modules);
|
||||
AddListItemPrio(module, Modules, action);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Simple bit flag(s) */
|
||||
if (action)
|
||||
module->options |= options;
|
||||
@@ -1356,16 +1378,16 @@ unsigned int ModuleGetError(Module *module)
|
||||
}
|
||||
|
||||
static const char *module_error_str[] = {
|
||||
"No error",
|
||||
"Object already exists",
|
||||
"No space available",
|
||||
"Invalid parameter(s)",
|
||||
"Object was not found",
|
||||
"No error",
|
||||
"Object already exists",
|
||||
"No space available",
|
||||
"Invalid parameter(s)",
|
||||
"Object was not found",
|
||||
};
|
||||
|
||||
const char *ModuleGetErrorStr(Module *module)
|
||||
{
|
||||
if (module->errorcode >= sizeof(module_error_str)/sizeof(module_error_str[0]))
|
||||
if (module->errorcode >= sizeof(module_error_str) / sizeof(module_error_str[0]))
|
||||
return NULL;
|
||||
|
||||
return module_error_str[module->errorcode];
|
||||
@@ -1376,9 +1398,9 @@ const char *ModuleGetErrorStr(Module *module)
|
||||
*/
|
||||
int callbacks_check(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i=0; i < MAXCALLBACKS; i++)
|
||||
for (i = 0; i < MAXCALLBACKS; i++)
|
||||
{
|
||||
if (num_callbacks(i) > 1)
|
||||
{
|
||||
@@ -1404,14 +1426,14 @@ int i;
|
||||
|
||||
void callbacks_switchover(void)
|
||||
{
|
||||
Callback *e;
|
||||
int i;
|
||||
Callback *e;
|
||||
int i;
|
||||
|
||||
/* Now set the real callback, and tag the new one
|
||||
* as 'willberemoved' if needed.
|
||||
*/
|
||||
|
||||
for (i=0; i < MAXCALLBACKS; i++)
|
||||
for (i = 0; i < MAXCALLBACKS; i++)
|
||||
for (e = Callbacks[i]; e; e = e->next)
|
||||
if (!e->willberemoved)
|
||||
{
|
||||
@@ -1427,12 +1449,12 @@ const char *our_dlerror(void)
|
||||
{
|
||||
static char errbuf[513];
|
||||
DWORD err = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err,
|
||||
0, errbuf, 512, NULL);
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err,
|
||||
0, errbuf, 512, NULL);
|
||||
if (err == ERROR_MOD_NOT_FOUND)
|
||||
strlcat(errbuf, " This could be because the DLL depends on another DLL, for example if you "
|
||||
"are trying to load a 3rd party module which was compiled with a different compiler version.",
|
||||
sizeof(errbuf));
|
||||
"are trying to load a 3rd party module which was compiled with a different compiler version.",
|
||||
sizeof(errbuf));
|
||||
return errbuf;
|
||||
}
|
||||
#endif
|
||||
@@ -1489,7 +1511,8 @@ ModDataInfo *persistent_var_generic(ModuleInfo *modinfo, const char *varshortnam
|
||||
m->unloaded = 0;
|
||||
}
|
||||
return m;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
ModDataInfo mreq;
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.type = MODDATATYPE_LOCAL_VARIABLE;
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"account-notify", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"account-notify CAP", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"account-notify", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"account-notify CAP", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
long CAP_ACCOUNT_NOTIFY = 0L;
|
||||
@@ -67,10 +66,10 @@ int account_notify_account_login(Client *client, MessageTag *recv_mtags)
|
||||
MessageTag *mtags = NULL;
|
||||
new_message(client, recv_mtags, &mtags);
|
||||
sendto_local_common_channels(client, client,
|
||||
CAP_ACCOUNT_NOTIFY, mtags,
|
||||
":%s ACCOUNT %s",
|
||||
client->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*");
|
||||
CAP_ACCOUNT_NOTIFY, mtags,
|
||||
":%s ACCOUNT %s",
|
||||
client->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*");
|
||||
free_message_tags(mtags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"account-tag",
|
||||
"5.0",
|
||||
"account-tag CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"account-tag",
|
||||
"5.0",
|
||||
"account-tag CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Variables */
|
||||
long CAP_ACCOUNT_TAG = 0L;
|
||||
|
||||
+9
-10
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_addmotd);
|
||||
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
#define MSG_ADDMOTD "ADDMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"addmotd",
|
||||
"5.0",
|
||||
"command /addmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"addmotd",
|
||||
"5.0",
|
||||
"command /addmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -67,7 +66,7 @@ CMD_FUNC(cmd_addmotd)
|
||||
if (!MyConnect(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:addmotd",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:addmotd", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
|
||||
+9
-10
@@ -24,16 +24,15 @@
|
||||
|
||||
CMD_FUNC(cmd_addomotd);
|
||||
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
#define MSG_ADDOMOTD "ADDOMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"addomotd",
|
||||
"5.0",
|
||||
"command /addomotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"addomotd",
|
||||
"5.0",
|
||||
"command /addomotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -67,7 +66,7 @@ CMD_FUNC(cmd_addomotd)
|
||||
if (!MyConnect(client))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("server:addomotd",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("server:addomotd", client, NULL, NULL, NULL))
|
||||
{
|
||||
sendnumeric(client, ERR_NOPRIVILEGES);
|
||||
return;
|
||||
|
||||
+9
-10
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_admin);
|
||||
|
||||
#define MSG_ADMIN "ADMIN"
|
||||
#define MSG_ADMIN "ADMIN"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"admin",
|
||||
"5.0",
|
||||
"command /admin",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"admin",
|
||||
"5.0",
|
||||
"command /admin",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_USER|CMD_SHUN|CMD_VIRUS);
|
||||
CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_USER | CMD_SHUN | CMD_VIRUS);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
+20
-31
@@ -47,13 +47,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"antimixedutf8",
|
||||
"1.0",
|
||||
"Mixed UTF8 character filter (look-alike character spam) - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"antimixedutf8",
|
||||
"1.0",
|
||||
"Mixed UTF8 character filter (look-alike character spam) - by Syzop",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct {
|
||||
@@ -84,14 +83,13 @@ int antimixedutf8_check(Client *client, TextAnalysis *txa, const char **errmsg)
|
||||
unreal_log(ULOG_INFO, "antimixedutf8", "ANTIMIXEDUTF8_HIT", client,
|
||||
"[antimixedutf8] Client $client.details hit score $score -- taking action",
|
||||
log_data_integer("score", txa->antimixedutf8_points),
|
||||
log_data_textanalysis("text_analysis",txa));
|
||||
log_data_textanalysis("text_analysis", txa));
|
||||
/* Take the action */
|
||||
retval = take_action(client, cfg.ban_action, cfg.ban_reason, cfg.ban_time, 0, NULL);
|
||||
if ((retval == BAN_ACT_WARN) || (retval == BAN_ACT_SOFT_WARN))
|
||||
{
|
||||
/* no action */
|
||||
} else
|
||||
if ((retval == BAN_ACT_BLOCK) || (retval == BAN_ACT_SOFT_BLOCK))
|
||||
} else if ((retval == BAN_ACT_BLOCK) || (retval == BAN_ACT_SOFT_BLOCK))
|
||||
{
|
||||
*errmsg = cfg.ban_reason;
|
||||
return HOOK_DENY;
|
||||
@@ -182,36 +180,31 @@ int antimixedutf8_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::antimixedutf8::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 99))
|
||||
{
|
||||
config_error("%s:%i: set::antimixedutf8::score: must be between 1 - 99 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
errors += test_ban_action_config(cep);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::antimixedutf8::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -235,20 +228,16 @@ int antimixedutf8_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
cfg.score = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &cfg.except);
|
||||
}
|
||||
|
||||
+78
-78
@@ -22,17 +22,16 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"antirandom",
|
||||
"1.5",
|
||||
"Detect and ban users with random names",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"antirandom",
|
||||
"1.5",
|
||||
"Detect and ban users with random names",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
||||
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/* "<char1><char2>" followed by "<rest>" */
|
||||
@@ -482,7 +481,7 @@ static char *triples_txt[] = {
|
||||
/* clang-format on */
|
||||
|
||||
/* Used for parsed triples: */
|
||||
#define TRIPLES_REST_SIZE 32
|
||||
#define TRIPLES_REST_SIZE 32
|
||||
typedef struct Triples Triples;
|
||||
struct Triples {
|
||||
Triples *next;
|
||||
@@ -576,21 +575,19 @@ int antirandom_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::antirandom... */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "antirandom"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-hosts"))
|
||||
} else if (!strcmp(cep->name, "except-hosts"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-webirc"))
|
||||
} else if (!strcmp(cep->name, "except-webirc"))
|
||||
{
|
||||
/* This should normally be UNDER the generic 'set::antirandom::%s with no value'
|
||||
* stuff but I put it here because people may think it's a hostlist and then
|
||||
@@ -602,39 +599,32 @@ int antirandom_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::antirandom::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "threshold"))
|
||||
} else if (!strcmp(cep->name, "threshold"))
|
||||
{
|
||||
req.threshold = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
{
|
||||
req.ban_action = 1;
|
||||
errors += test_ban_action_config(cep);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
req.ban_reason = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
req.ban_time = 1;
|
||||
} else
|
||||
if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
} else if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "show-failedconnects"))
|
||||
} else if (!strcmp(cep->name, "show-failedconnects"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::antirandom::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -648,45 +638,38 @@ int antirandom_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::antirandom... */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "antirandom"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &cfg.except);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-hosts"))
|
||||
} else if (!strcmp(cep->name, "except-hosts"))
|
||||
{
|
||||
/* backwards compatible with set::antirandom::except */
|
||||
for (cep2 = cep->items; cep2; cep2 = cep2->next)
|
||||
unreal_add_masks(&cfg.except->mask, cep2);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except-webirc"))
|
||||
} else if (!strcmp(cep->name, "except-webirc"))
|
||||
{
|
||||
/* backwards compatible with set::antirandom::except */
|
||||
cfg.except->webirc = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "threshold"))
|
||||
} else if (!strcmp(cep->name, "threshold"))
|
||||
{
|
||||
cfg.threshold = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
} else if (!strcmp(cep->name, "convert-to-lowercase"))
|
||||
{
|
||||
cfg.convert_to_lowercase = config_checkval(cep->value, CFG_YESNO);
|
||||
}
|
||||
@@ -702,11 +685,27 @@ int antirandom_config_posttest(int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
|
||||
if (!req.threshold) { config_error("set::antirandom::threshold missing"); errors++; }
|
||||
if (!req.ban_action) { config_error("set::antirandom::ban-action missing"); errors++; }
|
||||
if (!req.ban_time) { config_error("set::antirandom::ban-time missing"); errors++; }
|
||||
if (!req.ban_reason) { config_error("set::antirandom::ban-reason missing"); errors++; }
|
||||
|
||||
if (!req.threshold)
|
||||
{
|
||||
config_error("set::antirandom::threshold missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_action)
|
||||
{
|
||||
config_error("set::antirandom::ban-action missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_time)
|
||||
{
|
||||
config_error("set::antirandom::ban-time missing");
|
||||
errors++;
|
||||
}
|
||||
if (!req.ban_reason)
|
||||
{
|
||||
config_error("set::antirandom::ban-reason missing");
|
||||
errors++;
|
||||
}
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -722,17 +721,17 @@ static int init_stuff(void)
|
||||
static int init_triples(void)
|
||||
{
|
||||
char **s;
|
||||
Triples *e, *last=NULL;
|
||||
int cnt=0;
|
||||
Triples *e, *last = NULL;
|
||||
int cnt = 0;
|
||||
|
||||
for (s=triples_txt; *s; s++)
|
||||
for (s = triples_txt; *s; s++)
|
||||
{
|
||||
cnt++;
|
||||
e = safe_alloc(sizeof(Triples));
|
||||
if (strlen(*s) > 2)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, item='%s' (length>2)",
|
||||
cnt, *s);
|
||||
cnt, *s);
|
||||
return 0;
|
||||
}
|
||||
strcpy(e->two, *s); /* (SAFE) */
|
||||
@@ -740,13 +739,13 @@ static int init_triples(void)
|
||||
if (!*s)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, got NULL expected param",
|
||||
cnt);
|
||||
cnt);
|
||||
return 0;
|
||||
}
|
||||
if (strlen(*s) > TRIPLES_REST_SIZE-1)
|
||||
if (strlen(*s) > TRIPLES_REST_SIZE - 1)
|
||||
{
|
||||
config_error("init_triples: error parsing triples_txt, cnt=%d, item='%s' (length>%d)",
|
||||
cnt, *s, TRIPLES_REST_SIZE-1);
|
||||
cnt, *s, TRIPLES_REST_SIZE - 1);
|
||||
return 0;
|
||||
}
|
||||
strcpy(e->rest, *s); /* (SAFE) */
|
||||
@@ -772,27 +771,30 @@ static int internal_getscore(char *str)
|
||||
Triples *t;
|
||||
register char *s;
|
||||
int score = 0;
|
||||
int highest_vowels=0, highest_consonants=0, highest_digits=0;
|
||||
int vowels=0, consonants=0, digits=0;
|
||||
int highest_vowels = 0, highest_consonants = 0, highest_digits = 0;
|
||||
int vowels = 0, consonants = 0, digits = 0;
|
||||
|
||||
/* Fast digit/consonant/vowel checks... */
|
||||
for (s=str; *s; s++)
|
||||
for (s = str; *s; s++)
|
||||
{
|
||||
if ((*s >= '0') && (*s <= '9'))
|
||||
digits++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_digits = MAX(highest_digits, digits);
|
||||
digits = 0;
|
||||
}
|
||||
if (strchr("bcdfghjklmnpqrstvwxz", *s))
|
||||
consonants++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_consonants = MAX(highest_consonants, consonants);
|
||||
consonants = 0;
|
||||
}
|
||||
if (strchr("aeiou", *s))
|
||||
vowels++;
|
||||
else {
|
||||
else
|
||||
{
|
||||
highest_vowels = MAX(highest_vowels, vowels);
|
||||
vowels = 0;
|
||||
}
|
||||
@@ -801,7 +803,7 @@ static int internal_getscore(char *str)
|
||||
digits = MAX(highest_digits, digits);
|
||||
consonants = MAX(highest_consonants, consonants);
|
||||
vowels = MAX(highest_vowels, vowels);
|
||||
|
||||
|
||||
if (digits >= 5)
|
||||
{
|
||||
score += digits;
|
||||
@@ -814,18 +816,17 @@ static int internal_getscore(char *str)
|
||||
{
|
||||
score += consonants;
|
||||
}
|
||||
|
||||
for (t=triples; t; t=t->next)
|
||||
|
||||
for (t = triples; t; t = t->next)
|
||||
{
|
||||
for (s=str; *s; s++)
|
||||
for (s = str; *s; s++)
|
||||
if ((t->two[0] == s[0]) && (t->two[1] == s[1]) && s[2] && strchr(t->rest, s[2]))
|
||||
{
|
||||
score++; /* OK */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
@@ -837,7 +838,7 @@ static int get_spam_score(Client *client)
|
||||
char *nick = client->name;
|
||||
char *user = client->user->username;
|
||||
char *gecos = client->info;
|
||||
char nbuf[NICKLEN+1], ubuf[USERLEN+1], rbuf[REALLEN+1];
|
||||
char nbuf[NICKLEN + 1], ubuf[USERLEN + 1], rbuf[REALLEN + 1];
|
||||
int nscore, uscore, gscore, score;
|
||||
|
||||
if (cfg.convert_to_lowercase)
|
||||
@@ -874,8 +875,7 @@ int antirandom_preconnect(Client *client)
|
||||
unreal_log(ULOG_INFO, "antirandom", "ANTIRANDOM_DENIED_USER", client,
|
||||
"[antirandom] would have denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
} else
|
||||
if (n <= 0)
|
||||
} else if (n <= 0)
|
||||
{
|
||||
/* No action / exempt */
|
||||
} else
|
||||
@@ -883,8 +883,8 @@ int antirandom_preconnect(Client *client)
|
||||
if (cfg.show_failedconnects)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "antirandom", "ANTIRANDOM_DENIED_USER", client,
|
||||
"[antirandom] denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
"[antirandom] denied access to user with score $score: $client.details:$client.user.realname",
|
||||
log_data_integer("score", score));
|
||||
}
|
||||
return HOOK_DENY;
|
||||
}
|
||||
@@ -896,7 +896,7 @@ static void free_stuff(void)
|
||||
{
|
||||
Triples *t, *t_next;
|
||||
|
||||
for (t=triples; t; t=t_next)
|
||||
for (t = triples; t; t = t_next)
|
||||
{
|
||||
t_next = t->next;
|
||||
safe_free(t);
|
||||
|
||||
+36
-39
@@ -19,13 +19,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"authprompt",
|
||||
"1.0",
|
||||
"SASL authentication for clients that don't support SASL",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"authprompt",
|
||||
"1.0",
|
||||
"SASL authentication for clients that don't support SASL",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/** Configuration settings */
|
||||
@@ -62,9 +61,13 @@ CMD_FUNC(cmd_auth);
|
||||
void authprompt_md_free(ModData *md);
|
||||
|
||||
/* Some macros */
|
||||
#define SetAPUser(x, y) do { moddata_local_client(x, authprompt_md).ptr = y; } while(0)
|
||||
#define SEUSER(x) ((APUser *)moddata_local_client(x, authprompt_md).ptr)
|
||||
#define AGENT_SID(agent_p) (agent_p->user != NULL ? agent_p->user->server : agent_p->name)
|
||||
#define SetAPUser(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, authprompt_md).ptr = y; \
|
||||
} while (0)
|
||||
#define SEUSER(x) ((APUser *)moddata_local_client(x, authprompt_md).ptr)
|
||||
#define AGENT_SID(agent_p) (agent_p->user != NULL ? agent_p->user->server : agent_p->name)
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -167,24 +170,20 @@ int authprompt_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::authentication-prompt::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "enabled"))
|
||||
} else if (!strcmp(cep->name, "enabled"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "message"))
|
||||
} else if (!strcmp(cep->name, "message"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "fail-message"))
|
||||
} else if (!strcmp(cep->name, "fail-message"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
} else if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::authentication-prompt::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -208,16 +207,13 @@ int authprompt_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep->name, "enabled"))
|
||||
{
|
||||
cfg.enabled = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "message"))
|
||||
} else if (!strcmp(cep->name, "message"))
|
||||
{
|
||||
addmultiline(&cfg.message, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "fail-message"))
|
||||
} else if (!strcmp(cep->name, "fail-message"))
|
||||
{
|
||||
addmultiline(&cfg.fail_message, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
} else if (!strcmp(cep->name, "unconfirmed-message"))
|
||||
{
|
||||
addmultiline(&cfg.unconfirmed_message, cep->value);
|
||||
}
|
||||
@@ -273,14 +269,14 @@ char *make_authbuf(const char *username, const char *password)
|
||||
int size;
|
||||
|
||||
size = strlen(username) + 1 + strlen(username) + 1 + strlen(password);
|
||||
if (size >= sizeof(inbuf)-1)
|
||||
if (size >= sizeof(inbuf) - 1)
|
||||
return NULL; /* too long */
|
||||
|
||||
/* Because size limits are already checked above, we can cut some corners here: */
|
||||
memset(inbuf, 0, sizeof(inbuf));
|
||||
strcpy(inbuf, username);
|
||||
strcpy(inbuf+strlen(username)+1, username);
|
||||
strcpy(inbuf+strlen(username)+1+strlen(username)+1, password);
|
||||
strcpy(inbuf + strlen(username) + 1, username);
|
||||
strcpy(inbuf + strlen(username) + 1 + strlen(username) + 1, password);
|
||||
/* ^ normal people use stpcpy here ;) */
|
||||
|
||||
if (b64_encode(inbuf, size, outbuf, sizeof(outbuf)) < 0)
|
||||
@@ -309,22 +305,23 @@ void send_first_auth(Client *client)
|
||||
/* Make them a user, needed for CHGHOST etc that we may receive */
|
||||
if (!client->user)
|
||||
make_user(client);
|
||||
|
||||
|
||||
if (Hooks[HOOKTYPE_SASL_AUTHENTICATE] && (find_client(SASL_SERVER, NULL) == &me))
|
||||
{
|
||||
/* We are the SASL server (some module handling auth) */
|
||||
RunHook(HOOKTYPE_SASL_AUTHENTICATE, client, 1, "PLAIN");
|
||||
RunHook(HOOKTYPE_SASL_AUTHENTICATE, client, 0, SEUSER(client)->authmsg);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s H %s %s",
|
||||
me.id, SASL_SERVER, client->id, addr, addr);
|
||||
me.id, SASL_SERVER, client->id, addr, addr);
|
||||
|
||||
if (certfp)
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s S %s %s",
|
||||
me.id, SASL_SERVER, client->id, "PLAIN", certfp);
|
||||
me.id, SASL_SERVER, client->id, "PLAIN", certfp);
|
||||
else
|
||||
sendto_one(sasl_server, NULL, ":%s SASL %s %s S %s",
|
||||
me.id, SASL_SERVER, client->id, "PLAIN");
|
||||
me.id, SASL_SERVER, client->id, "PLAIN");
|
||||
}
|
||||
/* The rest is sent from authprompt_sasl_continuation() */
|
||||
|
||||
@@ -426,10 +423,10 @@ int authprompt_find_tkline_match(Client *client, TKL *tkl)
|
||||
* and the user is not yet online, then we will handle this user.
|
||||
*/
|
||||
if (cfg.enabled &&
|
||||
TKLIsServerBan(tkl) &&
|
||||
(tkl->ptr.serverban->subtype & TKL_SUBTYPE_SOFT) &&
|
||||
!IsLoggedIn(client) &&
|
||||
!IsUser(client))
|
||||
TKLIsServerBan(tkl) &&
|
||||
(tkl->ptr.serverban->subtype & TKL_SUBTYPE_SOFT) &&
|
||||
!IsLoggedIn(client) &&
|
||||
!IsUser(client))
|
||||
{
|
||||
/* And tag the user */
|
||||
authprompt_tag_as_auth_required(client, tkl->ptr.serverban->reason);
|
||||
@@ -463,7 +460,7 @@ int authprompt_sasl_continuation(Client *client, const char *buf)
|
||||
if (agent)
|
||||
{
|
||||
sendto_one(agent, NULL, ":%s SASL %s %s C %s",
|
||||
me.id, AGENT_SID(agent), client->id, SEUSER(client)->authmsg);
|
||||
me.id, AGENT_SID(agent), client->id, SEUSER(client)->authmsg);
|
||||
}
|
||||
safe_free(SEUSER(client)->authmsg);
|
||||
}
|
||||
|
||||
+12
-13
@@ -29,16 +29,15 @@ int away_join(Client *client, Channel *channel, MessageTag *mtags);
|
||||
|
||||
long CAP_AWAY_NOTIFY = 0L;
|
||||
|
||||
#define MSG_AWAY "AWAY"
|
||||
#define MSG_AWAY "AWAY"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"away",
|
||||
"5.0",
|
||||
"command /away",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"away",
|
||||
"5.0",
|
||||
"command /away",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -46,7 +45,7 @@ MOD_INIT()
|
||||
memset(&c, 0, sizeof(c));
|
||||
c.name = "away-notify";
|
||||
ClientCapabilityAdd(modinfo->handle, &c, &CAP_AWAY_NOTIFY);
|
||||
CommandAdd(modinfo->handle, MSG_AWAY, cmd_away, 1, CMD_USER|CMD_TEXTANALYSIS);
|
||||
CommandAdd(modinfo->handle, MSG_AWAY, cmd_away, 1, CMD_USER | CMD_TEXTANALYSIS);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_JOIN, 0, away_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_JOIN, 0, away_join);
|
||||
|
||||
@@ -137,7 +136,7 @@ CMD_FUNC(cmd_away)
|
||||
|
||||
/* Check away-flood */
|
||||
if (MyUser(client) &&
|
||||
!ValidatePermissionsForPath("immune:away-flood",client,NULL,NULL,NULL) &&
|
||||
!ValidatePermissionsForPath("immune:away-flood", client, NULL, NULL, NULL) &&
|
||||
flood_limit_exceeded(client, FLD_AWAY))
|
||||
{
|
||||
sendnumeric(client, ERR_TOOMANYAWAY);
|
||||
@@ -153,7 +152,7 @@ CMD_FUNC(cmd_away)
|
||||
client->user->away_since = t;
|
||||
else
|
||||
client->user->away_since = TStime();
|
||||
|
||||
|
||||
new_message(client, recv_mtags, &mtags);
|
||||
|
||||
sendto_server(client, 0, 0, mtags, ":%s AWAY :%s", client->id, reason);
|
||||
@@ -163,7 +162,7 @@ CMD_FUNC(cmd_away)
|
||||
safe_free(client->user->away);
|
||||
already_as_away = 1;
|
||||
}
|
||||
|
||||
|
||||
safe_strdup(client->user->away, reason);
|
||||
|
||||
if (MyConnect(client))
|
||||
|
||||
+10
-10
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"batch",
|
||||
"5.0",
|
||||
"Batch CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"batch",
|
||||
"5.0",
|
||||
"Batch CAP",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
CMD_FUNC(cmd_batch);
|
||||
@@ -57,7 +56,7 @@ MOD_INIT()
|
||||
mtag.clicap_handler = c;
|
||||
MessageTagHandlerAdd(modinfo->handle, &mtag);
|
||||
|
||||
CommandAdd(modinfo->handle, "BATCH", cmd_batch, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, "BATCH", cmd_batch, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -116,7 +115,8 @@ CMD_FUNC(cmd_batch)
|
||||
parv[1] = "BATCH";
|
||||
concat_params(buf, sizeof(buf), parc, parv);
|
||||
sendto_prefix_one(target, client, recv_mtags, ":%s %s", client->name, buf);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Relay the batch message to the server */
|
||||
concat_params(buf, sizeof(buf), parc, parv);
|
||||
sendto_prefix_one(target, client, recv_mtags, ":%s BATCH %s", client->name, buf);
|
||||
|
||||
+119
-132
@@ -19,13 +19,12 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"blacklist",
|
||||
"5.0",
|
||||
"Check connecting users against DNS Blacklists",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"blacklist",
|
||||
"5.0",
|
||||
"Check connecting users against DNS Blacklists",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* In this module and the config syntax I tried to 'abstract' things
|
||||
@@ -40,13 +39,18 @@ static long BLACKLIST_RECHECK_TIME_FIRST = 120;
|
||||
/* After that, check every <this>: */
|
||||
static long BLACKLIST_RECHECK_TIME = 900;
|
||||
|
||||
#define LastBLCheck(x) (moddata_local_client(x, blacklistrecheck_md).l)
|
||||
#define SetLastBLCheck(x, y) do { moddata_local_client(x, blacklistrecheck_md).l = y; } while(0)
|
||||
#define LastBLCheck(x) (moddata_local_client(x, blacklistrecheck_md).l)
|
||||
#define SetLastBLCheck(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, blacklistrecheck_md).l = y; \
|
||||
} while (0)
|
||||
|
||||
/* Types */
|
||||
|
||||
typedef enum {
|
||||
DNSBL_RECORD=1, DNSBL_BITMASK=2
|
||||
DNSBL_RECORD = 1,
|
||||
DNSBL_BITMASK = 2
|
||||
} DNSBLType;
|
||||
|
||||
typedef struct DNSBL DNSBL;
|
||||
@@ -57,8 +61,7 @@ struct DNSBL {
|
||||
};
|
||||
|
||||
typedef union BlacklistBackend BlacklistBackend;
|
||||
union BlacklistBackend
|
||||
{
|
||||
union BlacklistBackend {
|
||||
DNSBL *dns;
|
||||
};
|
||||
|
||||
@@ -124,8 +127,12 @@ void blacklist_set_handshake_delay(void);
|
||||
void blacklist_free_bluser_if_able(BLUser *bl);
|
||||
EVENT(blacklist_recheck);
|
||||
|
||||
#define SetBLUser(x, y) do { moddata_local_client(x, blacklist_md).ptr = y; } while(0)
|
||||
#define BLUSER(x) ((BLUser *)moddata_local_client(x, blacklist_md).ptr)
|
||||
#define SetBLUser(x, y) \
|
||||
do \
|
||||
{ \
|
||||
moddata_local_client(x, blacklist_md).ptr = y; \
|
||||
} while (0)
|
||||
#define BLUSER(x) ((BLUser *)moddata_local_client(x, blacklist_md).ptr)
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -142,7 +149,7 @@ MOD_INIT()
|
||||
ModDataInfo mreq;
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "blacklist";
|
||||
mreq.type = MODDATATYPE_LOCAL_CLIENT;
|
||||
@@ -225,7 +232,7 @@ void blacklist_set_handshake_delay(void)
|
||||
Blacklist *blacklist_find_block_by_dns(char *name)
|
||||
{
|
||||
Blacklist *d;
|
||||
|
||||
|
||||
for (d = conf_blacklist; d; d = d->next)
|
||||
if ((d->backend_type == BLACKLIST_BACKEND_DNS) && !strcmp(name, d->backend->dns->name))
|
||||
return d;
|
||||
@@ -256,7 +263,7 @@ void delete_blacklist_block(Blacklist *e)
|
||||
safe_free(e->backend->dns);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
safe_free(e->backend);
|
||||
|
||||
safe_free(e->name);
|
||||
@@ -269,24 +276,24 @@ void delete_blacklist_block(Blacklist *e)
|
||||
|
||||
int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
int errors = 0;
|
||||
char has_reason = 0, has_ban_time = 0, has_action = 0;
|
||||
char has_dns_type = 0, has_dns_reply = 0, has_dns_name = 0, has_recheck = 0;
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce)
|
||||
return 0;
|
||||
|
||||
|
||||
if (strcmp(ce->name, "blacklist"))
|
||||
return 0; /* not interested in non-blacklist stuff.. */
|
||||
|
||||
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: blacklist block without name (use: blacklist somename { })",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
*errs = 1;
|
||||
return -1;
|
||||
}
|
||||
@@ -304,8 +311,8 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
/* this is an error (not a warning) */
|
||||
config_error("%s:%i: blacklist block may contain only one blacklist::dns::reply item. "
|
||||
"You can specify multiple replies by using: reply { 1; 2; 4; };",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"You can specify multiple replies by using: reply { 1; 2; 4; };",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -319,8 +326,8 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (cepp->value && cepp->items)
|
||||
{
|
||||
config_error("%s:%i: blacklist::dns::reply must be either using format 'reply 1;' or "
|
||||
"'reply { 1; 2; 4; }; but not both formats at the same time.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
"'reply { 1; 2; 4; }; but not both formats at the same time.",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -329,46 +336,43 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (atoi(cepp->value) <= 0)
|
||||
{
|
||||
config_error("%s:%i: blacklist::dns::reply must be >0",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (cepp->items)
|
||||
{
|
||||
for (ceppp = cepp->items; ceppp; ceppp=ceppp->next)
|
||||
for (ceppp = cepp->items; ceppp; ceppp = ceppp->next)
|
||||
{
|
||||
if (atoi(ceppp->name) <= 0)
|
||||
{
|
||||
config_error("%s:%i: all items in blacklist::dns::reply must be >0",
|
||||
cepp->file->filename, cepp->line_number);
|
||||
cepp->file->filename, cepp->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!cepp->value)
|
||||
} else if (!cepp->value)
|
||||
{
|
||||
config_error_empty(cepp->file->filename, cepp->line_number,
|
||||
"blacklist::dns", cepp->name);
|
||||
"blacklist::dns", cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "name"))
|
||||
} else if (!strcmp(cepp->name, "name"))
|
||||
{
|
||||
if (has_dns_name)
|
||||
{
|
||||
config_warn_duplicate(cepp->file->filename,
|
||||
cepp->line_number, "blacklist::dns::name");
|
||||
cepp->line_number, "blacklist::dns::name");
|
||||
}
|
||||
has_dns_name = 1;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "type"))
|
||||
} else if (!strcmp(cepp->name, "type"))
|
||||
{
|
||||
if (has_dns_type)
|
||||
{
|
||||
config_warn_duplicate(cepp->file->filename,
|
||||
cepp->line_number, "blacklist::dns::type");
|
||||
cepp->line_number, "blacklist::dns::type");
|
||||
}
|
||||
has_dns_type = 1;
|
||||
if (!strcmp(cepp->value, "record"))
|
||||
@@ -378,68 +382,61 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
else
|
||||
{
|
||||
config_error("%s:%i: unknown blacklist::dns::type '%s', must be either 'record' or 'bitmask'",
|
||||
cepp->file->filename, cepp->line_number, cepp->value);
|
||||
cepp->file->filename, cepp->line_number, cepp->value);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error_empty(cep->file->filename, cep->line_number,
|
||||
"blacklist", cep->name);
|
||||
"blacklist", cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
if (has_action)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::action");
|
||||
cep->line_number, "blacklist::action");
|
||||
continue;
|
||||
}
|
||||
has_action = 1;
|
||||
errors += test_ban_action_config(cep);
|
||||
}
|
||||
else if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
if (has_ban_time)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::ban-time");
|
||||
cep->line_number, "blacklist::ban-time");
|
||||
continue;
|
||||
}
|
||||
has_ban_time = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
if (has_reason)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::reason");
|
||||
cep->line_number, "blacklist::reason");
|
||||
continue;
|
||||
}
|
||||
has_reason = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "recheck"))
|
||||
} else if (!strcmp(cep->name, "recheck"))
|
||||
{
|
||||
if (has_recheck)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "blacklist::recheck");
|
||||
cep->line_number, "blacklist::recheck");
|
||||
continue;
|
||||
}
|
||||
has_recheck = 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"blacklist", cep->name);
|
||||
"blacklist", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -447,35 +444,35 @@ int blacklist_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!has_action)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::action");
|
||||
"blacklist::action");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_reason)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::reason");
|
||||
"blacklist::reason");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_name)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::name");
|
||||
"blacklist::dns::name");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_type)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::type");
|
||||
"blacklist::dns::type");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_dns_reply)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"blacklist::dns::reply");
|
||||
"blacklist::dns::reply");
|
||||
errors++;
|
||||
}
|
||||
|
||||
@@ -487,10 +484,10 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ConfigEntry *cep, *cepp, *ceppp;
|
||||
Blacklist *d = NULL;
|
||||
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0; /* not interested */
|
||||
|
||||
@@ -499,7 +496,7 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
/* set some defaults */
|
||||
d->ban_time = 3600;
|
||||
d->recheck = 1;
|
||||
|
||||
|
||||
/* assume dns for now ;) */
|
||||
d->backend_type = BLACKLIST_BACKEND_DNS;
|
||||
d->backend = safe_alloc(sizeof(BlacklistBackend));
|
||||
@@ -516,11 +513,10 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (cepp->value)
|
||||
{
|
||||
/* single reply */
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int)*2);
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int) * 2);
|
||||
d->backend->dns->reply[0] = atoi(cepp->value);
|
||||
d->backend->dns->reply[1] = 0;
|
||||
} else
|
||||
if (cepp->items)
|
||||
} else if (cepp->items)
|
||||
{
|
||||
/* (potentially) multiple reply values */
|
||||
int cnt = 0;
|
||||
@@ -529,12 +525,12 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (ceppp->name)
|
||||
cnt++;
|
||||
}
|
||||
|
||||
|
||||
if (cnt == 0)
|
||||
abort(); /* impossible */
|
||||
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int)*(cnt+1));
|
||||
|
||||
|
||||
d->backend->dns->reply = safe_alloc(sizeof(int) * (cnt + 1));
|
||||
|
||||
cnt = 0;
|
||||
for (ceppp = cepp->items; ceppp; ceppp = ceppp->next)
|
||||
{
|
||||
@@ -542,44 +538,37 @@ int blacklist_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
}
|
||||
d->backend->dns->reply[cnt] = 0;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "type"))
|
||||
} else if (!strcmp(cepp->name, "type"))
|
||||
{
|
||||
if (!strcmp(cepp->value, "record"))
|
||||
d->backend->dns->type = DNSBL_RECORD;
|
||||
else if (!strcmp(cepp->value, "bitmask"))
|
||||
d->backend->dns->type = DNSBL_BITMASK;
|
||||
} else
|
||||
if (!strcmp(cepp->name, "name"))
|
||||
} else if (!strcmp(cepp->name, "name"))
|
||||
{
|
||||
safe_strdup(d->backend->dns->name, cepp->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &d->action);
|
||||
}
|
||||
else if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
d->ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
}
|
||||
else if (!strcmp(cep->name, "reason"))
|
||||
} else if (!strcmp(cep->name, "reason"))
|
||||
{
|
||||
safe_strdup(d->reason, cep->value);
|
||||
}
|
||||
else if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
conf_match_block(cf, cep, &d->except);
|
||||
}
|
||||
else if (!strcmp(cep->name, "recheck"))
|
||||
} else if (!strcmp(cep->name, "recheck"))
|
||||
{
|
||||
d->recheck = config_checkval(cep->value, CFG_YESNO);
|
||||
}
|
||||
}
|
||||
|
||||
AddListItem(d, conf_blacklist);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -591,11 +580,11 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::blacklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "recheck-time-first"))
|
||||
@@ -604,7 +593,7 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time-first with no value",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -621,17 +610,16 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (v < 60)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time-first cannot be less than 60 seconds",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "recheck-time"))
|
||||
} else if (!strcmp(cep->name, "recheck-time"))
|
||||
{
|
||||
int v;
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time with no value",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -641,19 +629,19 @@ int blacklist_set_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *er
|
||||
if (v < 60)
|
||||
{
|
||||
config_error("%s:%i: set::blacklist::recheck-time cannot be less than 60 seconds",
|
||||
cep->file->filename, cep->line_number);
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::blacklist::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -665,11 +653,11 @@ int blacklist_set_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::blacklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "blacklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "recheck-time"))
|
||||
@@ -739,7 +727,7 @@ int blacklist_start_check(Client *client, int recheck)
|
||||
if (bl->backend_type == BLACKLIST_BACKEND_DNS)
|
||||
blacklist_dns_request(client, bl);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -748,7 +736,7 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
char buf[256], wbuf[128];
|
||||
unsigned int e[8];
|
||||
char *ip = GetIP(client);
|
||||
|
||||
|
||||
if (!ip)
|
||||
return 0;
|
||||
|
||||
@@ -759,16 +747,15 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
/* IPv4 */
|
||||
if (sscanf(ip, "%u.%u.%u.%u", &e[0], &e[1], &e[2], &e[3]) != 4)
|
||||
return 0;
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "%u.%u.%u.%u.%s", e[3], e[2], e[1], e[0], d->backend->dns->name);
|
||||
} else
|
||||
if (strchr(ip, ':'))
|
||||
} else if (strchr(ip, ':'))
|
||||
{
|
||||
/* IPv6 */
|
||||
int i;
|
||||
BLUSER(client)->is_ipv6 = 1;
|
||||
if (sscanf(ip, "%x:%x:%x:%x:%x:%x:%x:%x",
|
||||
&e[0], &e[1], &e[2], &e[3], &e[4], &e[5], &e[6], &e[7]) != 8)
|
||||
&e[0], &e[1], &e[2], &e[3], &e[4], &e[5], &e[6], &e[7]) != 8)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -776,21 +763,20 @@ int blacklist_dns_request(Client *client, Blacklist *d)
|
||||
for (i = 7; i >= 0; i--)
|
||||
{
|
||||
snprintf(wbuf, sizeof(wbuf), "%x.%x.%x.%x.",
|
||||
(unsigned int)(e[i] & 0xf),
|
||||
(unsigned int)((e[i] >> 4) & 0xf),
|
||||
(unsigned int)((e[i] >> 8) & 0xf),
|
||||
(unsigned int)((e[i] >> 12) & 0xf));
|
||||
(unsigned int)(e[i] & 0xf),
|
||||
(unsigned int)((e[i] >> 4) & 0xf),
|
||||
(unsigned int)((e[i] >> 8) & 0xf),
|
||||
(unsigned int)((e[i] >> 12) & 0xf));
|
||||
strlcat(buf, wbuf, sizeof(buf));
|
||||
}
|
||||
strlcat(buf, d->backend->dns->name, sizeof(buf));
|
||||
}
|
||||
else
|
||||
} else
|
||||
return 0; /* unknown IP format */
|
||||
|
||||
BLUSER(client)->refcnt++; /* one (more) blacklist result remaining */
|
||||
|
||||
|
||||
unreal_gethostbyname_api(buf, AF_INET, "blacklist_resolver_callback", BLUSER(client));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -850,7 +836,7 @@ char *getdnsblname(char *p, Client *client)
|
||||
{
|
||||
dots++;
|
||||
if (dots == dots_count)
|
||||
return p+1;
|
||||
return p + 1;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -870,12 +856,12 @@ int blacklist_parse_reply(struct hostent *he, int entry)
|
||||
*ipbuf = '\0';
|
||||
if (!inet_ntop(AF_INET, he->h_addr_list[entry], ipbuf, sizeof(ipbuf)))
|
||||
return 0;
|
||||
|
||||
|
||||
p = strrchr(ipbuf, '.');
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
return atoi(p+1);
|
||||
|
||||
return atoi(p + 1);
|
||||
}
|
||||
|
||||
/** Take the actual ban action.
|
||||
@@ -908,10 +894,10 @@ void blacklist_hit(Client *client, Blacklist *bl, int reply)
|
||||
|
||||
if (IsUser(client))
|
||||
snprintf(opernotice, sizeof(opernotice), "[Blacklist] IP %s (%s) matches blacklist %s (%s/reply=%d)",
|
||||
GetIP(client), client->name, bl->name, bl->backend->dns->name, reply);
|
||||
GetIP(client), client->name, bl->name, bl->backend->dns->name, reply);
|
||||
else
|
||||
snprintf(opernotice, sizeof(opernotice), "[Blacklist] IP %s matches blacklist %s (%s/reply=%d)",
|
||||
GetIP(client), bl->name, bl->backend->dns->name, reply);
|
||||
GetIP(client), bl->name, bl->backend->dns->name, reply);
|
||||
|
||||
snprintf(reply_num, sizeof(reply_num), "%d", reply);
|
||||
|
||||
@@ -934,7 +920,8 @@ void blacklist_hit(Client *client, Blacklist *bl, int reply)
|
||||
safe_strdup(blu->save_blacklist_dns_name, bl->backend->dns->name);
|
||||
blu->save_blacklist_dns_reply = reply;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Otherwise, execute the action immediately */
|
||||
blacklist_action(client, opernotice, bl->action, banbuf, bl->ban_time, bl->name, bl->backend->dns->name, reply);
|
||||
}
|
||||
@@ -947,27 +934,27 @@ void blacklist_process_result(Client *client, int status, struct hostent *he)
|
||||
int reply;
|
||||
int i;
|
||||
int replycnt;
|
||||
|
||||
|
||||
if ((status != 0) || (he->h_length != 4) || !he->h_name)
|
||||
return; /* invalid reply */
|
||||
|
||||
|
||||
domain = getdnsblname(he->h_name, client);
|
||||
if (!domain)
|
||||
return; /* odd */
|
||||
bl = blacklist_find_block_by_dns(domain);
|
||||
if (!bl)
|
||||
return; /* possibly just rehashed and the blacklist block is gone now */
|
||||
|
||||
|
||||
/* walk through all replies for this record... until we have a hit */
|
||||
for (replycnt=0; he->h_addr_list[replycnt]; replycnt++)
|
||||
for (replycnt = 0; he->h_addr_list[replycnt]; replycnt++)
|
||||
{
|
||||
reply = blacklist_parse_reply(he, replycnt);
|
||||
|
||||
for (i = 0; bl->backend->dns->reply[i]; i++)
|
||||
{
|
||||
if ((bl->backend->dns->reply[i] == -1) ||
|
||||
( (bl->backend->dns->type == DNSBL_BITMASK) && (reply & bl->backend->dns->reply[i]) ) ||
|
||||
( (bl->backend->dns->type == DNSBL_RECORD) && (bl->backend->dns->reply[i] == reply) ) )
|
||||
((bl->backend->dns->type == DNSBL_BITMASK) && (reply & bl->backend->dns->reply[i])) ||
|
||||
((bl->backend->dns->type == DNSBL_RECORD) && (bl->backend->dns->reply[i] == reply)))
|
||||
{
|
||||
blacklist_hit(client, bl, reply);
|
||||
return;
|
||||
@@ -1043,9 +1030,9 @@ EVENT(blacklist_recheck)
|
||||
/* First time: check after 60 seconds already */
|
||||
blacklist_recheck_user(client);
|
||||
} else /* After that, check every <...> seconds */
|
||||
if (last_check && (TStime() - last_check) >= BLACKLIST_RECHECK_TIME)
|
||||
{
|
||||
blacklist_recheck_user(client);
|
||||
}
|
||||
if (last_check && (TStime() - last_check) >= BLACKLIST_RECHECK_TIME)
|
||||
{
|
||||
blacklist_recheck_user(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"bot-tag",
|
||||
"5.0",
|
||||
"bot message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"bot-tag",
|
||||
"5.0",
|
||||
"bot message tag",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
int bottag_mtag_is_ok(Client *client, const char *name, const char *value);
|
||||
void mtag_add_bottag(Client *client, MessageTag *recv_mtags, MessageTag **mtag_list, const char *signature);
|
||||
|
||||
+9
-10
@@ -24,20 +24,19 @@
|
||||
|
||||
CMD_FUNC(cmd_botmotd);
|
||||
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
#define MSG_BOTMOTD "BOTMOTD"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"botmotd",
|
||||
"5.0",
|
||||
"command /botmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"botmotd",
|
||||
"5.0",
|
||||
"command /botmotd",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CommandAdd(modinfo->handle, MSG_BOTMOTD, cmd_botmotd, MAXPARA, CMD_USER|CMD_SERVER);
|
||||
CommandAdd(modinfo->handle, MSG_BOTMOTD, cmd_botmotd, MAXPARA, CMD_USER | CMD_SERVER);
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
+24
-27
@@ -26,16 +26,15 @@ typedef int (*bqcmp)(const void *, const void *);
|
||||
|
||||
CMD_FUNC(cmd_cap);
|
||||
|
||||
#define MSG_CAP "CAP"
|
||||
#define MSG_CAP "CAP"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"cap", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cap", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"cap", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"command /cap", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cap_is_handshake_finished(Client *client);
|
||||
@@ -48,9 +47,9 @@ long CAP_NOTIFY = 0L;
|
||||
MOD_INIT()
|
||||
{
|
||||
ClientCapabilityInfo c;
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
CommandAdd(modinfo->handle, MSG_CAP, cmd_cap, MAXPARA, CMD_UNREGISTERED|CMD_USER|CMD_NOLAG);
|
||||
CommandAdd(modinfo->handle, MSG_CAP, cmd_cap, MAXPARA, CMD_UNREGISTERED | CMD_USER | CMD_NOLAG);
|
||||
|
||||
/* This first cap is special, in the sense that it is hidden
|
||||
* and indicates a cap exchange is in progress.
|
||||
@@ -100,7 +99,7 @@ static ClientCapability *clicap_find(Client *client, const char *data, int *nega
|
||||
return NULL;
|
||||
|
||||
/* skip any whitespace */
|
||||
while(*p && isspace(*p))
|
||||
while (*p && isspace(*p))
|
||||
p++;
|
||||
|
||||
if (BadPtr(p))
|
||||
@@ -125,7 +124,7 @@ static ClientCapability *clicap_find(Client *client, const char *data, int *nega
|
||||
cap = ClientCapabilityFind(p, client);
|
||||
if (!s)
|
||||
*finished = 1;
|
||||
|
||||
|
||||
p = s; /* point to next token for next iteration */
|
||||
|
||||
if (cap && (cap->flags & CLICAP_FLAGS_ADVERTISE_ONLY))
|
||||
@@ -146,7 +145,7 @@ static void clicap_generate(Client *client, const char *subcmd, int flags)
|
||||
int buflen = 0;
|
||||
int curlen, mlen;
|
||||
|
||||
mlen = snprintf(buf, BUFSIZE, ":%s CAP %s %s", me.name, BadPtr(client->name) ? "*" : client->name, subcmd);
|
||||
mlen = snprintf(buf, BUFSIZE, ":%s CAP %s %s", me.name, BadPtr(client->name) ? "*" : client->name, subcmd);
|
||||
|
||||
p = capbuf;
|
||||
buflen = mlen;
|
||||
@@ -259,13 +258,13 @@ static void cap_req(Client *client, const char *arg)
|
||||
return;
|
||||
|
||||
buflen = snprintf(buf, sizeof(buf), ":%s CAP %s ACK",
|
||||
me.name, BadPtr(client->name) ? "*" : client->name);
|
||||
me.name, BadPtr(client->name) ? "*" : client->name);
|
||||
|
||||
pbuf[0][0] = '\0';
|
||||
plen = 0;
|
||||
|
||||
for(cap = clicap_find(client, arg, &negate, &finished, &errors); cap;
|
||||
cap = clicap_find(client, NULL, &negate, &finished, &errors))
|
||||
for (cap = clicap_find(client, arg, &negate, &finished, &errors); cap;
|
||||
cap = clicap_find(client, NULL, &negate, &finished, &errors))
|
||||
{
|
||||
/* filled the first array, but cant send it in case the
|
||||
* request fails. one REQ should never fill more than two
|
||||
@@ -284,8 +283,7 @@ static void cap_req(Client *client, const char *arg)
|
||||
plen++;
|
||||
|
||||
capdel |= cap->cap;
|
||||
}
|
||||
else
|
||||
} else
|
||||
{
|
||||
capadd |= cap->cap;
|
||||
}
|
||||
@@ -309,8 +307,7 @@ static void cap_req(Client *client, const char *arg)
|
||||
{
|
||||
sendto_one(client, NULL, "%s * :%s", buf, pbuf[0]);
|
||||
sendto_one(client, NULL, "%s :%s", buf, pbuf[1]);
|
||||
}
|
||||
else
|
||||
} else
|
||||
sendto_one(client, NULL, "%s :%s", buf, pbuf[0]);
|
||||
|
||||
client->local->caps |= capadd;
|
||||
@@ -323,10 +320,10 @@ struct clicap_cmd {
|
||||
};
|
||||
|
||||
static struct clicap_cmd clicap_cmdtable[] = {
|
||||
{ "END", cap_end },
|
||||
{ "LIST", cap_list },
|
||||
{ "LS", cap_ls },
|
||||
{ "REQ", cap_req },
|
||||
{"END", cap_end},
|
||||
{"LIST", cap_list},
|
||||
{"LS", cap_ls},
|
||||
{"REQ", cap_req},
|
||||
};
|
||||
|
||||
static int clicap_cmd_search(const char *command, struct clicap_cmd *entry)
|
||||
@@ -380,8 +377,8 @@ CMD_FUNC(cmd_cap)
|
||||
}
|
||||
|
||||
if (!(cmd = bsearch(parv[1], clicap_cmdtable,
|
||||
sizeof(clicap_cmdtable) / sizeof(struct clicap_cmd),
|
||||
sizeof(struct clicap_cmd), (bqcmp) clicap_cmd_search)))
|
||||
sizeof(clicap_cmdtable) / sizeof(struct clicap_cmd),
|
||||
sizeof(struct clicap_cmd), (bqcmp)clicap_cmd_search)))
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDCAPCMD, parv[1]);
|
||||
|
||||
|
||||
+26
-30
@@ -5,14 +5,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"central-api",
|
||||
"1.0.2",
|
||||
"Acquire and set API key for unrealircd.org services",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"central-api",
|
||||
"1.0.2",
|
||||
"Acquire and set API key for unrealircd.org services",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
struct cfgstruct {
|
||||
char *request_key_challenge;
|
||||
@@ -83,20 +82,19 @@ int capi_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-api.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-api"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::central-api::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "request-key"))
|
||||
} else if (!strcmp(cep->name, "request-key"))
|
||||
{
|
||||
char *p = strchr(cep->value, '-');
|
||||
if (!p)
|
||||
@@ -107,29 +105,28 @@ int capi_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
errors++;
|
||||
}
|
||||
req.request_key = 1;
|
||||
|
||||
} else
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
|
||||
} else if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
if (!strchr(cep->value, ':'))
|
||||
{
|
||||
config_error("%s:%i: set::central-api::api-key: Invalid format. "
|
||||
"Please check if you copy-pasted the api-key correctly. "
|
||||
"You can log in at your account to view API keys at "
|
||||
"https://www.unrealircd.org/central-api/account/",
|
||||
cep->file->filename, cep->line_number);
|
||||
"Please check if you copy-pasted the api-key correctly. "
|
||||
"You can log in at your account to view API keys at "
|
||||
"https://www.unrealircd.org/central-api/account/",
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
}
|
||||
req.api_key = 1;
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-api::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -143,7 +140,7 @@ int capi_config_posttest(int *errs)
|
||||
config_error("You need to set either set::central-api::request-key or set::central-api::api-key (not both or none).");
|
||||
config_error("See https://www.unrealircd.org/docs/Central_API for the documentation");
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
@@ -166,9 +163,9 @@ char *capi_hash(const char *in)
|
||||
static char hashbuf[128];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s:%s:%s",
|
||||
CAPI_HASH_STRING_PREFIX,
|
||||
in,
|
||||
CAPI_HASH_STRING_SUFFIX);
|
||||
CAPI_HASH_STRING_PREFIX,
|
||||
in,
|
||||
CAPI_HASH_STRING_SUFFIX);
|
||||
return sha256hash(hashbuf, buf, strlen(buf));
|
||||
}
|
||||
|
||||
@@ -179,11 +176,11 @@ int capi_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-api.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-api"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "request-key"))
|
||||
@@ -198,8 +195,7 @@ int capi_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
safe_strdup(cfg.request_key_challenge, capi_hash(buf));
|
||||
safe_strdup(cfg.request_key_response, capi_hash(p));
|
||||
} else
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
} else if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
safe_strdup(cfg.api_key, cep->value);
|
||||
}
|
||||
|
||||
+104
-118
@@ -5,29 +5,27 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"central-blocklist",
|
||||
"1.0.8",
|
||||
"Check users at central blocklist",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"central-blocklist",
|
||||
"1.0.8",
|
||||
"Check users at central blocklist",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
ModDataInfo *centralblocklist_md = NULL;
|
||||
Module *cbl_module = NULL;
|
||||
|
||||
#define CBL_URL "https://centralblocklist.unrealircd-api.org/api/v1"
|
||||
#define SPAMREPORT_URL "https://spamreport.unrealircd-api.org/api/spamreport-v1"
|
||||
#define CBL_TRANSFER_TIMEOUT 10
|
||||
#define CBL_URL "https://centralblocklist.unrealircd-api.org/api/v1"
|
||||
#define SPAMREPORT_URL "https://spamreport.unrealircd-api.org/api/spamreport-v1"
|
||||
#define CBL_TRANSFER_TIMEOUT 10
|
||||
#define SPAMREPORT_NUM_REMEMBERED_CMDS 20
|
||||
|
||||
#define WEB(client) ((WebRequest *)moddata_local_client(client, webserver_md).ptr)
|
||||
#define WSU(client) ((WebSocketUser *)moddata_client(client, websocket_md).ptr)
|
||||
#define WEB(client) ((WebRequest *)moddata_local_client(client, webserver_md).ptr)
|
||||
#define WSU(client) ((WebSocketUser *)moddata_client(client, websocket_md).ptr)
|
||||
|
||||
typedef struct CBLUser CBLUser;
|
||||
struct CBLUser
|
||||
{
|
||||
struct CBLUser {
|
||||
json_t *handshake;
|
||||
time_t request_sent;
|
||||
char request_pending;
|
||||
@@ -39,8 +37,7 @@ struct CBLUser
|
||||
|
||||
/* For tracking current HTTPS requests */
|
||||
typedef struct CBLTransfer CBLTransfer;
|
||||
struct CBLTransfer
|
||||
{
|
||||
struct CBLTransfer {
|
||||
CBLTransfer *prev, *next;
|
||||
time_t started;
|
||||
NameList *clients;
|
||||
@@ -96,19 +93,26 @@ void send_request_for_pending_clients(void);
|
||||
const char *get_api_key(void);
|
||||
void set_tag(Client *client, const char *tag, int value);
|
||||
|
||||
#define CBLRAW(x) (moddata_local_client(x, centralblocklist_md).ptr)
|
||||
#define CBL(x) ((CBLUser *)(moddata_local_client(x, centralblocklist_md).ptr))
|
||||
#define CBLRAW(x) (moddata_local_client(x, centralblocklist_md).ptr)
|
||||
#define CBL(x) ((CBLUser *)(moddata_local_client(x, centralblocklist_md).ptr))
|
||||
|
||||
#define alloc_cbl_if_needed(x) do { \
|
||||
if (!moddata_local_client(x, centralblocklist_md).ptr) \
|
||||
{ \
|
||||
CBLUser *u = safe_alloc(sizeof(CBLUser)); \
|
||||
u->handshake = json_object(); \
|
||||
moddata_local_client(x, centralblocklist_md).ptr = u; \
|
||||
} \
|
||||
} while(0)
|
||||
#define alloc_cbl_if_needed(x) \
|
||||
do \
|
||||
{ \
|
||||
if (!moddata_local_client(x, centralblocklist_md).ptr) \
|
||||
{ \
|
||||
CBLUser *u = safe_alloc(sizeof(CBLUser)); \
|
||||
u->handshake = json_object(); \
|
||||
moddata_local_client(x, centralblocklist_md).ptr = u; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define AddScoreAction(item,list) do { item->priority = 0 - item->score; AddListItemPrio(item, list, item->priority); } while(0)
|
||||
#define AddScoreAction(item, list) \
|
||||
do \
|
||||
{ \
|
||||
item->priority = 0 - item->score; \
|
||||
AddListItemPrio(item, list, item->priority); \
|
||||
} while (0)
|
||||
|
||||
CMD_OVERRIDE_FUNC(cbl_override);
|
||||
CMD_OVERRIDE_FUNC(cbl_override_spamreport_gather);
|
||||
@@ -244,7 +248,8 @@ MOD_LOAD()
|
||||
"Acquire a key via https://www.unrealircd.org/central-api/ and then "
|
||||
"make sure the central-api-key module is loaded and set::central-api::api-key set.");
|
||||
return MOD_SUCCESS;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
safe_strdup(cfg.api_key, central_api_key);
|
||||
}
|
||||
|
||||
@@ -284,11 +289,11 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-blocklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-blocklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
@@ -298,18 +303,16 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
"central-api module and put the key in set::central-api::api-key",
|
||||
cep->file->filename, cep->line_number);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
test_match_block(cf, cep, &errors);
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 99))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::score: must be between 1 - 99 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
if (cep->items)
|
||||
@@ -320,32 +323,27 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!strcmp(cepp->name, "ban-action"))
|
||||
{
|
||||
errors += test_ban_action_config(cepp);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-reason"))
|
||||
} else if (!strcmp(cepp->name, "ban-reason"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-time"))
|
||||
} else if (!strcmp(cepp->name, "ban-time"))
|
||||
{
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-blocklist::score::%s",
|
||||
cepp->file->filename, cepp->line_number, cepp->name);
|
||||
cepp->file->filename, cepp->line_number, cepp->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!cep->value)
|
||||
} else if (!cep->value)
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::%s with no value",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "url"))
|
||||
} else if (!strcmp(cep->name, "url"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport") || !strcmp(cep->name, "spamreport-enabled"))
|
||||
} else if (!strcmp(cep->name, "spamreport") || !strcmp(cep->name, "spamreport-enabled"))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::%s: This setting is deprecated. "
|
||||
"Please remove this setting, and, if you wish to use spamreport, add a "
|
||||
@@ -353,24 +351,20 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
"See https://www.unrealircd.org/docs/Central_spamreport",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
} else
|
||||
if (!strcmp(cep->name, "blocklist") || !strcmp(cep->name, "blocklist-enabled"))
|
||||
} else if (!strcmp(cep->name, "blocklist") || !strcmp(cep->name, "blocklist-enabled"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport-url"))
|
||||
} else if (!strcmp(cep->name, "spamreport-url"))
|
||||
{
|
||||
} else
|
||||
if (!strcmp(cep->name, "max-downloads"))
|
||||
} else if (!strcmp(cep->name, "max-downloads"))
|
||||
{
|
||||
int v = atoi(cep->value);
|
||||
if ((v < 1) || (v > 500))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist::score: must be between 1 - 500 (got: %d)",
|
||||
cep->file->filename, cep->line_number, v);
|
||||
cep->file->filename, cep->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "ban-reason") || !strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-action") || !strcmp(cep->name, "ban-reason") || !strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
config_error("%s:%i: set::central-blocklist: you cannot use ban-action/ban-reason/ban-time here. "
|
||||
"There are now multiple score blocks. "
|
||||
@@ -380,12 +374,12 @@ int cbl_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error("%s:%i: unknown directive set::central-blocklist::%s",
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
cep->file->filename, cep->line_number, cep->name);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -405,18 +399,17 @@ int cbl_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_SET)
|
||||
return 0;
|
||||
|
||||
|
||||
/* We are only interrested in set::central-blocklist.. */
|
||||
if (!ce || !ce->name || strcmp(ce->name, "central-blocklist"))
|
||||
return 0;
|
||||
|
||||
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
if (!strcmp(cep->name, "api-key"))
|
||||
{
|
||||
safe_strdup(cfg.api_key, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "score"))
|
||||
} else if (!strcmp(cep->name, "score"))
|
||||
{
|
||||
if (!cep->items)
|
||||
{
|
||||
@@ -433,47 +426,37 @@ int cbl_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cepp->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cepp, &action->ban_action);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-reason"))
|
||||
} else if (!strcmp(cepp->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(action->ban_reason, cepp->value);
|
||||
} else
|
||||
if (!strcmp(cepp->name, "ban-time"))
|
||||
} else if (!strcmp(cepp->name, "ban-time"))
|
||||
{
|
||||
action->ban_time = config_checkval(cepp->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep->name, "url"))
|
||||
} else if (!strcmp(cep->name, "url"))
|
||||
{
|
||||
safe_strdup(cfg.url, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "blocklist-enabled"))
|
||||
} else if (!strcmp(cep->name, "blocklist-enabled"))
|
||||
{
|
||||
cfg.blocklist_enabled = config_checkval(cep->value, CFG_YESNO);
|
||||
} else
|
||||
if (!strcmp(cep->name, "spamreport-url"))
|
||||
} else if (!strcmp(cep->name, "spamreport-url"))
|
||||
{
|
||||
safe_strdup(cfg.spamreport_url, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "max-downloads"))
|
||||
} else if (!strcmp(cep->name, "max-downloads"))
|
||||
{
|
||||
cfg.max_downloads = atoi(cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-action"))
|
||||
} else if (!strcmp(cep->name, "ban-action"))
|
||||
{
|
||||
parse_ban_action_config(cep, &cfg.actions->ban_action);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-reason"))
|
||||
} else if (!strcmp(cep->name, "ban-reason"))
|
||||
{
|
||||
safe_strdup(cfg.actions->ban_reason, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "ban-time"))
|
||||
} else if (!strcmp(cep->name, "ban-time"))
|
||||
{
|
||||
cfg.actions->ban_time = config_checkval(cep->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(cep->name, "except"))
|
||||
} else if (!strcmp(cep->name, "except"))
|
||||
{
|
||||
if (cfg.except)
|
||||
{
|
||||
@@ -543,9 +526,9 @@ EVENT(centralblocklist_timeout_evt)
|
||||
(TStime() - cbl->request_sent > CBL_TRANSFER_TIMEOUT))
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TIMEOUT", client,
|
||||
"Central blocklist too slow to respond. "
|
||||
"Possible problem with infrastructure at unrealircd.org. "
|
||||
"Allowing user $client.details in unchecked.");
|
||||
"Central blocklist too slow to respond. "
|
||||
"Possible problem with infrastructure at unrealircd.org. "
|
||||
"Allowing user $client.details in unchecked.");
|
||||
cbl_allow(client);
|
||||
}
|
||||
}
|
||||
@@ -560,14 +543,14 @@ void show_client_json(Client *client)
|
||||
json_serialized = json_dumps(CBL(client)->handshake, JSON_COMPACT);
|
||||
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST", client,
|
||||
"OUT: $data",
|
||||
log_data_string("data", json_serialized));
|
||||
"OUT: $data",
|
||||
log_data_string("data", json_serialized));
|
||||
safe_free(json_serialized);
|
||||
}
|
||||
|
||||
void cbl_add_client_info(Client *client)
|
||||
{
|
||||
char buf[BUFSIZE+1];
|
||||
char buf[BUFSIZE + 1];
|
||||
json_t *cbl = CBL(client)->handshake;
|
||||
json_t *child = json_object();
|
||||
const char *str;
|
||||
@@ -576,7 +559,7 @@ void cbl_add_client_info(Client *client)
|
||||
json_object_set_new(cbl, "client", child);
|
||||
|
||||
//// THE FOLLOWING IS TAKEN FROM src/json.c AND MODIFIED /////
|
||||
|
||||
|
||||
/* First the information that is available for ALL client types: */
|
||||
json_object_set_new(child, "name", json_string_unreal(client->name));
|
||||
json_object_set_new(child, "id", json_string_unreal(client->id));
|
||||
@@ -599,13 +582,15 @@ void cbl_add_client_info(Client *client)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s!%s@%s", client->name, client->user->username, client->user->realhost);
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else if (client->ip) {
|
||||
} else if (client->ip)
|
||||
{
|
||||
if (*client->name)
|
||||
snprintf(buf, sizeof(buf), "%s@%s", client->name, client->ip);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "[%s]", client->ip);
|
||||
json_object_set_new(child, "details", json_string_unreal(buf));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
json_object_set_new(child, "details", json_string_unreal(client->name));
|
||||
}
|
||||
|
||||
@@ -670,13 +655,13 @@ void cbl_add_client_info(Client *client)
|
||||
{
|
||||
json_t *j = json_object();
|
||||
json_object_set_new(child, "tcp_info", j);
|
||||
json_object_set_new(j, "rtt", json_integer(MAX(tcp_info.tcpi_rtt,1)/1000));
|
||||
json_object_set_new(j, "rtt_var", json_integer(MAX(tcp_info.tcpi_rttvar,1)/1000));
|
||||
#if defined(__FreeBSD__)
|
||||
json_object_set_new(j, "rtt", json_integer(MAX(tcp_info.tcpi_rtt, 1) / 1000));
|
||||
json_object_set_new(j, "rtt_var", json_integer(MAX(tcp_info.tcpi_rttvar, 1) / 1000));
|
||||
#if defined(__FreeBSD__)
|
||||
json_object_set_new(j, "pmtu", json_integer(tcp_info.__tcpi_pmtu));
|
||||
#else
|
||||
#else
|
||||
json_object_set_new(j, "pmtu", json_integer(tcp_info.tcpi_pmtu));
|
||||
#endif
|
||||
#endif
|
||||
json_object_set_new(j, "snd_cwnd", json_integer(tcp_info.tcpi_snd_cwnd));
|
||||
json_object_set_new(j, "snd_mss", json_integer(tcp_info.tcpi_snd_mss));
|
||||
json_object_set_new(j, "rcv_mss", json_integer(tcp_info.tcpi_rcv_mss));
|
||||
@@ -737,8 +722,7 @@ CMD_OVERRIDE_FUNC(cbl_override)
|
||||
{
|
||||
isnick = 1;
|
||||
nospoof = client->local->nospoof;
|
||||
} else
|
||||
if (!strcmp(ovr->command->cmd, "PONG") && (parc > 1) && !BadPtr(parv[1]))
|
||||
} else if (!strcmp(ovr->command->cmd, "PONG") && (parc > 1) && !BadPtr(parv[1]))
|
||||
{
|
||||
unsigned long result = strtoul(parv[1], NULL, 16);
|
||||
if (client->local->nospoof && (client->local->nospoof == result))
|
||||
@@ -858,12 +842,13 @@ void cbl_handle_response(Client *client, json_t *response)
|
||||
if (highest_ban_action(action->ban_action) <= BAN_ACT_WARN)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CBL_HIT", client,
|
||||
"CBL: Client $client.details flagged by central-blocklist, but allowed in (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
} else {
|
||||
"CBL: Client $client.details flagged by central-blocklist, but allowed in (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
} else
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CBL_HIT_REJECTED_USER", client,
|
||||
"CBL: Client $client.details is rejected by central-blocklist (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
"CBL: Client $client.details is rejected by central-blocklist (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
}
|
||||
if (take_action(client, action->ban_action, action->ban_reason, action->ban_time, 0, NULL) <= BAN_ACT_WARN)
|
||||
cbl_allow(client);
|
||||
@@ -871,8 +856,8 @@ void cbl_handle_response(Client *client, json_t *response)
|
||||
}
|
||||
}
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST", client,
|
||||
"CBL: Client $client.details is allowed (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
"CBL: Client $client.details is allowed (score $spam_score)",
|
||||
log_data_integer("spam_score", spam_score));
|
||||
cbl_allow(client);
|
||||
}
|
||||
|
||||
@@ -890,17 +875,17 @@ void cbl_error_response(CBLTransfer *transfer, const char *error)
|
||||
if (CBL(client) && CBL(client)->allowed_in)
|
||||
continue; /* Client allowed in already (eg due to timeout) */
|
||||
unreal_log(ULOG_DEBUG, "central-blocklist", "DEBUG_CENTRAL_BLOCKLIST_ERROR", client,
|
||||
"CBL: Client $client.details allowed in due to CBL error: $error",
|
||||
log_data_string("error", error));
|
||||
"CBL: Client $client.details allowed in due to CBL error: $error",
|
||||
log_data_string("error", error));
|
||||
cbl_allow(client);
|
||||
num++;
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
unreal_log(ULOG_INFO, "central-blocklist", "CENTRAL_BLOCKLIST_ERROR", NULL,
|
||||
"CBL: Allowed $num_clients client(s) in due to CBL error: $error",
|
||||
log_data_integer("num_clients", num),
|
||||
log_data_string("error", error));
|
||||
"CBL: Allowed $num_clients client(s) in due to CBL error: $error",
|
||||
log_data_integer("num_clients", num),
|
||||
log_data_string("error", error));
|
||||
}
|
||||
del_cbl_transfer(transfer);
|
||||
}
|
||||
@@ -1021,8 +1006,8 @@ void send_request_for_pending_clients(void)
|
||||
if (num > cfg.max_downloads)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TOO_MANY_CONCURRENT_REQUESTS", NULL,
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1051,7 +1036,7 @@ void send_request_for_pending_clients(void)
|
||||
if (!json_serialized)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_BUG_SERIALIZE", client,
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
json_decref(j);
|
||||
free_entire_name_list(clientlist);
|
||||
return;
|
||||
@@ -1116,7 +1101,8 @@ CMD_OVERRIDE_FUNC(cbl_override_spamreport_gather)
|
||||
if (clictx && clictx->textanalysis)
|
||||
{
|
||||
memcpy(&CBL(client)->last_cmds_textanalysis[slot], clictx->textanalysis, sizeof(TextAnalysis));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
memset(&CBL(client)->last_cmds_textanalysis[slot], 0, sizeof(TextAnalysis));
|
||||
}
|
||||
CBL(client)->last_cmds_slot++;
|
||||
@@ -1149,8 +1135,8 @@ int _central_spamreport(Client *client, Client *by, const char *url)
|
||||
if (num > cfg.max_downloads)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_TOO_MANY_CONCURRENT_REQUESTS", NULL,
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
"Already $num_requests HTTP(S) requests in progress.",
|
||||
log_data_integer("num_requests", num));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1206,7 +1192,7 @@ int _central_spamreport(Client *client, Client *by, const char *url)
|
||||
if (!json_serialized)
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "central-blocklist", "CENTRAL_BLOCKLIST_BUG_SERIALIZE", client,
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
"Unable to serialize JSON request. Weird.");
|
||||
json_decref(j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+12
-12
@@ -11,14 +11,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"certfp",
|
||||
"5.0",
|
||||
"Certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"certfp",
|
||||
"5.0",
|
||||
"Certificate fingerprint",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
void certfp_free(ModData *m);
|
||||
@@ -36,7 +35,7 @@ MOD_INIT()
|
||||
ModDataInfo mreq;
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "certfp";
|
||||
mreq.free = certfp_free;
|
||||
@@ -83,12 +82,13 @@ char *get_fingerprint_for_client(Client *client)
|
||||
|
||||
if (!MyConnect(client) || !client->local->ssl)
|
||||
return NULL;
|
||||
|
||||
|
||||
x509_clientcert = SSL_get_peer_certificate(client->local->ssl);
|
||||
|
||||
if (x509_clientcert)
|
||||
{
|
||||
if (X509_digest(x509_clientcert, digest, md, &n)) {
|
||||
if (X509_digest(x509_clientcert, digest, md, &n))
|
||||
{
|
||||
binarytohex(md, n, hex);
|
||||
X509_free(x509_clientcert);
|
||||
return hex;
|
||||
@@ -117,7 +117,7 @@ int certfp_connect(Client *client)
|
||||
if (IsSecure(client))
|
||||
{
|
||||
const char *fp = moddata_client_get(client, "certfp");
|
||||
|
||||
|
||||
if (fp && !iConf.no_connect_tls_info)
|
||||
sendnotice(client, "*** Your TLS certificate fingerprint is %s", fp);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/censor",
|
||||
"4.2",
|
||||
"Channel Mode +G",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/censor",
|
||||
"4.2",
|
||||
"Channel Mode +G",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
|
||||
Cmode_t EXTMODE_CENSOR = 0L;
|
||||
@@ -37,7 +36,7 @@ MOD_TEST()
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CONFIGTEST, 0, censor_config_test);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
@@ -87,24 +86,24 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "badword"))
|
||||
return 0; /* not interested */
|
||||
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error("%s:%i: badword without type",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
*errs = 1;
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(ce->value, "channel") &&
|
||||
strcmp(ce->value, "quit") && strcmp(ce->value, "all")) {
|
||||
} else if (strcmp(ce->value, "channel") &&
|
||||
strcmp(ce->value, "quit") && strcmp(ce->value, "all"))
|
||||
{
|
||||
/* config_error("%s:%i: badword with unknown type",
|
||||
ce->file->filename, ce->line_number); -- can't do that.. */
|
||||
return 0; /* unhandled */
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp(ce->value, "quit"))
|
||||
{
|
||||
config_error("%s:%i: badword quit has been removed. We just use the bad words from "
|
||||
@@ -125,36 +124,34 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
const char *errbuf;
|
||||
if (has_word)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::word");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::word");
|
||||
continue;
|
||||
}
|
||||
has_word = 1;
|
||||
if ((errbuf = badword_config_check_regex(cep->value,1,1)))
|
||||
if ((errbuf = badword_config_check_regex(cep->value, 1, 1)))
|
||||
{
|
||||
config_error("%s:%i: badword::%s contains an invalid regex: %s",
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
cep->name, errbuf);
|
||||
cep->file->filename,
|
||||
cep->line_number,
|
||||
cep->name, errbuf);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "replace"))
|
||||
} else if (!strcmp(cep->name, "replace"))
|
||||
{
|
||||
if (has_replace)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::replace");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::replace");
|
||||
continue;
|
||||
}
|
||||
has_replace = 1;
|
||||
}
|
||||
else if (!strcmp(cep->name, "action"))
|
||||
} else if (!strcmp(cep->name, "action"))
|
||||
{
|
||||
if (has_action)
|
||||
{
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::action");
|
||||
config_warn_duplicate(cep->file->filename,
|
||||
cep->line_number, "badword::action");
|
||||
continue;
|
||||
}
|
||||
has_action = 1;
|
||||
@@ -165,16 +162,15 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
else
|
||||
{
|
||||
config_error("%s:%d: Unknown badword::action '%s'",
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
cep->file->filename, cep->line_number,
|
||||
cep->value);
|
||||
errors++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"badword", cep->name);
|
||||
"badword", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +178,7 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!has_word)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"badword::word");
|
||||
"badword::word");
|
||||
errors++;
|
||||
}
|
||||
if (has_action)
|
||||
@@ -190,11 +186,11 @@ int censor_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (has_replace && action == 'b')
|
||||
{
|
||||
config_error("%s:%i: badword::action is block but badword::replace exists",
|
||||
ce->file->filename, ce->line_number);
|
||||
ce->file->filename, ce->line_number);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -207,12 +203,12 @@ int censor_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
|
||||
if (type != CONFIG_MAIN)
|
||||
return 0;
|
||||
|
||||
|
||||
if (!ce || !ce->name || strcmp(ce->name, "badword"))
|
||||
return 0; /* not interested */
|
||||
|
||||
if (strcmp(ce->value, "channel") && strcmp(ce->value, "all"))
|
||||
return 0; /* not for us */
|
||||
return 0; /* not for us */
|
||||
|
||||
ca = safe_alloc(sizeof(ConfigItem_badword));
|
||||
ca->action = BADWORD_REPLACE;
|
||||
@@ -225,12 +221,10 @@ int censor_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
{
|
||||
ca->action = BADWORD_BLOCK;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(cep->name, "replace"))
|
||||
} else if (!strcmp(cep->name, "replace"))
|
||||
{
|
||||
safe_strdup(ca->replace, cep->value);
|
||||
} else
|
||||
if (!strcmp(cep->name, "word"))
|
||||
} else if (!strcmp(cep->name, "word"))
|
||||
{
|
||||
word = cep;
|
||||
}
|
||||
@@ -330,9 +324,9 @@ int censor_stats_badwords_channel(Client *client, const char *para)
|
||||
for (words = conf_badword_channel; words; words = words->next)
|
||||
{
|
||||
sendtxtnumeric(client, "c %c %s%s%s %s", words->type & BADW_TYPE_REGEX ? 'R' : 'F',
|
||||
(words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word,
|
||||
(words->type & BADW_TYPE_FAST_R) ? "*" : "",
|
||||
words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : "");
|
||||
(words->type & BADW_TYPE_FAST_L) ? "*" : "", words->word,
|
||||
(words->type & BADW_TYPE_FAST_R) ? "*" : "",
|
||||
words->action == BADWORD_REPLACE ? (words->replace ? words->replace : "<censored>") : "");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanadmin",
|
||||
"6.0",
|
||||
"Channel Mode +a",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanadmin",
|
||||
"6.0",
|
||||
"Channel Mode +a",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanadmin_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanop",
|
||||
"6.0",
|
||||
"Channel Mode +o",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanop",
|
||||
"6.0",
|
||||
"Channel Mode +o",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanop_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/chanowner",
|
||||
"6.0",
|
||||
"Channel Mode +q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/chanowner",
|
||||
"6.0",
|
||||
"Channel Mode +q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_chanowner_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -5,16 +5,15 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/delayjoin", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"delayed join (+D,+d)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/delayjoin", /* Name of module */
|
||||
"5.0", /* Version */
|
||||
"delayed join (+D,+d)", /* Short description of module */
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
#define MOD_DATA_STR "delayjoin"
|
||||
#define MOD_DATA_STR "delayjoin"
|
||||
#define MOD_DATA_INVISIBLE "1"
|
||||
|
||||
static long UMODE_PRIVDEAF = 0;
|
||||
@@ -130,12 +129,12 @@ void clear_user_invisible_announce(Channel *channel, Client *client, MessageTag
|
||||
set_user_invisible(client, channel, 0);
|
||||
|
||||
ircsnprintf(joinbuf, sizeof(joinbuf), ":%s!%s@%s JOIN %s",
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
client->name, client->user->username, GetHost(client), channel->name);
|
||||
|
||||
ircsnprintf(exjoinbuf, sizeof(exjoinbuf), ":%s!%s@%s JOIN %s %s :%s",
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
client->name, client->user->username, GetHost(client), channel->name,
|
||||
IsLoggedIn(client) ? client->user->account : "*",
|
||||
client->info);
|
||||
|
||||
new_message_special(client, recv_mtags, &mtags, ":%s JOIN %s", client->name, channel->name);
|
||||
for (i = channel->members; i; i = i->next)
|
||||
@@ -153,7 +152,7 @@ void clear_user_invisible_announce(Channel *channel, Client *client, MessageTag
|
||||
|
||||
/* If this was the last invisible user to become visible, then set -d */
|
||||
if ((channel->mode.mode & EXTMODE_POST_DELAYED) && !channel_has_invisible_users(channel))
|
||||
clear_post_delayed(channel);
|
||||
clear_post_delayed(channel);
|
||||
}
|
||||
|
||||
int delayjoin_is_ok(Client *client, Channel *channel, char mode, const char *para, int checkt, int what)
|
||||
@@ -176,7 +175,7 @@ int moded_part(Client *client, Channel *channel, MessageTag *mtags, const char *
|
||||
{
|
||||
set_user_invisible(client, channel, 0);
|
||||
if (!channel_has_invisible_users(channel))
|
||||
clear_post_delayed(channel);
|
||||
clear_post_delayed(channel);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -186,7 +185,7 @@ int moded_quit(Client *client, MessageTag *mtags, const char *comment)
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
|
||||
for (membership = client->user->channel; membership; membership=membership->next)
|
||||
for (membership = client->user->channel; membership; membership = membership->next)
|
||||
{
|
||||
channel = membership->channel;
|
||||
/* Identical to moded_part() */
|
||||
@@ -244,8 +243,8 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
{
|
||||
if (pm.what == MODE_ADD && (pm.modechar == 'o' || pm.modechar == 'h' || pm.modechar == 'a' || pm.modechar == 'q' || pm.modechar == 'v'))
|
||||
{
|
||||
Member* i;
|
||||
Client *user = find_client(pm.param,NULL);
|
||||
Member *i;
|
||||
Client *user = find_client(pm.param, NULL);
|
||||
if (!user)
|
||||
continue;
|
||||
|
||||
@@ -271,18 +270,18 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
channel->name,
|
||||
IsLoggedIn(i->client) ? i->client->user->account : "*",
|
||||
i->client->info);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendto_one(user, mtags, ":%s!%s@%s JOIN :%s", i->client->name, i->client->user->username, GetHost(i->client), channel->name);
|
||||
}
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (pm.what == MODE_DEL && (pm.modechar == 'o' || pm.modechar == 'h' || pm.modechar == 'a' || pm.modechar == 'q' || pm.modechar == 'v'))
|
||||
{
|
||||
Member* i;
|
||||
Client *user = find_client(pm.param,NULL);
|
||||
Member *i;
|
||||
Client *user = find_client(pm.param, NULL);
|
||||
if (!user)
|
||||
continue;
|
||||
|
||||
@@ -305,7 +304,6 @@ int moded_chanmode(Client *client, Channel *channel, MessageTag *recv_mtags, con
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+135
-132
@@ -19,26 +19,25 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/floodprot",
|
||||
"6.0",
|
||||
"Channel Mode +f and +F",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/floodprot",
|
||||
"6.0",
|
||||
"Channel Mode +f and +F",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef enum Flood {
|
||||
CHFLD_CTCP = 0,
|
||||
CHFLD_JOIN = 1,
|
||||
CHFLD_KNOCK = 2,
|
||||
CHFLD_MSG = 3,
|
||||
CHFLD_NICK = 4,
|
||||
CHFLD_TEXT = 5,
|
||||
CHFLD_REPEAT = 6,
|
||||
CHFLD_PASTE = 7,
|
||||
CHFLD_CTCP = 0,
|
||||
CHFLD_JOIN = 1,
|
||||
CHFLD_KNOCK = 2,
|
||||
CHFLD_MSG = 3,
|
||||
CHFLD_NICK = 4,
|
||||
CHFLD_TEXT = 5,
|
||||
CHFLD_REPEAT = 6,
|
||||
CHFLD_PASTE = 7,
|
||||
} Flood;
|
||||
#define NUMFLD 8 /* 8 flood types */
|
||||
#define NUMFLD 8 /* 8 flood types */
|
||||
|
||||
/** Configuration settings */
|
||||
struct {
|
||||
@@ -77,8 +76,8 @@ FloodType floodtypes[] = {
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
#define MODEF_DEFAULT_UNSETTIME cfg.modef_default_unsettime
|
||||
#define MODEF_MAX_UNSETTIME cfg.modef_max_unsettime
|
||||
#define MODEF_DEFAULT_UNSETTIME cfg.modef_default_unsettime
|
||||
#define MODEF_MAX_UNSETTIME cfg.modef_max_unsettime
|
||||
|
||||
typedef struct ChannelFloodProtection ChannelFloodProtection;
|
||||
typedef struct ChannelFloodProfile ChannelFloodProfile;
|
||||
@@ -109,14 +108,14 @@ struct MemberFlood {
|
||||
|
||||
/** Per-channel flood protection settings and counters */
|
||||
struct ChannelFloodProtection {
|
||||
unsigned short per; /**< setting: per <XX> seconds */
|
||||
time_t timer[NUMFLD]; /**< runtime: timers */
|
||||
unsigned short counter[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short counter_unknown_users[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short limit[NUMFLD]; /**< setting: limit */
|
||||
unsigned char action[NUMFLD]; /**< setting: action */
|
||||
unsigned char remove_after[NUMFLD]; /**< setting: remove-after <this> minutes */
|
||||
unsigned char timers_running[MAXCHMODEFACTIONS+1]; /**< if for example a '-m' timer is running then this contains 'm' */
|
||||
unsigned short per; /**< setting: per <XX> seconds */
|
||||
time_t timer[NUMFLD]; /**< runtime: timers */
|
||||
unsigned short counter[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short counter_unknown_users[NUMFLD]; /**< runtime: counters */
|
||||
unsigned short limit[NUMFLD]; /**< setting: limit */
|
||||
unsigned char action[NUMFLD]; /**< setting: action */
|
||||
unsigned char remove_after[NUMFLD]; /**< setting: remove-after <this> minutes */
|
||||
unsigned char timers_running[MAXCHMODEFACTIONS + 1]; /**< if for example a '-m' timer is running then this contains 'm' */
|
||||
char *profile;
|
||||
};
|
||||
|
||||
@@ -132,18 +131,20 @@ ModDataInfo *mdflood = NULL;
|
||||
* protection (+f/+F), per flood type. Read via the channel_flood_blocked_count efunc
|
||||
* (eg the total_channel_flood_count() crule). Local-only, freed on disconnect.
|
||||
*/
|
||||
typedef struct ChannelFloodBlocks { int blocked[NUMFLD]; } ChannelFloodBlocks;
|
||||
typedef struct ChannelFloodBlocks {
|
||||
int blocked[NUMFLD];
|
||||
} ChannelFloodBlocks;
|
||||
ModDataInfo *md_channelflood_blocked = NULL;
|
||||
/* Friendly type names for the efunc/crule, indexed by enum Flood. KEEP IN SYNC. */
|
||||
static const char *channelfloodtype_names[NUMFLD] = {
|
||||
"ctcp", /* CHFLD_CTCP */
|
||||
"join", /* CHFLD_JOIN */
|
||||
"knock", /* CHFLD_KNOCK */
|
||||
"msg", /* CHFLD_MSG */
|
||||
"nick", /* CHFLD_NICK */
|
||||
"text", /* CHFLD_TEXT */
|
||||
"repeat", /* CHFLD_REPEAT */
|
||||
"paste", /* CHFLD_PASTE */
|
||||
"ctcp", /* CHFLD_CTCP */
|
||||
"join", /* CHFLD_JOIN */
|
||||
"knock", /* CHFLD_KNOCK */
|
||||
"msg", /* CHFLD_MSG */
|
||||
"nick", /* CHFLD_NICK */
|
||||
"text", /* CHFLD_TEXT */
|
||||
"repeat", /* CHFLD_REPEAT */
|
||||
"paste", /* CHFLD_PASTE */
|
||||
};
|
||||
Cmode_t EXTMODE_FLOODLIMIT = 0L;
|
||||
Cmode_t EXTMODE_FLOOD_PROFILE = 0L;
|
||||
@@ -153,7 +154,7 @@ ChannelFloodProfile *channel_flood_profiles = NULL;
|
||||
char *floodprot_msghash_key = NULL;
|
||||
long long floodprot_splittime = 0;
|
||||
|
||||
#define IsFloodLimit(x) (((x)->mode.mode & EXTMODE_FLOODLIMIT) || ((x)->mode.mode & EXTMODE_FLOOD_PROFILE) || (cfg.default_profile && GETPARASTRUCT((x), 'F')))
|
||||
#define IsFloodLimit(x) (((x)->mode.mode & EXTMODE_FLOODLIMIT) || ((x)->mode.mode & EXTMODE_FLOOD_PROFILE) || (cfg.default_profile && GETPARASTRUCT((x), 'F')))
|
||||
|
||||
/* Forward declarations */
|
||||
static void init_config(void);
|
||||
@@ -199,7 +200,7 @@ void floodprot_free_msghash_key(ModData *m);
|
||||
CMD_OVERRIDE_FUNC(floodprot_override_mode);
|
||||
ChannelFloodProtection *get_channel_flood_profile(const char *name);
|
||||
int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int strict, Client *client, const char **error_out);
|
||||
int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtection *fld, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf,3,4)));
|
||||
int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtection *fld, FORMAT_STRING(const char *fmt), ...) __attribute__((format(printf, 3, 4)));
|
||||
int floodprot_server_quit(Client *client, MessageTag *mtags);
|
||||
void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to);
|
||||
void reapply_profiles(void);
|
||||
@@ -267,7 +268,7 @@ MOD_INIT()
|
||||
mreq.free = memberflood_free;
|
||||
mdflood = ModDataAdd(modinfo->handle, mreq);
|
||||
if (!mdflood)
|
||||
abort();
|
||||
abort();
|
||||
|
||||
memset(&mreq, 0, sizeof(mreq));
|
||||
mreq.name = "channelfloodblocks";
|
||||
@@ -429,36 +430,36 @@ int floodprot_config_test_set_block(ConfigFile *cf, ConfigEntry *ce, int type, i
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
int v = atoi(ce->value);
|
||||
if ((v <= 0) || (v > 255))
|
||||
{
|
||||
config_error("%s:%i: set::modef-default-unsettime: value '%d' out of range (should be 1-255)",
|
||||
ce->file->filename, ce->line_number, v);
|
||||
ce->file->filename, ce->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "modef-max-unsettime"))
|
||||
} else if (!strcmp(ce->name, "modef-max-unsettime"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
int v = atoi(ce->value);
|
||||
if ((v <= 0) || (v > 255))
|
||||
{
|
||||
config_error("%s:%i: set::modef-max-unsettime: value '%d' out of range (should be 1-255)",
|
||||
ce->file->filename, ce->line_number, v);
|
||||
ce->file->filename, ce->line_number, v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "modef-boot-delay"))
|
||||
} else if (!strcmp(ce->name, "modef-boot-delay"))
|
||||
{
|
||||
config_error("%s:%i: set::modef-boot-delay is now called set::anti-flood::channel::boot-delay. "
|
||||
"See https://www.unrealircd.org/docs/Channel_anti-flood_settings#config",
|
||||
@@ -521,27 +522,26 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "boot-delay") || !strcmp(ce->name, "split-delay"))
|
||||
} else if (!strcmp(ce->name, "boot-delay") || !strcmp(ce->name, "split-delay"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
config_error_empty(ce->file->filename, ce->line_number,
|
||||
"set", ce->name);
|
||||
"set", ce->name);
|
||||
errors++;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
long v = config_checkval(ce->value, CFG_TIME);
|
||||
if ((v < 0) || (v > 600))
|
||||
{
|
||||
config_error("%s:%i: set::anti-flood::channel::%s: value '%ld' out of range (should be 0-600)",
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->name,
|
||||
v);
|
||||
ce->file->filename, ce->line_number,
|
||||
ce->name,
|
||||
v);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(ce->name, "profile"))
|
||||
} else if (!strcmp(ce->name, "profile"))
|
||||
{
|
||||
if (!ce->value)
|
||||
{
|
||||
@@ -583,9 +583,9 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
} else if (!BadPtr(err))
|
||||
{
|
||||
config_warn("%s:%i: set::anti-flood::channel::profile %s::flood-mode: %s",
|
||||
cep->file->filename, cep->line_number,
|
||||
ce->value,
|
||||
err);
|
||||
cep->file->filename, cep->line_number,
|
||||
ce->value,
|
||||
err);
|
||||
}
|
||||
if (fld.limit[CHFLD_TEXT] || fld.limit[CHFLD_REPEAT])
|
||||
{
|
||||
@@ -595,9 +595,10 @@ int floodprot_config_test_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int t
|
||||
ce->value);
|
||||
errors++;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename, cep->line_number,
|
||||
"set::anti-flood::channel::profile", cep->name);
|
||||
"set::anti-flood::channel::profile", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -629,16 +630,13 @@ int floodprot_config_run_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int ty
|
||||
/* Let's handle 'off' in a special way -> becomes NULL */
|
||||
if (!strcmp(cfg.default_profile, "off"))
|
||||
safe_free(cfg.default_profile);
|
||||
} else
|
||||
if (!strcmp(ce->name, "boot-delay"))
|
||||
} else if (!strcmp(ce->name, "boot-delay"))
|
||||
{
|
||||
cfg.boot_delay = config_checkval(ce->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(ce->name, "split-delay"))
|
||||
} else if (!strcmp(ce->name, "split-delay"))
|
||||
{
|
||||
cfg.split_delay = config_checkval(ce->value, CFG_TIME);
|
||||
} else
|
||||
if (!strcmp(ce->name, "profile"))
|
||||
} else if (!strcmp(ce->name, "profile"))
|
||||
{
|
||||
for (cep = ce->items; cep; cep = cep->next)
|
||||
{
|
||||
@@ -653,7 +651,7 @@ int floodprot_config_run_antiflood_block(ConfigFile *cf, ConfigEntry *ce, int ty
|
||||
FloodType *find_floodprot_by_letter(char c)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
if (floodtypes[i].letter == c)
|
||||
return &floodtypes[i];
|
||||
|
||||
@@ -663,7 +661,7 @@ FloodType *find_floodprot_by_letter(char c)
|
||||
FloodType *find_floodprot_by_index(Flood index)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
if (floodtypes[i].index == index)
|
||||
return &floodtypes[i];
|
||||
|
||||
@@ -693,7 +691,7 @@ int parse_channel_mode_flood_failed(const char **error_out, ChannelFloodProtecti
|
||||
va_end(vl);
|
||||
|
||||
/* Zero out all settings */
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
fld->limit[v] = 0;
|
||||
fld->action[v] = 0;
|
||||
@@ -736,7 +734,7 @@ int floodprot_valid_alternate_action(char action, FloodType *floodtype)
|
||||
int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int strict, Client *client, const char **error_out)
|
||||
{
|
||||
static char retbuf[512];
|
||||
char xbuf[256], c, a, *p, *p2, *x = xbuf+1;
|
||||
char xbuf[256], c, a, *p, *p2, *x = xbuf + 1;
|
||||
int v;
|
||||
unsigned short breakit;
|
||||
unsigned char r;
|
||||
@@ -750,7 +748,7 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
*error_out = NULL;
|
||||
|
||||
/* always reset settings (l, a, r) */
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
fld->limit[v] = 0;
|
||||
fld->action[v] = 0;
|
||||
@@ -763,19 +761,22 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (brackets missing)");
|
||||
|
||||
/* '['<number><1 letter>[optional: '#'+1 letter],[next..]']'':'<number> */
|
||||
p2 = strchr(xbuf+1, ']');
|
||||
p2 = strchr(xbuf + 1, ']');
|
||||
if (!p2)
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (brackets missing)");
|
||||
*p2 = '\0';
|
||||
if (*(p2+1) != ':')
|
||||
if (*(p2 + 1) != ':')
|
||||
return parse_channel_mode_flood_failed(error_out, fld, "Invalid format (:XX period missing)");
|
||||
|
||||
breakit = 0;
|
||||
for (x = strtok(xbuf+1, ","); x; x = strtok(NULL, ","))
|
||||
for (x = strtok(xbuf + 1, ","); x; x = strtok(NULL, ","))
|
||||
{
|
||||
/* <number><1 letter>[optional: '#'+1 letter] */
|
||||
p = x;
|
||||
while(isdigit(*p)) { p++; }
|
||||
while (isdigit(*p))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
/* letter */
|
||||
c = *p;
|
||||
@@ -850,7 +851,7 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
if (v < fld->per)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
fld->timer[i] = 0;
|
||||
fld->counter[i] = 0;
|
||||
@@ -861,9 +862,9 @@ int parse_channel_mode_flood(const char *param, ChannelFloodProtection *fld, int
|
||||
|
||||
/* Is anything turned on? (to stop things like '+f []:15' */
|
||||
breakit = 1;
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
if (fld->limit[v])
|
||||
breakit=0;
|
||||
breakit = 0;
|
||||
if (breakit)
|
||||
{
|
||||
/* Nothing is turned on.. */
|
||||
@@ -891,8 +892,7 @@ int cmodef_is_ok(Client *client, Channel *channel, char mode, const char *param,
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'f');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
ChannelFloodProtection fld;
|
||||
const char *err;
|
||||
@@ -1014,7 +1014,7 @@ int cmodef_sjoin_check(Channel *channel, void *ourx, void *theirx)
|
||||
return EXSJ_SAME;
|
||||
|
||||
our->per = MAX(our->per, their->per);
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
our->limit[i] = MAX(our->limit[i], their->limit[i]);
|
||||
our->action[i] = MAX(our->action[i], their->action[i]);
|
||||
@@ -1061,8 +1061,7 @@ int cmodef_profile_is_ok(Client *client, Channel *channel, char mode, const char
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'f');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
if (get_channel_flood_profile(param))
|
||||
return EX_ALLOW;
|
||||
@@ -1082,7 +1081,7 @@ void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to)
|
||||
/* If new 'per xxx seconds' is smaller than current 'per' then reset timers/counters (t, c) */
|
||||
if (from->per < to->per)
|
||||
{
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
to->timer[i] = 0;
|
||||
to->counter[i] = 0;
|
||||
@@ -1091,7 +1090,7 @@ void inherit_settings(ChannelFloodProtection *from, ChannelFloodProtection *to)
|
||||
}
|
||||
|
||||
/* inherit settings (limit/action/remove_after) */
|
||||
for (i=0; i < NUMFLD; i++)
|
||||
for (i = 0; i < NUMFLD; i++)
|
||||
{
|
||||
to->limit[i] = from->limit[i];
|
||||
to->action[i] = from->action[i];
|
||||
@@ -1174,7 +1173,7 @@ int is_floodprot_exempt(Client *client, Channel *channel, char flood_type_letter
|
||||
b->channel = channel;
|
||||
b->ban_check_types = BANCHK_MSG;
|
||||
|
||||
for (ban = channel->exlist; ban; ban=ban->next)
|
||||
for (ban = channel->exlist; ban; ban = ban->next)
|
||||
{
|
||||
char *p, *x;
|
||||
char *matchby;
|
||||
@@ -1234,7 +1233,7 @@ int floodprot_join(Client *client, Channel *channel, MessageTag *mtags)
|
||||
#endif
|
||||
!IsULine(client))
|
||||
{
|
||||
do_floodprot(channel, client, CHFLD_JOIN);
|
||||
do_floodprot(channel, client, CHFLD_JOIN);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1273,8 +1272,8 @@ int cmodef_channel_destroy(Channel *channel, int *should_destroy)
|
||||
/* [just a helper for channel_modef_string()] */
|
||||
static inline char *chmodefstrhelper(char *buf, char t, char tdef, unsigned short l, unsigned char a, unsigned char r)
|
||||
{
|
||||
char *p;
|
||||
char tmpbuf[16], *p2 = tmpbuf;
|
||||
char *p;
|
||||
char tmpbuf[16], *p2 = tmpbuf;
|
||||
|
||||
sprintf(buf, "%hd", l);
|
||||
p = buf + strlen(buf);
|
||||
@@ -1305,7 +1304,7 @@ char *channel_modef_string(ChannelFloodProtection *x, char *retbuf)
|
||||
|
||||
*p++ = '[';
|
||||
|
||||
for (i=0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
for (i = 0; i < ARRAY_SIZEOF(floodtypes); i++)
|
||||
{
|
||||
f = &floodtypes[i];
|
||||
if (x->limit[f->index])
|
||||
@@ -1387,7 +1386,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
ChannelFloodProtection *fld;
|
||||
MemberFlood *memberflood;
|
||||
uint64_t msghash;
|
||||
unsigned char is_flooding_text=0, is_flooding_repeat=0;
|
||||
unsigned char is_flooding_text = 0, is_flooding_repeat = 0;
|
||||
static char errbuf[256];
|
||||
|
||||
/* This is redundant, right? */
|
||||
@@ -1397,7 +1396,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
if (sendtype == SEND_TYPE_TAGMSG)
|
||||
return 0; // TODO: some TAGMSG specific limit? (1 of 2)
|
||||
|
||||
if (ValidatePermissionsForPath("channel:override:flood",client,NULL,channel,NULL) || !IsFloodLimit(channel) || check_channel_access(client, channel, "hoaq"))
|
||||
if (ValidatePermissionsForPath("channel:override:flood", client, NULL, channel, NULL) || !IsFloodLimit(channel) || check_channel_access(client, channel, "hoaq"))
|
||||
return HOOK_CONTINUE;
|
||||
|
||||
#ifdef TESTSUITE
|
||||
@@ -1508,7 +1507,8 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
snprintf(mask, sizeof(mask), "~time:%d:*!*@%s", fld->remove_after[flood_type], GetHost(client));
|
||||
else
|
||||
snprintf(mask, sizeof(mask), "~t:%d:*!*@%s", fld->remove_after[flood_type], GetHost(client));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
snprintf(mask, sizeof(mask), "*!*@%s", GetHost(client));
|
||||
}
|
||||
if (add_listmode(&channel->banlist, &me, channel, mask) == 1)
|
||||
@@ -1517,7 +1517,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership *
|
||||
new_message(&me, NULL, &mtags);
|
||||
sendto_server(NULL, 0, 0, mtags, ":%s MODE %s +b %s 0", me.id, channel->name, mask);
|
||||
sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s +b %s", me.name, channel->name, mask);
|
||||
":%s MODE %s +b %s", me.name, channel->name, mask);
|
||||
free_message_tags(mtags);
|
||||
} /* else.. ban list is full or already exists */
|
||||
}
|
||||
@@ -1546,7 +1546,7 @@ int floodprot_post_chanmsg(Client *client, Channel *channel, int sendflags, cons
|
||||
|
||||
do_floodprot(channel, client, CHFLD_MSG);
|
||||
|
||||
if ((text[0] == '\001') && strncmp(text+1, "ACTION ", 7))
|
||||
if ((text[0] == '\001') && strncmp(text + 1, "ACTION ", 7))
|
||||
do_floodprot(channel, client, CHFLD_CTCP);
|
||||
|
||||
return 0;
|
||||
@@ -1585,7 +1585,7 @@ int floodprot_nickchange(Client *client, MessageTag *mtags, const char *oldnick)
|
||||
void floodprot_chanmode_del_helper(ChannelFloodProtection *fld, char modechar)
|
||||
{
|
||||
/* reset joinflood on -i, reset msgflood on -m, etc.. */
|
||||
switch(modechar)
|
||||
switch (modechar)
|
||||
{
|
||||
case 'C':
|
||||
fld->counter[CHFLD_CTCP] = 0;
|
||||
@@ -1652,7 +1652,7 @@ RemoveChannelModeTimer *floodprottimer_find(Channel *channel, char mflag)
|
||||
{
|
||||
RemoveChannelModeTimer *e;
|
||||
|
||||
for (e=removechannelmodetimer_list; e; e=e->next)
|
||||
for (e = removechannelmodetimer_list; e; e = e->next)
|
||||
{
|
||||
if ((e->channel == channel) && (e->m == mflag))
|
||||
return e;
|
||||
@@ -1663,7 +1663,8 @@ RemoveChannelModeTimer *floodprottimer_find(Channel *channel, char mflag)
|
||||
/** strcat-like */
|
||||
void strccat(char *s, char c)
|
||||
{
|
||||
for (; *s; s++);
|
||||
for (; *s; s++)
|
||||
;
|
||||
*s++ = c;
|
||||
*s++ = '\0';
|
||||
}
|
||||
@@ -1683,7 +1684,7 @@ void strccat(char *s, char c)
|
||||
void floodprottimer_add(Channel *channel, ChannelFloodProtection *fld, char mflag, time_t when)
|
||||
{
|
||||
RemoveChannelModeTimer *e = NULL;
|
||||
unsigned char add=1;
|
||||
unsigned char add = 1;
|
||||
|
||||
if (strchr(fld->timers_running, mflag))
|
||||
{
|
||||
@@ -1695,7 +1696,7 @@ void floodprottimer_add(Channel *channel, ChannelFloodProtection *fld, char mfla
|
||||
|
||||
if (!strchr(fld->timers_running, mflag))
|
||||
{
|
||||
if (strlen(fld->timers_running)+1 >= sizeof(fld->timers_running))
|
||||
if (strlen(fld->timers_running) + 1 >= sizeof(fld->timers_running))
|
||||
{
|
||||
unreal_log(ULOG_WARNING, "flood", "BUG_FLOODPROTTIMER_ADD", NULL,
|
||||
"[BUG] floodprottimer_add: too many timers running for $channel ($timers_running)",
|
||||
@@ -1731,15 +1732,15 @@ void floodprottimer_del(Channel *channel, ChannelFloodProtection *fld, char mfla
|
||||
safe_free(e);
|
||||
|
||||
if (fld)
|
||||
{
|
||||
char newtf[MAXCHMODEFACTIONS+1];
|
||||
char *i, *o;
|
||||
for (i=fld->timers_running, o=newtf; *i; i++)
|
||||
if (*i != mflag)
|
||||
*o++ = *i;
|
||||
*o = '\0';
|
||||
strcpy(fld->timers_running, newtf); /* always shorter (or equal) */
|
||||
}
|
||||
{
|
||||
char newtf[MAXCHMODEFACTIONS + 1];
|
||||
char *i, *o;
|
||||
for (i = fld->timers_running, o = newtf; *i; i++)
|
||||
if (*i != mflag)
|
||||
*o++ = *i;
|
||||
*o = '\0';
|
||||
strcpy(fld->timers_running, newtf); /* always shorter (or equal) */
|
||||
}
|
||||
}
|
||||
|
||||
EVENT(modef_event)
|
||||
@@ -1850,8 +1851,8 @@ void do_floodprot_action_standard(Channel *channel, int what, FloodType *floodty
|
||||
text, fld->limit[what], fld->per, m, channel->name);
|
||||
ircsnprintf(target, sizeof(target), "%%%s", channel->name);
|
||||
sendto_channel(channel, &me, NULL, "ho",
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
free_message_tags(mtags);
|
||||
|
||||
/* Then the MODE broadcast */
|
||||
@@ -1897,11 +1898,11 @@ int do_floodprot_action_alternative(Channel *channel, int what, FloodType *flood
|
||||
ircsnprintf(comment, sizeof(comment),
|
||||
"*** Channel %s detected (limit is %d per %d seconds), "
|
||||
"mostly caused by 'unknown-users', setting mode +b %s",
|
||||
text, fld->limit[what], fld->per, ban);
|
||||
text, fld->limit[what], fld->per, ban);
|
||||
ircsnprintf(target, sizeof(target), "%%%s", channel->name);
|
||||
sendto_channel(channel, &me, NULL, "ho",
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
0, SEND_ALL, mtags,
|
||||
":%s NOTICE %s :%s", me.name, target, comment);
|
||||
free_message_tags(mtags);
|
||||
|
||||
/* Then the MODE broadcast */
|
||||
@@ -1956,7 +1957,7 @@ void do_floodprot_action(Channel *channel, int what)
|
||||
if (!ban_exists)
|
||||
{
|
||||
/* Calculate the percentage of unknown-users that is responsible for the action trigger */
|
||||
perc = ((double)fld->counter_unknown_users[what] / (double)fld->counter[what])*100;
|
||||
perc = ((double)fld->counter_unknown_users[what] / (double)fld->counter[what]) * 100;
|
||||
if (perc >= cfg.modef_alternate_action_percentage_threshold)
|
||||
{
|
||||
/* ACTION: We need to add the ban (+b) */
|
||||
@@ -2132,7 +2133,7 @@ void floodprot_free_removechannelmodetimer_list(ModData *m)
|
||||
{
|
||||
RemoveChannelModeTimer *e, *e_next;
|
||||
|
||||
for (e=removechannelmodetimer_list; e; e=e_next)
|
||||
for (e = removechannelmodetimer_list; e; e = e_next)
|
||||
{
|
||||
e_next = e->next;
|
||||
safe_free(e);
|
||||
@@ -2166,19 +2167,18 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
if (!advanced && !profile)
|
||||
{
|
||||
sendnotice(client, "No channel mode +f/+F is active on %s", channel->name);
|
||||
} else
|
||||
if (advanced && !profile)
|
||||
} else if (advanced && !profile)
|
||||
{
|
||||
channel_modef_string(advanced, buf);
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (custom settings via +f)",
|
||||
channel->name, buf);
|
||||
} else
|
||||
if (profile && !advanced)
|
||||
} else if (profile && !advanced)
|
||||
{
|
||||
channel_modef_string(profile, buf);
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (flood profile '%s')",
|
||||
channel->name, buf, profile->profile);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Both +f and +F are set */
|
||||
int v;
|
||||
ChannelFloodProtection mix;
|
||||
@@ -2186,9 +2186,9 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
char overridden[64];
|
||||
*overridden = '\0';
|
||||
memcpy(&mix, profile, sizeof(mix));
|
||||
for (v=0; v < NUMFLD; v++)
|
||||
for (v = 0; v < NUMFLD; v++)
|
||||
{
|
||||
if ((advanced->limit[v]>0) && (mix.limit[v]>0))
|
||||
if ((advanced->limit[v] > 0) && (mix.limit[v] > 0))
|
||||
{
|
||||
mix.limit[v] = 0;
|
||||
mix.action[v] = 0;
|
||||
@@ -2201,11 +2201,12 @@ CMD_OVERRIDE_FUNC(floodprot_override_mode)
|
||||
if (*overridden)
|
||||
{
|
||||
sendnotice(client, "Channel '%s' uses flood profile '%s', without action(s) '%s' as they are overridden by +f.",
|
||||
channel->name, profile->profile, overridden);
|
||||
channel->name, profile->profile, overridden);
|
||||
sendnotice(client, "Effective flood setting via +F: '%s'", buf);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendnotice(client, "Channel '%s' has effective flood setting '%s' (flood profile '%s')",
|
||||
channel->name, buf, profile->profile);
|
||||
channel->name, buf, profile->profile);
|
||||
}
|
||||
channel_modef_string(advanced, buf);
|
||||
sendnotice(client, "Plus flood setting via +f: '%s'", buf);
|
||||
@@ -2238,7 +2239,7 @@ void reapply_profiles(void)
|
||||
{
|
||||
Channel *channel;
|
||||
|
||||
for (channel = channels; channel; channel=channel->nextch)
|
||||
for (channel = channels; channel; channel = channel->nextch)
|
||||
{
|
||||
ChannelFloodProtection *fld = GETPARASTRUCT(channel, 'F');
|
||||
ChannelFloodProtection *base;
|
||||
@@ -2260,7 +2261,8 @@ void reapply_profiles(void)
|
||||
if (!fld)
|
||||
{
|
||||
cmodef_channel_create(channel);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
base = get_channel_flood_profile(cfg.default_profile);
|
||||
if (base)
|
||||
{
|
||||
@@ -2268,7 +2270,8 @@ void reapply_profiles(void)
|
||||
safe_strdup(fld->profile, cfg.default_profile);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (fld)
|
||||
{
|
||||
/* Not +F, previously we had a default profile
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/halfop",
|
||||
"6.0",
|
||||
"Channel Mode +h",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/halfop",
|
||||
"6.0",
|
||||
"Channel Mode +h",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
int cmode_halfop_is_ok(Client *client, Channel *channel, char mode, const char *para, int type, int what);
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
*/
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/history",
|
||||
"1.0",
|
||||
"Channel Mode +H",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/history",
|
||||
"1.0",
|
||||
"Channel Mode +H",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ConfigHistoryExt ConfigHistoryExt;
|
||||
struct ConfigHistoryExt {
|
||||
@@ -40,7 +39,7 @@ static cfgstruct test;
|
||||
/* Externally looked up */
|
||||
long CAP_CHATHISTORY_DRAFT = 0;
|
||||
|
||||
#define HistoryEnabled(channel) (channel->mode.mode & EXTMODE_HISTORY)
|
||||
#define HistoryEnabled(channel) (channel->mode.mode & EXTMODE_HISTORY)
|
||||
|
||||
/* Forward declarations */
|
||||
static void init_config(cfgstruct *cfg);
|
||||
@@ -125,17 +124,17 @@ static void init_config(cfgstruct *cfg)
|
||||
cfg->playback_on_join.lines = 15;
|
||||
cfg->playback_on_join.time = 86400;
|
||||
cfg->max_storage_per_channel_unregistered.lines = 200;
|
||||
cfg->max_storage_per_channel_unregistered.time = 86400*31;
|
||||
cfg->max_storage_per_channel_unregistered.time = 86400 * 31;
|
||||
cfg->max_storage_per_channel_registered.lines = 5000;
|
||||
cfg->max_storage_per_channel_registered.time = 86400*31;
|
||||
cfg->max_storage_per_channel_registered.time = 86400 * 31;
|
||||
}
|
||||
|
||||
int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
ConfigEntry *cep, *cepp, *cep4, *cep5;
|
||||
int on_join_lines=0, maximum_storage_lines_registered=0, maximum_storage_lines_unregistered=0;
|
||||
long on_join_time=0L, maximum_storage_time_registered=0L, maximum_storage_time_unregistered=0L;
|
||||
int on_join_lines = 0, maximum_storage_lines_registered = 0, maximum_storage_lines_unregistered = 0;
|
||||
long on_join_time = 0L, maximum_storage_time_registered = 0L, maximum_storage_time_unregistered = 0L;
|
||||
|
||||
/* We only care about set::history */
|
||||
if ((type != CONFIG_SET) || strcmp(ce->name, "history"))
|
||||
@@ -165,8 +164,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
continue;
|
||||
}
|
||||
test.playback_on_join.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep4->name, "time"))
|
||||
} else if (!strcmp(cep4->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep4);
|
||||
@@ -182,12 +180,11 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep4->file->filename,
|
||||
cep4->line_number, "set::history::channel::playback-on-join", cep4->name);
|
||||
cep4->line_number, "set::history::channel::playback-on-join", cep4->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
} else if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
{
|
||||
for (cep4 = cepp->items; cep4; cep4 = cep4->next)
|
||||
{
|
||||
@@ -203,13 +200,12 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::registered::lines must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
test.max_storage_per_channel_registered.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep5);
|
||||
@@ -217,7 +213,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::registered::time must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -225,12 +221,11 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep5->file->filename,
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::registered", cep5->name);
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::registered", cep5->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep4->name, "unregistered"))
|
||||
} else if (!strcmp(cep4->name, "unregistered"))
|
||||
{
|
||||
for (cep5 = cep4->items; cep5; cep5 = cep5->next)
|
||||
{
|
||||
@@ -242,13 +237,12 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::unregistered::lines must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
test.max_storage_per_channel_unregistered.lines = v;
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
long v;
|
||||
CheckNull(cep5);
|
||||
@@ -256,7 +250,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (v < 1)
|
||||
{
|
||||
config_error("%s:%i: set::history::channel::max-storage-per-channel::unregistered::time must be a positive number.",
|
||||
cep5->file->filename, cep5->line_number);
|
||||
cep5->file->filename, cep5->line_number);
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
@@ -264,14 +258,14 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep5->file->filename,
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::unregistered", cep5->name);
|
||||
cep5->line_number, "set::history::channel::max-storage-per-channel::unregistered", cep5->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename,
|
||||
cep->line_number, "set::history::max-storage-per-channel", cep->name);
|
||||
cep->line_number, "set::history::max-storage-per-channel", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -283,8 +277,7 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
for (h = Hooks[HOOKTYPE_CONFIGTEST]; h; h = h->next)
|
||||
{
|
||||
int value, errs = 0;
|
||||
if (h->owner && !(h->owner->flags & MODFLAG_TESTING)
|
||||
&& !(h->owner->options & MOD_OPT_PERM))
|
||||
if (h->owner && !(h->owner->flags & MODFLAG_TESTING) && !(h->owner->options & MOD_OPT_PERM))
|
||||
continue;
|
||||
value = (*(h->func.intfunc))(cf, cepp, CONFIG_SET_HISTORY_CHANNEL, &errs);
|
||||
if (value == 2)
|
||||
@@ -309,14 +302,15 @@ int history_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
if (!used)
|
||||
{
|
||||
config_error_unknown(cepp->file->filename,
|
||||
cepp->line_number, "set::history::channel", cepp->name);
|
||||
cepp->line_number, "set::history::channel", cepp->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
config_error_unknown(cep->file->filename,
|
||||
cep->line_number, "set::history", cep->name);
|
||||
cep->line_number, "set::history", cep->name);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
@@ -357,14 +351,12 @@ int history_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep4->name, "lines"))
|
||||
{
|
||||
cfg.playback_on_join.lines = atoi(cep4->value);
|
||||
} else
|
||||
if (!strcmp(cep4->name, "time"))
|
||||
} else if (!strcmp(cep4->name, "time"))
|
||||
{
|
||||
cfg.playback_on_join.time = config_checkval(cep4->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
} else if (!strcmp(cepp->name, "max-storage-per-channel"))
|
||||
{
|
||||
for (cep4 = cepp->items; cep4; cep4 = cep4->next)
|
||||
{
|
||||
@@ -375,22 +367,19 @@ int history_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
|
||||
if (!strcmp(cep5->name, "lines"))
|
||||
{
|
||||
cfg.max_storage_per_channel_registered.lines = atoi(cep5->value);
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
cfg.max_storage_per_channel_registered.time = config_checkval(cep5->value, CFG_TIME);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (!strcmp(cep4->name, "unregistered"))
|
||||
} else if (!strcmp(cep4->name, "unregistered"))
|
||||
{
|
||||
for (cep5 = cep4->items; cep5; cep5 = cep5->next)
|
||||
{
|
||||
if (!strcmp(cep5->name, "lines"))
|
||||
{
|
||||
cfg.max_storage_per_channel_unregistered.lines = atoi(cep5->value);
|
||||
} else
|
||||
if (!strcmp(cep5->name, "time"))
|
||||
} else if (!strcmp(cep5->name, "time"))
|
||||
{
|
||||
cfg.max_storage_per_channel_unregistered.time = config_checkval(cep5->value, CFG_TIME);
|
||||
}
|
||||
@@ -441,7 +430,7 @@ int history_parse_chanmode(Channel *channel, const char *param, int *lines, long
|
||||
|
||||
/* Parse time value */
|
||||
/* If it is all digits then it is in minutes */
|
||||
for (q=p; *q; q++)
|
||||
for (q = p; *q; q++)
|
||||
{
|
||||
if (!isdigit(*q))
|
||||
{
|
||||
@@ -469,7 +458,8 @@ int history_parse_chanmode(Channel *channel, const char *param, int *lines, long
|
||||
|
||||
if (*t > cfg.max_storage_per_channel_registered.time)
|
||||
*t = cfg.max_storage_per_channel_registered.time;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
if (*lines > cfg.max_storage_per_channel_unregistered.lines)
|
||||
*lines = cfg.max_storage_per_channel_unregistered.lines;
|
||||
|
||||
@@ -492,8 +482,7 @@ int history_chanmode_is_ok(Client *client, Channel *channel, char mode, const ch
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'H');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
int lines = 0;
|
||||
long t = 0L;
|
||||
@@ -518,8 +507,7 @@ static void history_chanmode_helper(char *buf, size_t bufsize, int lines, long t
|
||||
{
|
||||
/* Can be represented in full days, eg "1d" */
|
||||
snprintf(buf, bufsize, "%d:%ldd", lines, t / 86400);
|
||||
} else
|
||||
if ((t % 3600) == 0)
|
||||
} else if ((t % 3600) == 0)
|
||||
{
|
||||
/* Can be represented in hours, eg "8h" */
|
||||
snprintf(buf, bufsize, "%d:%ldh", lines, t / 3600);
|
||||
@@ -659,7 +647,7 @@ int history_chanmsg(Client *client, Channel *channel, int sendflags, const char
|
||||
return 0;
|
||||
|
||||
/* Filter out CTCP / CTCP REPLY */
|
||||
if ((*text == '\001') && strncmp(text+1, "ACTION", 6))
|
||||
if ((*text == '\001') && strncmp(text + 1, "ACTION", 6))
|
||||
return 0;
|
||||
|
||||
/* Filter out TAGMSG */
|
||||
@@ -678,10 +666,10 @@ int history_chanmsg(Client *client, Channel *channel, int sendflags, const char
|
||||
strlcpy(source, client->name, sizeof(source));
|
||||
|
||||
snprintf(buf, sizeof(buf), ":%s %s %s :%s",
|
||||
source,
|
||||
sendtype_to_cmd(sendtype),
|
||||
channel->name,
|
||||
text);
|
||||
source,
|
||||
sendtype_to_cmd(sendtype),
|
||||
channel->name,
|
||||
text);
|
||||
|
||||
history_add(channel->name, mtags, buf);
|
||||
|
||||
@@ -704,7 +692,7 @@ int history_chanmsg_multiline(Client *client, Channel *channel, int sendflags, c
|
||||
return 0;
|
||||
|
||||
/* Filter out CTCP (except ACTION) based on first line */
|
||||
if (lines && lines->text && (*lines->text == '\001') && strncmp(lines->text+1, "ACTION", 6))
|
||||
if (lines && lines->text && (*lines->text == '\001') && strncmp(lines->text + 1, "ACTION", 6))
|
||||
return 0;
|
||||
|
||||
if (IsUser(client))
|
||||
@@ -820,11 +808,11 @@ CMD_OVERRIDE_FUNC(override_mode)
|
||||
new_message(&me, NULL, &mtags);
|
||||
|
||||
sendto_channel(channel, &me, &me, 0, 0, SEND_LOCAL, mtags,
|
||||
":%s MODE %s %s %s",
|
||||
me.name, channel->name, modebuf, parabuf);
|
||||
":%s MODE %s %s %s",
|
||||
me.name, channel->name, modebuf, parabuf);
|
||||
sendto_server(NULL, 0, 0, mtags, ":%s MODE %s %s %s %lld",
|
||||
me.id, channel->name, modebuf, parabuf,
|
||||
(long long)channel->creationtime);
|
||||
me.id, channel->name, modebuf, parabuf,
|
||||
(long long)channel->creationtime);
|
||||
|
||||
/* Activate this hook just like cmd_mode.c */
|
||||
RunHook(HOOKTYPE_REMOTE_CHANMODE, &me, channel, mtags, modebuf, parabuf, 0, 0, &destroy_channel);
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/inviteonly",
|
||||
"6.0",
|
||||
"Channel Mode +i",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/inviteonly",
|
||||
"6.0",
|
||||
"Channel Mode +i",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_INVITE_ONLY;
|
||||
|
||||
#define IsInviteOnly(channel) (channel->mode.mode & EXTCMODE_INVITE_ONLY)
|
||||
#define IsInviteOnly(channel) (channel->mode.mode & EXTCMODE_INVITE_ONLY)
|
||||
|
||||
int inviteonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
|
||||
@@ -62,7 +61,7 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int inviteonly_can_join (Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
int inviteonly_can_join(Client *client, Channel *channel, const char *key, char **errmsg)
|
||||
{
|
||||
if (IsInviteOnly(channel))
|
||||
{
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/isregistered",
|
||||
"6.0",
|
||||
"Channel Mode +r",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/isregistered",
|
||||
"6.0",
|
||||
"Channel Mode +r",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_REGISTERED;
|
||||
|
||||
#define IsRegisteredChannel(channel) (channel->mode.mode & EXTCMODE_REGISTERED)
|
||||
#define IsRegisteredChannel(channel) (channel->mode.mode & EXTCMODE_REGISTERED)
|
||||
|
||||
int isregistered_chanmode_is_ok(Client *client, Channel *channel, char mode, const char *param, int type, int what);
|
||||
|
||||
|
||||
@@ -28,18 +28,17 @@
|
||||
|
||||
CMD_FUNC(issecure);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/issecure",
|
||||
"4.2",
|
||||
"Channel Mode +Z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/issecure",
|
||||
"4.2",
|
||||
"Channel Mode +Z",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_ISSECURE;
|
||||
|
||||
#define IsSecureChanIndicated(channel) (channel->mode.mode & EXTCMODE_ISSECURE)
|
||||
#define IsSecureChanIndicated(channel) (channel->mode.mode & EXTCMODE_ISSECURE)
|
||||
|
||||
int IsSecureJoin(Channel *channel);
|
||||
int modeZ_is_ok(Client *client, Channel *channel, char mode, const char *para, int checkt, int what);
|
||||
@@ -48,8 +47,8 @@ int issecure_part(Client *client, Channel *channel, MessageTag *mtags, const cha
|
||||
int issecure_quit(Client *client, MessageTag *mtags, const char *comment);
|
||||
int issecure_kick(Client *client, Client *victim, Channel *channel, MessageTag *mtags, const char *comment);
|
||||
int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel);
|
||||
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel);
|
||||
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -58,7 +57,7 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
/* Channel mode */
|
||||
memset(&req, 0, sizeof(req));
|
||||
@@ -67,7 +66,7 @@ CmodeInfo req;
|
||||
req.letter = 'Z';
|
||||
req.local = 1; /* local channel mode */
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_ISSECURE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_JOIN, 0, issecure_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_JOIN, 0, issecure_join);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_PART, 0, issecure_part);
|
||||
@@ -78,7 +77,7 @@ CmodeInfo req;
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_KICK, 0, issecure_kick);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_LOCAL_CHANMODE, 0, issecure_chanmode);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_REMOTE_CHANMODE, 0, issecure_chanmode);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -116,7 +115,7 @@ int modeZ_is_ok(Client *client, Channel *channel, char mode, const char *para, i
|
||||
|
||||
int channel_has_insecure_users_butone(Channel *channel, Client *skip)
|
||||
{
|
||||
Member *member;
|
||||
Member *member;
|
||||
|
||||
for (member = channel->members; member; member = member->next)
|
||||
{
|
||||
@@ -149,7 +148,7 @@ void issecure_unset(Channel *channel, Client *client, MessageTag *recv_mtags, in
|
||||
me.name, channel->name, client->name);
|
||||
free_message_tags(mtags);
|
||||
}
|
||||
|
||||
|
||||
channel->mode.mode &= ~EXTCMODE_ISSECURE;
|
||||
mtags = NULL;
|
||||
new_message_special(&me, recv_mtags, &mtags, "MODE %s -Z", channel->name);
|
||||
@@ -224,14 +223,14 @@ int issecure_part(Client *client, Channel *channel, MessageTag *mtags, const cha
|
||||
|
||||
int issecure_quit(Client *client, MessageTag *mtags, const char *comment)
|
||||
{
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
Membership *membership;
|
||||
Channel *channel;
|
||||
|
||||
for (membership = client->user->channel; membership; membership=membership->next)
|
||||
for (membership = client->user->channel; membership; membership = membership->next)
|
||||
{
|
||||
channel = membership->channel;
|
||||
/* Identical to part */
|
||||
if (IsSecureJoin(channel) && !IsSecureChanIndicated(channel) &&
|
||||
if (IsSecureJoin(channel) && !IsSecureChanIndicated(channel) &&
|
||||
!IsSecureConnect(client) && !channel_has_insecure_users_butone(channel, client))
|
||||
issecure_set(channel, client, mtags, 1);
|
||||
}
|
||||
@@ -248,7 +247,7 @@ int issecure_kick(Client *client, Client *victim, Channel *channel, MessageTag *
|
||||
}
|
||||
|
||||
int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel)
|
||||
const char *modebuf, const char *parabuf, time_t sendts, int samode, int *destroy_channel)
|
||||
{
|
||||
if (!strchr(modebuf, 'z'))
|
||||
return 0; /* don't care */
|
||||
@@ -264,12 +263,14 @@ int issecure_chanmode(Client *client, Channel *channel, MessageTag *mtags,
|
||||
/* Should be -Z, if not already */
|
||||
if (IsSecureChanIndicated(channel))
|
||||
issecure_unset(channel, NULL, mtags, 0); /* would be odd if we got here ;) */
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Should be +Z, but check if it isn't already.. */
|
||||
if (!IsSecureChanIndicated(channel))
|
||||
issecure_set(channel, NULL, mtags, 0);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* there was a -z, check if the channel is currently +Z and if so, set it -Z */
|
||||
if (IsSecureChanIndicated(channel))
|
||||
issecure_unset(channel, NULL, mtags, 0);
|
||||
|
||||
+13
-15
@@ -19,25 +19,24 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/key",
|
||||
"6.0",
|
||||
"Channel Mode +k",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/key",
|
||||
"6.0",
|
||||
"Channel Mode +k",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ChannelKey ChannelKey;
|
||||
struct ChannelKey {
|
||||
char key[KEYLEN+1];
|
||||
char key[KEYLEN + 1];
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
ModDataInfo *mdkey = NULL;
|
||||
Cmode_t EXTMODE_KEY = 0L;
|
||||
|
||||
#define IsKey(x) ((x)->mode.mode & EXTMODE_KEY)
|
||||
#define IsKey(x) ((x)->mode.mode & EXTMODE_KEY)
|
||||
|
||||
/* Forward declarations */
|
||||
int key_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
@@ -110,13 +109,12 @@ int cmode_key_is_ok(Client *client, Channel *channel, char mode, const char *par
|
||||
if (IsUser(client) && check_channel_access(client, channel, "hoaq"))
|
||||
return EX_ALLOW;
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
if (!is_valid_key(param))
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDMODEPARAM,
|
||||
channel->name, 'k', "*", "Channel key contains forbidden characters or is too long");
|
||||
channel->name, 'k', "*", "Channel key contains forbidden characters or is too long");
|
||||
return EX_DENY;
|
||||
}
|
||||
return EX_ALLOW;
|
||||
@@ -141,7 +139,7 @@ void *cmode_key_put_param(void *k_in, const char *param)
|
||||
const char *cmode_key_get_param(void *r_in)
|
||||
{
|
||||
ChannelKey *r = (ChannelKey *)r_in;
|
||||
static char retbuf[KEYLEN+1];
|
||||
static char retbuf[KEYLEN + 1];
|
||||
|
||||
if (!r)
|
||||
return NULL;
|
||||
@@ -152,7 +150,7 @@ const char *cmode_key_get_param(void *r_in)
|
||||
|
||||
const char *cmode_key_conv_param(const char *param, Client *client, Channel *channel)
|
||||
{
|
||||
static char retbuf[KEYLEN+1];
|
||||
static char retbuf[KEYLEN + 1];
|
||||
|
||||
transform_channel_key(param, retbuf, sizeof(retbuf));
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/limit",
|
||||
"6.0",
|
||||
"Channel Mode +l",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/limit",
|
||||
"6.0",
|
||||
"Channel Mode +l",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
typedef struct ChannelLimit ChannelLimit;
|
||||
struct ChannelLimit {
|
||||
@@ -37,10 +36,10 @@ struct ChannelLimit {
|
||||
ModDataInfo *mdlimit = NULL;
|
||||
Cmode_t EXTMODE_LIMIT = 0L;
|
||||
|
||||
#define IsLimit(x) ((x)->mode.mode & EXTMODE_LIMIT)
|
||||
#define IsLimit(x) ((x)->mode.mode & EXTMODE_LIMIT)
|
||||
|
||||
/* Just for buffers, nothing else */
|
||||
#define LIMITLEN 32
|
||||
#define LIMITLEN 32
|
||||
|
||||
/* Forward declarations */
|
||||
int limit_can_join(Client *client, Channel *channel, const char *key, char **errmsg);
|
||||
@@ -95,9 +94,9 @@ int limit_can_join(Client *client, Channel *channel, const char *key, char **err
|
||||
if (r && r->limit && (channel->users >= r->limit))
|
||||
{
|
||||
Hook *h;
|
||||
for (h = Hooks[HOOKTYPE_CAN_JOIN_LIMITEXCEEDED]; h; h = h->next)
|
||||
for (h = Hooks[HOOKTYPE_CAN_JOIN_LIMITEXCEEDED]; h; h = h->next)
|
||||
{
|
||||
int i = (*(h->func.intfunc))(client,channel,key,errmsg);
|
||||
int i = (*(h->func.intfunc))(client, channel, key, errmsg);
|
||||
if (i != 0)
|
||||
return i;
|
||||
}
|
||||
@@ -116,14 +115,13 @@ int cmode_limit_is_ok(Client *client, Channel *channel, char mode, const char *p
|
||||
if (IsUser(client) && check_channel_access(client, channel, "hoaq"))
|
||||
return EX_ALLOW;
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
/* When coming from an IRC client, we reject limit <=0 explicitly, as it makes no sense */
|
||||
if (atoi(param) <= 0)
|
||||
{
|
||||
sendnumeric(client, ERR_INVALIDMODEPARAM,
|
||||
channel->name, 'l', "*", "Channel limit (+l) needs to be a positive number");
|
||||
channel->name, 'l', "*", "Channel limit (+l) needs to be a positive number");
|
||||
return EX_DENY;
|
||||
}
|
||||
/* Any other value is valid, we just morph it */
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#define MAX_EB_LEN 128 // Max extban length
|
||||
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/link",
|
||||
"5.0",
|
||||
"Channel Mode +L",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
"chanmodes/link",
|
||||
"5.0",
|
||||
"Channel Mode +L",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTMODE_LINK = 0L;
|
||||
@@ -115,8 +115,7 @@ int cmodeL_is_ok(Client *client, Channel *channel, char mode, const char *para,
|
||||
if (type == EXCHK_ACCESS_ERR) /* can only be due to being halfop */
|
||||
sendnumeric(client, ERR_NOTFORHALFOPS, 'L');
|
||||
return EX_DENY;
|
||||
} else
|
||||
if (type == EXCHK_PARAM)
|
||||
} else if (type == EXCHK_PARAM)
|
||||
{
|
||||
/* Check parameter.. syntax is +L #channel */
|
||||
if (strchr(para, ','))
|
||||
@@ -132,7 +131,7 @@ int cmodeL_is_ok(Client *client, Channel *channel, char mode, const char *para,
|
||||
{
|
||||
if (MyUser(client))
|
||||
sendnumeric(client, ERR_CANNOTCHANGECHANMODE, 'L',
|
||||
"a channel cannot be linked to itself");
|
||||
"a channel cannot be linked to itself");
|
||||
return EX_DENY;
|
||||
}
|
||||
return EX_ALLOW;
|
||||
@@ -158,7 +157,7 @@ void *cmodeL_put_param(void *r_in, const char *param)
|
||||
const char *cmodeL_get_param(void *r_in)
|
||||
{
|
||||
aModeLEntry *r = (aModeLEntry *)r_in;
|
||||
static char retbuf[CHANNELLEN+1];
|
||||
static char retbuf[CHANNELLEN + 1];
|
||||
|
||||
if (!r)
|
||||
return NULL;
|
||||
@@ -284,7 +283,7 @@ const char *extban_link_conv_param(BanContext *b, Extban *extban)
|
||||
|
||||
int link_doforward(Client *client, Channel *channel, const char *linked, linkType type)
|
||||
{
|
||||
char linked_channel_buffer[CHANNELLEN+1];
|
||||
char linked_channel_buffer[CHANNELLEN + 1];
|
||||
char desc[64];
|
||||
const char *parv[3];
|
||||
|
||||
@@ -368,12 +367,10 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (!strncmp(ban->banstr, "~f:", 3))
|
||||
{
|
||||
strlcpy(bantmp, ban->banstr + 3, sizeof(bantmp));
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~forward:", 9))
|
||||
} else if (!strncmp(ban->banstr, "~forward:", 9))
|
||||
{
|
||||
strlcpy(bantmp, ban->banstr + 9, sizeof(bantmp));
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~t:", 3))
|
||||
} else if (!strncmp(ban->banstr, "~t:", 3))
|
||||
{
|
||||
/* A timed ban, but is it for us? Need to parse a little:
|
||||
* ~t:dddd:~f:...
|
||||
@@ -382,16 +379,15 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (p && !strncmp(p, ":~f:", 4))
|
||||
{
|
||||
strlcpy(bantmp, p + 4, sizeof(bantmp));
|
||||
} else
|
||||
if (p && !strncmp(p, ":~forward:", 10))
|
||||
} else if (p && !strncmp(p, ":~forward:", 10))
|
||||
{
|
||||
strlcpy(bantmp, p + 10, sizeof(bantmp));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Not for us - some other ~t ban */
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
if (!strncmp(ban->banstr, "~time:", 6))
|
||||
} else if (!strncmp(ban->banstr, "~time:", 6))
|
||||
{
|
||||
/* A timed ban, but is it for us? Need to parse a little:
|
||||
* ~t:dddd:~f:...
|
||||
@@ -400,11 +396,11 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
if (p && !strncmp(p, ":~f:", 4))
|
||||
{
|
||||
strlcpy(bantmp, p + 4, sizeof(bantmp));
|
||||
} else
|
||||
if (p && !strncmp(p, ":~forward:", 10))
|
||||
} else if (p && !strncmp(p, ":~forward:", 10))
|
||||
{
|
||||
strlcpy(bantmp, p + 10, sizeof(bantmp));
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Not for us - some other ~t ban */
|
||||
continue;
|
||||
}
|
||||
@@ -439,7 +435,8 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
/* A ~forward ban matched, go for it.. */
|
||||
safe_free(b);
|
||||
return link_doforward(client, channel, banchan, LINKTYPE_BAN);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
/* Break the outer loop as well: the user is exempt,
|
||||
* so it makes no sense to check other bans anymore.
|
||||
* no "safe_free(b);" here because that is taken
|
||||
@@ -474,7 +471,8 @@ int link_pre_localjoin_cb(Client *client, Channel *channel, const char *key)
|
||||
return link_doforward(client, channel, linked, LINKTYPE_REG);
|
||||
|
||||
// For a couple of conditions we can use the return value from can_join() =]
|
||||
switch(canjoin) {
|
||||
switch (canjoin)
|
||||
{
|
||||
// Any ban other than our own ~f: extban
|
||||
case ERR_BANNEDFROMCHAN:
|
||||
return link_doforward(client, channel, linked, LINKTYPE_BAN);
|
||||
|
||||
@@ -20,14 +20,13 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/moderated",
|
||||
"6.0",
|
||||
"Channel Mode +m",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/moderated",
|
||||
"6.0",
|
||||
"Channel Mode +m",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
/* Global variables */
|
||||
Cmode_t EXTCMODE_MODERATED;
|
||||
@@ -38,7 +37,7 @@ const char *moderated_pre_local_part(Client *client, Channel *channel, const cha
|
||||
int moderated_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg);
|
||||
|
||||
/* Macros */
|
||||
#define IsModerated(channel) (channel->mode.mode & EXTCMODE_MODERATED)
|
||||
#define IsModerated(channel) (channel->mode.mode & EXTCMODE_MODERATED)
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
@@ -72,7 +71,7 @@ MOD_UNLOAD()
|
||||
int moderated_can_send_to_channel(Client *client, Channel *channel, Membership *m, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
{
|
||||
if (IsModerated(channel) && (!m || !check_channel_access_membership(m, "vhoaq")) &&
|
||||
!op_can_override("channel:override:message:moderated",client,channel,NULL))
|
||||
!op_can_override("channel:override:message:moderated", client, channel, NULL))
|
||||
{
|
||||
Hook *h;
|
||||
for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next)
|
||||
@@ -101,7 +100,7 @@ const char *moderated_pre_local_part(Client *client, Channel *channel, const cha
|
||||
|
||||
int moderated_can_set_topic(Client *client, Channel *channel, const char *topic, const char **errmsg)
|
||||
{
|
||||
static char errmsg_buf[NICKLEN+256];
|
||||
static char errmsg_buf[NICKLEN + 256];
|
||||
|
||||
/* Channel is +m but user is not +vhoaq: reject the topic change */
|
||||
if (has_channel_mode(channel, 'm') && !check_channel_access(client, channel, "vhoaq"))
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(nocolor);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nocolor",
|
||||
"4.2",
|
||||
"Channel Mode +c",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nocolor",
|
||||
"4.2",
|
||||
"Channel Mode +c",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOCOLOR;
|
||||
|
||||
#define IsNoColor(channel) (channel->mode.mode & EXTCMODE_NOCOLOR)
|
||||
#define IsNoColor(channel) (channel->mode.mode & EXTCMODE_NOCOLOR)
|
||||
|
||||
int nocolor_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
const char *nocolor_prelocalpart(Client *client, Channel *channel, const char *comment);
|
||||
@@ -45,7 +44,7 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
/* Channel mode */
|
||||
memset(&req, 0, sizeof(req));
|
||||
@@ -53,12 +52,12 @@ CmodeInfo req;
|
||||
req.letter = 'c';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOCOLOR);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, nocolor_can_send_to_channel);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_PART, 0, nocolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT_CHAN, 0, nocolor_prelocalpart);
|
||||
HookAddConstString(modinfo->handle, HOOKTYPE_PRE_LOCAL_QUIT, 0, nocolor_prelocalquit);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -75,14 +74,14 @@ MOD_UNLOAD()
|
||||
|
||||
static int IsUsingColor(const char *s)
|
||||
{
|
||||
if (!s)
|
||||
return 0;
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
for (; *s; s++)
|
||||
if (*s == 3 || *s == 27 || *s == 4 || *s == 22) /* mirc color, ansi, rgb, reverse */
|
||||
return 1;
|
||||
for (; *s; s++)
|
||||
if (*s == 3 || *s == 27 || *s == 4 || *s == 22) /* mirc color, ansi, rgb, reverse */
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nocolor_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(noctcp);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noctcp",
|
||||
"4.2",
|
||||
"Channel Mode +C",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noctcp",
|
||||
"4.2",
|
||||
"Channel Mode +C",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOCTCP;
|
||||
|
||||
#define IsNoCTCP(channel) (channel->mode.mode & EXTCMODE_NOCTCP)
|
||||
#define IsNoCTCP(channel) (channel->mode.mode & EXTCMODE_NOCTCP)
|
||||
|
||||
int noctcp_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -43,16 +42,16 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'C';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOCTCP);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, noctcp_can_send_to_channel);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -20,18 +20,17 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noexternalmsgs",
|
||||
"6.0",
|
||||
"Channel Mode +n",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noexternalmsgs",
|
||||
"6.0",
|
||||
"Channel Mode +n",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NO_EXTERNAL_MESSAGES;
|
||||
|
||||
#define IsNoExternalMessages(channel) (channel->mode.mode & EXTCMODE_NO_EXTERNAL_MESSAGES)
|
||||
#define IsNoExternalMessages(channel) (channel->mode.mode & EXTCMODE_NO_EXTERNAL_MESSAGES)
|
||||
|
||||
int noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -64,7 +63,7 @@ MOD_UNLOAD()
|
||||
|
||||
int noexternalmsgs_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx)
|
||||
{
|
||||
if (IsNoExternalMessages(channel) && !IsMember(client,channel))
|
||||
if (IsNoExternalMessages(channel) && !IsMember(client, channel))
|
||||
{
|
||||
/* Channel does not accept external messages (+n).
|
||||
* Reject, unless HOOKTYPE_CAN_BYPASS_NO_EXTERNAL_MSGS tells otherwise.
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
|
||||
CMD_FUNC(noinvite);
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noinvite",
|
||||
"4.2",
|
||||
"Channel Mode +V",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noinvite",
|
||||
"4.2",
|
||||
"Channel Mode +V",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOINVITE;
|
||||
|
||||
#define IsNoInvite(channel) (channel->mode.mode & EXTCMODE_NOINVITE)
|
||||
#define IsNoInvite(channel) (channel->mode.mode & EXTCMODE_NOINVITE)
|
||||
|
||||
int noinvite_pre_knock(Client *client, Channel *channel, const char **reason);
|
||||
int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *override);
|
||||
@@ -51,10 +50,10 @@ MOD_INIT()
|
||||
req.letter = 'V';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOINVITE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_KNOCK, 0, noinvite_pre_knock);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_INVITE, 0, noinvite_pre_invite);
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -86,10 +85,11 @@ int noinvite_pre_invite(Client *client, Client *target, Channel *channel, int *o
|
||||
{
|
||||
if (MyUser(client) && IsNoInvite(channel))
|
||||
{
|
||||
if (ValidatePermissionsForPath("channel:override:invite:noinvite",client,NULL,channel,NULL) && client == target)
|
||||
if (ValidatePermissionsForPath("channel:override:invite:noinvite", client, NULL, channel, NULL) && client == target)
|
||||
{
|
||||
*override = 1;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
sendnumeric(client, ERR_NOINVITE, channel->name);
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
@@ -20,20 +20,19 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nokick",
|
||||
"4.2",
|
||||
"Channel Mode +Q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nokick",
|
||||
"4.2",
|
||||
"Channel Mode +Q",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOKICK;
|
||||
|
||||
#define IsNoKick(channel) (channel->mode.mode & EXTCMODE_NOKICK)
|
||||
#define IsNoKick(channel) (channel->mode.mode & EXTCMODE_NOKICK)
|
||||
|
||||
int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
|
||||
int nokick_check(Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -49,10 +48,10 @@ MOD_INIT()
|
||||
req.letter = 'Q';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKICK);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_KICK, 0, nokick_check);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -67,7 +66,7 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int nokick_check (Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
|
||||
int nokick_check(Client *client, Client *target, Channel *channel, const char *comment, const char *client_member_modes, const char *target_member_modes, const char **reject_reason)
|
||||
{
|
||||
static char errmsg[256];
|
||||
|
||||
@@ -82,4 +81,3 @@ int nokick_check (Client *client, Client *target, Channel *channel, const char *
|
||||
|
||||
return EX_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/noknock",
|
||||
"4.2",
|
||||
"Channel Mode +K",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/noknock",
|
||||
"4.2",
|
||||
"Channel Mode +K",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NOKNOCK;
|
||||
|
||||
#define IsNoKnock(channel) (channel->mode.mode & EXTCMODE_NOKNOCK)
|
||||
#define IsNoKnock(channel) (channel->mode.mode & EXTCMODE_NOKNOCK)
|
||||
|
||||
int noknock_check_knock(Client *client, Channel *channel, const char **reason);
|
||||
int noknock_mode_allow(Client *client, Channel *channel, char mode, const char *para, int checkt, int what);
|
||||
int noknock_mode_del (Channel *channel, int modeChar);
|
||||
int noknock_mode_del(Channel *channel, int modeChar);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -43,18 +42,18 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'K';
|
||||
req.is_ok = noknock_mode_allow;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKNOCK);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_PRE_KNOCK, 0, noknock_check_knock);
|
||||
HookAdd(modinfo->handle, HOOKTYPE_MODECHAR_DEL, 0, noknock_mode_del);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -70,7 +69,7 @@ MOD_UNLOAD()
|
||||
}
|
||||
|
||||
|
||||
int noknock_check_knock (Client *client, Channel *channel, const char **reason)
|
||||
int noknock_check_knock(Client *client, Channel *channel, const char **reason)
|
||||
{
|
||||
if (MyUser(client) && IsNoKnock(channel))
|
||||
{
|
||||
@@ -81,7 +80,7 @@ int noknock_check_knock (Client *client, Channel *channel, const char **reason)
|
||||
return HOOK_CONTINUE;
|
||||
}
|
||||
|
||||
int noknock_mode_del (Channel *channel, int modeChar)
|
||||
int noknock_mode_del(Channel *channel, int modeChar)
|
||||
{
|
||||
// Remove noknock when we're removing invite only
|
||||
if (modeChar == 'i')
|
||||
|
||||
@@ -20,20 +20,19 @@
|
||||
#include "unrealircd.h"
|
||||
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nonickchange",
|
||||
"4.2",
|
||||
"Channel Mode +N",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nonickchange",
|
||||
"4.2",
|
||||
"Channel Mode +N",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NONICKCHANGE;
|
||||
|
||||
#define IsNoNickChange(channel) (channel->mode.mode & EXTCMODE_NONICKCHANGE)
|
||||
#define IsNoNickChange(channel) (channel->mode.mode & EXTCMODE_NONICKCHANGE)
|
||||
|
||||
int nonickchange_check (Client *client, Channel *channel);
|
||||
int nonickchange_check(Client *client, Channel *channel);
|
||||
|
||||
MOD_TEST()
|
||||
{
|
||||
@@ -42,17 +41,17 @@ MOD_TEST()
|
||||
|
||||
MOD_INIT()
|
||||
{
|
||||
CmodeInfo req;
|
||||
CmodeInfo req;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.paracount = 0;
|
||||
req.letter = 'N';
|
||||
req.is_ok = extcmode_default_requirehalfop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NONICKCHANGE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CHAN_PERMIT_NICK_CHANGE, 0, nonickchange_check);
|
||||
|
||||
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
@@ -67,15 +66,12 @@ MOD_UNLOAD()
|
||||
return MOD_SUCCESS;
|
||||
}
|
||||
|
||||
int nonickchange_check (Client *client, Channel *channel)
|
||||
int nonickchange_check(Client *client, Channel *channel)
|
||||
{
|
||||
if (!IsOper(client) && !IsULine(client)
|
||||
&& IsNoNickChange(channel)
|
||||
&& !check_channel_access(client, channel, "oaq"))
|
||||
if (!IsOper(client) && !IsULine(client) && IsNoNickChange(channel) && !check_channel_access(client, channel, "oaq"))
|
||||
{
|
||||
return HOOK_DENY;
|
||||
}
|
||||
|
||||
return HOOK_ALLOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,17 @@
|
||||
|
||||
#include "unrealircd.h"
|
||||
|
||||
ModuleHeader MOD_HEADER
|
||||
= {
|
||||
"chanmodes/nonotice",
|
||||
"4.2",
|
||||
"Channel Mode +T",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
ModuleHeader MOD_HEADER = {
|
||||
"chanmodes/nonotice",
|
||||
"4.2",
|
||||
"Channel Mode +T",
|
||||
"UnrealIRCd Team",
|
||||
"unrealircd-6",
|
||||
};
|
||||
|
||||
Cmode_t EXTCMODE_NONOTICE;
|
||||
|
||||
#define IsNoNotice(channel) (channel->mode.mode & EXTCMODE_NONOTICE)
|
||||
#define IsNoNotice(channel) (channel->mode.mode & EXTCMODE_NONOTICE)
|
||||
|
||||
int nonotice_check_can_send_to_channel(Client *client, Channel *channel, Membership *lp, const char **msg, const char **errmsg, SendType sendtype, ClientContext *clictx);
|
||||
|
||||
@@ -48,7 +47,7 @@ MOD_INIT()
|
||||
req.letter = 'T';
|
||||
req.is_ok = extcmode_default_requirechop;
|
||||
CmodeAdd(modinfo->handle, req, &EXTCMODE_NONOTICE);
|
||||
|
||||
|
||||
HookAdd(modinfo->handle, HOOKTYPE_CAN_SEND_TO_CHANNEL, 0, nonotice_check_can_send_to_channel);
|
||||
|
||||
MARK_AS_OFFICIAL_MODULE(modinfo);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user