The static 'pos' variable in check_flooding() would not stay in sync with the number of entries in
flood_list after clean_flood_list() was called. This meant that check_flooding() would always end up
removing all previous entries if it tried to add a new one.
Fix this by removing the tracking of number of flood_list entries, and just removing stale ones (older
than /SET FLOOD_RATE).
Checking before truncation means you can sneak a privileged port past the check.
This change also collects the various broken-out parts of a CTCP DCC offer into a struct so that
it's easier to pass them all around together.
glob_commands() would run off the end of the irc_command array if given a match that matched
the last command. It also leaked memory because it used m_s3cat() to construct the string,
then passed that to m_strdup().
This fixes these problems by reworking glob_commands(), and at the same time removes the use
of alloca() and wild_match() by using strncmp() instead to match the start of a string. Move
glob_commands() to alias.c and make it static since it's only used for aliasctl().
Change the 'name' argument of find_command() and find_dll_command() to const char * at the same
time, so that glob_commands()'s prefix argument can be const char * too.
The 'channels' argument was unnecessary because the channel list passed to it would
always be from get_server_channels(server) anyway.
Changing the message argument from a protocol message format string to a plain payload
string for PRIVMSG means printf-escaping of the argument is avoided in the caller.
This simplifies the callers and means we can remove the last use of quote_it().
This change also switches set_server_away() to use send_msg_to_channels() instead of
open-coding the equivalent, which simplifies that function a lot.
We are changing the signature of a function exported to modules here; however none
of the in-tree modules use this function so it should be OK.
Identifiers beginning with two underscores or one underscore and a capital
letter are reserved in all contexts, including macros.
The __N macro in irc_std.h is in this space, and was conflicting with a macro
definition in gcc 5.4.0's xmmintrin.h under cygwin, making the build fail.
Reported-By: ice-man
This FSET has existed for a long while but has been unused for some time,
since before the userlist was reworked to use flags instead of levels. This
means that the default value for the FSET also has to be updated.
This switches from somewhat gory string parsing based on strncmp() and next_arg() to a simpler alternative
based on sscanf(). I think these are much easier to understand now, and shouldn't have any subtle bugs
lurking like the old code.
This also removes support for some obsolete messages that don't seem to be in any modern ircds:
"Identd reponse differs"; bot messages like "Rejecting vlad/joh/com bot:" except for "is a possible spambot"
which is still in use; and the "High-traffic mode" messages.
serversay() calls add_last_type(), so there's no need for the callers to do so
as well.
Remove the first argument to serversay() because it was always called with 1
anyway.
Remove the extra space in the default /fset SERVER_NOTICE, and similarly
the extra space in the HUMBLE /set SERVER_PROMPT.
The code in the client always _intended_ to add a space between SERVER_PROMPT
and SERVER_NOTICE_FSET but a bug in 75p3 and below meant it that it didn't.
This bug was fixed in 1.0b but the formats were never updated.
Also remove replace the embedded ANSI in the default SERVER_PROMPT with
% color code.
We don't know the server's proper name until registration, so the test against
that isn't reliable. We shouldn't be able to receive messages from anyone else
until we're registered, so this should be safe.
This requires changing serversay() to accept the from name instead of the
from_server. While we're there, replace the use of alloca() with simpler
logic based on m_sprintf().
This hook and format are used for NOTICEs where the destination isn't
a channel and isn't yourself - eg. global targets like $$*.org. This was
already the case for PRIVMSGs (using the MSG_GROUP hook and format).
Previously these were being routed like a normal NOTICE, and those don't
display the target, so it looked exactly like a private NOTICE to you.
This will also catch server notices sent before you're registered.
Functions display_msg() and check_sync() are only used in numbers.c, so they
can be static.
Remove inclusions of <numbers.h> from .c files that don't need it.
Some systems need <sys/sockio.h> for the SIOCGIFCONF ioctl - this switches
to using a proper configure check for that header rather than just assuming
it'll be there if we can't find SIOCGIFCONF. Should be more robust.
Only include <netinet/in.h> and <sys/socket.h> if the system supplies them.
This is necessary to try and get the mingw32 build working again.
No need to include <sys/types.h> and <netinet/in.h> from cdns.c - these are
already included by <irc.h>.
There's several different types of DCC offers, all of which need slightly
different handling. Previously they were all handled by the monster function
register_dcc_type() - this breaks them out into seperate functions for handling
SEND, RESEND, CHAT and BOT offers, moves common code into static helper
functions and renames the entry point from ctcp.c to handle_dcc_offer().
This will allow adding a way for modules to register DCC offer types that
they're interested in.
This also moves rename_file() from misc.c into dcc.c, where its only user is.
Mark DCC connections that we have requested RESUME on, so that we know
whether or not to act on a DCC ACCEPT that is received.
Also fixes up a slightly wrong message in /DCC RESUME.
DCC_CNCT_PEND was only ever set, not tested, so it was pointless.
There's no point only defining DCC_SSL when HAVE_SSL is defined: we can't
re-use that flag bit anyway, so might as well just define it always.
Also fixes a "flags && DCC_WAIT" that should have been "flags & DCC_WAIT".
This has no practical effect though I believe, since as far as I can tell
DCC_WAIT would always be set at that point anyway.
get_reason() is then used only for the implementation of get_kick_reason()
and for the $getreason() scripting function. Add current nick as an
explicit argument for get_reason(), which pushes all use of from_server
out of the ransom reason functions.
Also switch a few instances of send_to_server() to my_send_to_server() where
the current server has been returned by prepare_command().
Previously only send_kill() used BitchX.kill - the other KILL commands (eg.
/WHOKILL) were using the random kick reasons. Standardise them all on
BitchX.kill, and add this file to the source so it can be installed along
with the other random reason files.
Rename randreason() to fread_random() to better reflect its function,
and change it to a one-pass algorithm. Have it write into a caller-provided
buffer instead of a static buffer. Fixes a file leak when an empty
file is given to this function.
Change freadln() so that it never returns an empty line - it only returns
0 at end-of-file now. This simplifies its callers.
Factor out some common code from the several get_reason()-type functions,
which greatly simplifies them.
This silences a few compiler warnings.
This also cleans the function up by removing some always-true checks.
I'm not convinced that this function makes a whole lot of sense, though.
Will look into it further...
This function is only used by the GUI menu code, so we don't need to
build it for normal builds.
Also clean up some unsigned char / char mismatches that the compiler warned
about.
Chatnet doesn't use the odd 310 numeric support anymore, it now uses 310 for
the same WHOIS_HELPFUL as Dalnet. They apparently use a pretty bog-standard
Unreal ircd now.
Previously the server lag check was run by update_clock() if the number of
seconds since client startup was a multiple of 20 (unless it had already been
done this second). This meant that if update_clock() was not being called
frequently (eg. if your IRC connection was very quiet), it might go a long
time between lag checks.
This commit adds a /set LAG_CHECK_INTERVAL (defaulting to 30). For each
server, a lag check ping is scheduled for every LAG_CHECK_INTERVAL seconds
after the connection is finalised/registered. Setting this value to 0
disables the lag check pings entirely.
The old code set the lag to 'unknown' immediately after sending out a ping,
which meant that it was quite unpredictable how long the lag value would
stay around for. The new code only sets this once the current lag value
has become stale (ie. a ping reply is overdue based on the current lag
value). If your lag is staying the same or reducing, you shouldn't see
the [Lag ??] at all.
An absolute wake time is now calculated and updated by set_server_bits(),
TimerTimeout() and tclTimerTimeout(). This is then used to calculate the actual
select() timeout, instead of having those functions calculate a relative timeout
value themselves. This significantly simplifies those functions, since the
underlying values tend to be recorded as absolute times.
It also allows us to disentangle tclTimeTimeout from TimerTimeout(), and move the
responsibility for calculating the QUEUE_SENDS wake time from TimerTimeout() to
set_server_bits() where it belongs.
The QUEUE_SENDS and CONNECT_DELAY wake up times will also now be correctly
calculated, based on the last sent time and connect time respectively.