Commit Graph

439 Commits

Author SHA1 Message Date
Kevin Easton
9427b3db84 Try all addresses returned by getaddrinfo() until we find one that socket() is happy with
Someone reported being unable to connect with the error "Address family not
supported", which is probably being returned by socket().  It is likely a
system where getaddrinfo() is returning AF_INET6 addresses, but socket()
won't create AF_INET6 sockets.

To handle this case, we loop over all the addresses returned by getaddrinfo()
until we find one that socket() will accept.
2016-03-08 23:53:16 +11:00
Kevin Easton
c2a2d68d8d Only show version once with -v command line option
Reported by cpet.
2016-02-24 17:23:38 +11:00
Kevin Easton
6dc89247e2 Drop group privileges before dropping user privileges when execing
This ensures that the saved-set-gid is also set, although this shouldn't
matter in practice since we always call execve() soon after, which
overwrites the saved-set-gid with the effective gid anyway.
2016-02-24 16:52:33 +11:00
Kevin Easton
f2ae2327e3 Improve toplevel Makefile "all" target to work better with parallel make
Change the all: target in the toplevel Makefile so that it doesn't try to
resolve build dependencies at the top level - instead, it just recursively
builds the all: target in source/ and dll/.

Change the all: target in the source/Makefile so that it builds the EXTRAS
(scr-bx and wserv) as well as the main client binary.

The upshot of all this is that one "make" invocation is responsible for both
scr-bx and wserv, which is necessary for parallel make (make -j) to work
correctly as these binaries share some object files.
2016-02-19 22:54:50 +11:00
Kevin Easton
04f5138a6c Improve a couple of messages in /window create 2015-11-11 17:05:58 +11:00
Kevin Easton
8886c20c1b Improve messages shown by /window size 2015-11-11 14:59:21 +11:00
Kevin Easton
4ee14e00c2 Minor cleanup in add_userhost_to_dcc() 2015-10-29 22:17:10 +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
af3b0c920a Change find_name_in_genericlist() to take const char * argument 2015-10-28 21:42:33 +11:00
Kevin Easton
f2262d5b01 Change hash_nickname() to take a const char * argument 2015-10-28 21:38:26 +11:00
Kevin Easton
a24f1d12ec Convert lookup_userlevelc() to accept const char * parameters
Also converted dependant functions check_channel_match() and
find_bestmatch() to use const char *.
2015-10-20 23:12:33 +11:00
Kevin Easton
51ecdb8d1b Re-add code for DCC CHAT autoget mistakenly removed in [be6bd5aca] 2015-10-12 17:22:52 +11:00
Kevin Easton
cfe6735ef0 Simplify find_dcc() and find_dcc_pending()
Extract the common DCC matching code into one function and simplify
it a little.
2015-10-12 16:26:23 +11:00
Kevin Easton
fe368ac875 Fix argument order for dcc_getfile_resume_start()
The last two arguments are port, then offset (as per the DCC ACCEPT CTCP
command).  We don't really use these anyway - port is passed to dcc_create()
but for pre-existing DCC entries all that did was add it to the socketinfo,
which doesn't seem to have any real effect.

Also fix dcc_create() so it passes the actual remote port to add_socketread()
(as above, this doesn't seem to have any real effect but is consistent with
the other code).
2015-10-10 22:48:26 +11:00
Kevin Easton
be6bd5aca4 Simplify and improve code around DCC auto-get / auto-rename / auto-resume
This improves the client messages - eg previously the message to tell you that
you could use /DCC RESUME never got shown due to a logic error.

It also won't try to auto-resume if the local file is already the same size or
bigger than the incoming file.
2015-10-10 00:08:00 +11:00
Kevin Easton
ce3fd79652 Global spelling fix s/recieve/receive/ across codebase
This includes some user-visible messages and help files, so if anyone has
hooked them with /ON WINDOW their hooks will need updating.
2015-10-04 09:06:38 +11:00
Kevin Easton
726884b0b0 Ignore DCC ACCEPT if we didn't request a DCC RESUME
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.
2015-10-04 00:44:47 +10:00
Kevin Easton
c173af3f65 Remove unused DCC_CNCT_PEND flag and always define DCC_SSL
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.
2015-10-03 22:10:15 +10:00
Kevin Easton
857a5fa524 Fix /KB so that it kicks-then-bans as documented
This also fixes a few others - eg /KBI now kicks-then-bans, and
/BKI bans-then-kicks (previously these were the wrong way around).

Reported by profiler.
2015-09-20 21:54:54 +10:00
Kevin Easton
aea7050efe Don't create a double stack frame when calling aliases
The old code created a new stack frame in parse_line_alias_special(), then
another one in parse_line().  This prevented $functioncall() from working,
and made the output of CALL look odd.

|Rain| mentioned this years ago in starman.irc.
2015-09-08 23:35:06 +10:00
Kevin Easton
8cc9684c76 Ensure close_server() clears the who/ison/userhost queues for the right server
close_server() should call clear_server_queues() on the server that's being
closed, not from_server.  This also lets us remove a few other calls to
clear_server_queues() that are right next to calls to close_server().
2015-09-07 16:34:41 +10:00
Kevin Easton
9606ab312f Remove now-unused stripansi() function. 2015-09-06 22:54:12 +10:00
Kevin Easton
2520bd32f6 Separate parsing of channel WALLs into a function and clean it up
Channel WALL notices now have to match "[%Wall%/%] *", and have to be for
a channel that the client is actually on.  Otherwise, they just appear as
ordinary NOTICEs.
2015-09-06 22:47:20 +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
c881dd7a9a Change 'from' and 'format' arguments of logmsg() to const char *
This allows callers to pass const char * pointers to them.
2015-09-02 23:39:53 +10:00
Kevin Easton
d1816fdc8b Don't mangle ANSI sequences in NOTICEs.
We pass through ANSI just fine in PRIVMSGs, so we might as well treat
NOTICEs the same way too.  The old code wasn't just stripping them out,
either - it was turning them into printable garbage.
2015-09-01 23:04:01 +10:00
Kevin Easton
75bd647d15 Switch stripansi() to stripansicodes() in the CTCP reply parser.
stripansi() actually just munged control-characters, so it just turned ANSI
codes into visible junk.

stripansicodes() instead leaves control characters alone but removes complete
ANSI sequences from the string.  I'm not sure if even that is necessary,
really - after all, we always allowed ^B, ^C etc style formatting in CTCP
replies.
2015-08-30 22:03:38 +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
5f4429bf7b Removed unused variable from output_reject_ctcp()
Also remove unnecessary tests for stuff and stuff->user - these are always
non-null when the callback is called.
2015-06-25 11:45:09 +10:00
Kevin Easton
ee0cd23ae5 Rearrange code in bankick() to silence a compiler warning
Re-checking the command name to see if it's a timed ban means that the
compiler can't see that it's the same check.

This also makes sure you can't specify a negative timeout.
2015-06-24 23:38:28 +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
05cf540a99 Fix use of uninitialised variable and hostmask matching logic in userhost_unban()
Initialise ip_str so that it isn't used uninitialised.

Don't strip server flags from user@ portion of the hostmask, so that it will
not miss matching bans.

Switch ip_str from alloca() to malloc_sprintf() / new_free() - there's no
particular need for alloca() here.
2015-06-23 15:53:30 +10:00
Kevin Easton
90f85dec0c Clean up unsigned char / char mismatches in screen.c
Also remove a couple of unused variables in prepare_display()
and create_additional_screen().
2015-06-21 22:50:44 +10:00
Kevin Easton
91d6169cb7 Fix unsigned char / char mismatches in a few remaining places in functions.c
Also slightly clean up function_stripansi(), removing a redundant mask.
2015-06-21 18:01:11 +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
8649c17912 Change edit_char() from unsigned char to char
This squashes a few more warnings.
2015-06-20 00:03:15 +10:00
Kevin Easton
53f7c374cf Convert strip_ansi() from unsigned char to char
This required a few careful changes to ensure that the result does the same
thing.

Also included a few little cleanups in this function.
2015-06-19 23:12:10 +10:00
Kevin Easton
d0b0a95330 Convert skip_ctl_c_seq() and its callers (except strip_ansi()) from unsigned char to char
This should make no functional difference, and cuts out a large number of
unsigned char * / char * mismatch warnings.
2015-06-17 22:50:49 +10:00
Kevin Easton
563493dd6a Add COLOR_CHAR and BELL_CHAR defines to replace open-coded values 2015-06-16 19:06:30 +10:00
Kevin Easton
aa3dc1939d Remove obsolete Chatnet 310 numeric support (WANT_CHATNET)
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.
2015-06-16 13:23:36 +10:00
Kevin Easton
6077322ef8 Check for socket errors when connection is terminated by server
This means that when a connection fails or is closed due to a socket
error, the error is properly bubbled back up to the user.
2015-06-13 23:29:00 +10:00
Kevin Easton
bc94fbe64a Remove a strange old piece of code apparently for detecting a server gone to lunch
This code appears to be some kind of backstop so that the client will notice
a server connection that's died because of a network interruption.  Checking
errno that was last set christ-knows-where is not the right way to do this,
though.

The normal write to the server for the lag check should eventually see the
host/net unreachable error if this happens.
2015-06-13 22:35:03 +10:00
Kevin Easton
b0951d44dd Simplify and make static reconnect_server() function 2015-06-13 22:30:44 +10:00
Kevin Easton
1883e2c0c3 Minor fix to /STACK to make it match /SET behaviour
Previously /STACK would not accept just the initial part of a /SET name
even if it wasn't ambiguous.  Now it uses the same matching behaviour
as /SET.

This also removes an unused variable in do_stack_set().
2015-06-12 16:57:19 +10:00