Commit Graph

72 Commits

Author SHA1 Message Date
Kevin Easton
50608f65ff Test sent_kick instead of kickcount for DEOPFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:26:57 +10:00
Kevin Easton
3caf308ea0 Test sent_kick instead of kickcount for JOINFLOOD kicking
kickcount is for counting KICKs sent by the user to detect KICK floods.
2017-06-11 00:23:39 +10:00
Kevin Easton
afc4793cd8 Remove unnecessary variable from userhost_scanport() and findports() 2017-04-17 13:27:35 +10:00
Kevin Easton
d851661942 Remove unused function argument from scan() 2017-04-16 23:28:18 +10:00
Kevin Easton
eca1e54602 Simplify addidle() a little 2017-04-11 01:54:31 +10:00
Kevin Easton
83770fd645 Simplify and clean up putlog() 2017-04-11 01:44:47 +10:00
Kevin Easton
3cf21ccc9d Simplify a conditional expression 2017-04-11 01:27:31 +10:00
Kevin Easton
bad8c2fa02 Remove netfinger client code and repurpose /FINGER command to send a CTCP FINGER instead
No-one runs fingerd servers anymore so this code was entirely obsolete.
2017-04-11 01:19:32 +10:00
Kevin Easton
eace841366 Enable use of cached whowas info for /IG* and /UNIG* commands
Previously these codepaths were dead because it was passing an argument like "+HOST" to check_whowas_nick_buffer()
in place of the channel name, so it would never find anything.

Now that function supports a NULL channel to mean "any channel", so we can use that.  The actual code itself needed to be
fixed as well, it's now similar to the way userhost_unban() is written.
2017-04-05 22:55:43 +10:00
Kevin Easton
2363ea709d Remove unused 'unlink' argument from check_whowas_nick_buffer()
Every caller was passing 0 for unlink, so remove it.  This simplifies the function.

Also change the nick and channel arguments to const char *.
2017-02-22 22:28:17 +11:00
Kevin Easton
0c721de2a5 Remove dead code and clean up convert_output_format_raw()
The second branch of if (str) ... else if (str) is dead code, remove it.  Also remove the if() entirely because
the while condition covers it exactly anyway.

Move the static variables used only in this function to function scope.

Change color_mod to const static and remove unneeded variable c_mod.

Move the increment of cparse_recurse to after the point where we bail.

None of this should have any user-visible impact.
2017-02-18 01:04:39 +11:00
Kevin Easton
61ff399b3d Remove superfluous test for current_window
It is always non-NULL, and we dereference it unconditionally anyway.
2017-02-18 00:32:23 +11:00
Kevin Easton
95a422cd27 Directly link string format to numargs in do_dirlasttype()
This is just a simplification - the string format should always match the arguments passed,
and none of the options are using anything but plain %s formats.

This also requires modifying /RELI to store the invited-channel in .last_msg so that it
can use the numargs = 3 format.
2016-05-15 22:43:01 +10:00
Kevin Easton
2c805c096f Use /FSET RELSN to format /RELSN relayed messages
The RELSN format already existed but wasn't used - instead it used SEND_NOTICE.  The other relay
types already used similar formats for their relayed messages.

The default /FSET RELSN looks just like the default /FSET SEND_NOTICE so this shouldn't be
noticeable to anyone using the defaults.

This required updating the NOTICE-sending code to correctly stash the 'to' in the right place.
2016-05-15 22:05:16 +10:00
Kevin Easton
d464bd91fb Remove unnecessary inclusions of <numbers.h>
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.
2016-03-24 11:21:09 +11:00
Kevin Easton
a2e8e103e0 Modularise handling of DCC offers
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.
2015-10-28 21:46:38 +11:00
Kevin Easton
9606ab312f Remove now-unused stripansi() function. 2015-09-06 22:54:12 +10:00
Kevin Easton
d62914af15 Optimise add_last_type() and change it to accept const char * pointers
The optimisation reduces the number of malloc_strcpy() calls, from 50 to 5
for most last types.
2015-09-03 01:04:12 +10:00
Kevin Easton
498631e74a Introduce get_kick_reason() and switch all kick commands to use it
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().
2015-06-28 00:35:50 +10:00
Kevin Easton
ff251080da Add get_kill_reason() that uses BitchX.kill, and convert all /KILL users to it
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.
2015-06-27 23:18:38 +10:00
Kevin Easton
27e32a0319 Cleanup and simplify get_reason() and related functions
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.
2015-06-27 00:38:40 +10:00
Kevin Easton
28bd7a66b6 Remove useless check for !nick from userhostbase callbacks
The userhostbase callback is always called with non-null nick.  Checking for
this is just noise which also sometimes results in odd compiler warnings.
2015-06-24 23:20:53 +10:00
Kevin Easton
69bbcfd83d Convert stripansi() from unsigned char to char
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...
2015-06-21 00:18:03 +10:00
Kevin Easton
b0f0124779 Don't compile convert_output_format2() in non-GUI builds
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.
2015-06-20 23:42:04 +10:00
Kevin Easton
64860729b3 Convert read_netfinger() to use char instead of unsigned char 2015-06-20 23:18:13 +10:00
Kevin Easton
716a8ec33a Change ar_* resolver functions from char to unsigned char where appropriate
This gets rid of all the unsigned char / char mismatch warnings in these
functions.
2015-06-20 22:36:05 +10:00
Kevin Easton
cce8b30079 Switch write_sockets() and read_sockets() from unsigned char * to char * 2015-06-20 08:43:00 +10:00
Kevin Easton
e646ab42d2 Move char_fucknut() and caps_fucknut() from misc.c to parse.c.
These functions are only used by parse.c:annoy_kicks(), so move them next
to that function and make them static.

This also changes their arguments from unsigned char * to char *, getting rid
of some signed/unsigned mismatch warnings.
2015-05-05 20:30:07 +10:00
Kevin Easton
9f7cf6b6c2 Alter the way PINGs for /sping and lag check are used.
We now send PING <server> :<server> for /spings, and
PING LAG!<cookie>.<tv_sec>.<tv_usec> :<server> for lag checks.  The cookie is
set randomly at server connect time, and means that clients connected to the
same bouncer shouldn't act on each other's lag checks.

We can now remove in_sping entirely - previously it would get out of synch if
you disconnected with a sping in progress.
2015-05-04 00:13:08 +10:00
Kevin Easton
34c34b9a43 Add ccTLDs for .cw (Curacao) and .sx (Sint Maarten).
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@511 13b04d17-f746-0410-82c6-800466cd88b0
2014-10-21 12:21:24 +00:00
Kevin Easton
a3170cf578 Fix regression introduced in r480, where /BKI on non-joined clients no longer ignored.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@499 13b04d17-f746-0410-82c6-800466cd88b0
2014-09-23 13:46:47 +00:00
Kevin Easton
e808dbe94b Change the lag check so that it does not try to format a time_t using %lu.
Recent OpenBSD and NetBSD have changed time_t to be a 64 bit type on all
platforms.  This means that on 32 bit systems, time_t is now longer than
long, and %lu can't be used to format it.

The lag check doesn't actually care what is in the first field of the PING
command, so change it to be our nick (which is arguably what it should be).


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@498 13b04d17-f746-0410-82c6-800466cd88b0
2014-09-21 14:54:12 +00:00
Tim Cava
112b38ac7a Revert the last commit. It accidentally had autogenerated files in it.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@432 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-07 03:00:24 +00:00
Tim Cava
276fd24258 Use snprintf rather than sprintf. From pvaldes.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@431 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-07 02:41:16 +00:00
Tim Cava
8e8a4022f9 Cleanup check_serverlag(), with suggestions from caf.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@427 13b04d17-f746-0410-82c6-800466cd88b0
2013-11-01 11:32:57 +00:00
Kevin Easton
717d2e88b7 Fix incorrect truncation in cluster() caused by strlcpy().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@377 13b04d17-f746-0410-82c6-800466cd88b0
2013-09-28 14:26:57 +00:00
Tim Cava
ea5aa01f87 Use strlcpy, rather than strmcpy, in cluster().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@372 13b04d17-f746-0410-82c6-800466cd88b0
2013-09-18 23:28:07 +00:00
Tim Cava
fafd888528 Cleanup rename_file() a little bit. Use strlcpy, rather than strmcpy.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@368 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-26 08:04:21 +00:00
Tim Cava
94f99bfdbb Use strlcpy, rather than strmcpy, in make_channel().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@354 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 09:11:04 +00:00
Tim Cava
41e52c7cf5 Use strlcpy, rather than strmcpy, in do_newuser().
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@353 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-17 09:07:32 +00:00
Kevin Easton
c7cefb1c05 Don't look beyond the end of a cparse format if it ends with % or $.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@310 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-10 15:59:04 +00:00
Kevin Easton
6691732900 Make add_socketread() close the new socket if it can't be added to the
socket manager because it exceeds FD_SETSIZE.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@307 13b04d17-f746-0410-82c6-800466cd88b0
2013-08-07 23:03:45 +00:00
Tim Cava
80cfa9c5d8 Make the namelen passed to getpeername() a socklen_t everywhere.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@279 13b04d17-f746-0410-82c6-800466cd88b0
2013-07-14 03:18:47 +00:00
Kevin Easton
bad477f9dc Fix off-by-one error in the check for s against FD_SETSIZE in add_socketread()
and set_socketwrite().  This was found by Coverity.



git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@237 13b04d17-f746-0410-82c6-800466cd88b0
2013-06-16 06:04:29 +00:00
Kevin Easton
2027f75969 Move inclusion of system headers in misc.c to top, which fixes building on
recent Cygwin (including windows.h after the macros defined in modval.h
causes the build to fail due to our 'load' macro).  Reported by VICODAN.

Also define WIN32_LEAN_AND_MEAN in misc.c, which should speed up Cygwin
build times a little.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@219 13b04d17-f746-0410-82c6-800466cd88b0
2013-01-02 22:40:58 +00:00
Kevin Easton
d13eee6683 The Cygwin resolver library doesn't fill out the list of name servers in
res_init() if /etc/resolv.conf doesn't exist, which is usual.

Add code to handle this by calling GetNetworkParams().


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@198 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-28 13:52:18 +00:00
Kevin Easton
79625bf516 Define BIND_4_COMPAT everywhere (except OS X, who just _had_ to be different)
and switch to using BIND4 macros (GETSHORT / GETLONG).

Should fix /nslookup on OpenBSD.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@196 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-27 04:42:09 +00:00
Kevin Easton
9ec4f49540 Apply patch from snadge to set BIND_4_COMPAT on OpenBSD. This is similar
to the existing BIND_8_COMPAT fix for OSX.

Oh how I hate the /nslookup function.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@187 13b04d17-f746-0410-82c6-800466cd88b0
2012-05-15 13:16:11 +00:00
Kevin Easton
87f24694b9 Remove unnecessary ns_init() function.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@149 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-10 11:22:14 +00:00
Kevin Easton
122849f247 Replace _getshort() and _getlong() with NS_GET16() and NS_GET32() respectively.
Fixes compilation on cygwin (and possibly other targets).


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@148 13b04d17-f746-0410-82c6-800466cd88b0
2012-02-08 12:53:16 +00:00