Commit Graph

243 Commits

Author SHA1 Message Date
Kevin Easton
8072aea782 Improve error messages for SSL connection failures
This now shows the underlying failure reason, and includes the server name.
2019-01-16 23:54:59 +11:00
Kevin Easton
95b57cc3cc Correctly handle reconnection after finalize_server_connect() fails
finalize_server_connect() can fail for SSL connections, because SSL_connect() can fail.  Without this change, the client won't
try to reconnect after an initial SSL connection failure - it'll just wait forever.

Reported by g0z, thanks!
2019-01-16 17:13:29 +11:00
Kevin Easton
66b6fa4345 Add /EXEC -WINTARGET <target> argument
This allows you to choose a specific target window for the output of an /EXEC.
2018-11-30 13:17:27 +11:00
Kevin Easton
e51469568e Update command-line help text to explain server descriptions
Makes it clear that a each server can also specify port/password/nick/network if desired.

Reported by Ant.
2018-11-14 13:17:48 +11:00
Kevin Easton
b5afd1d596 Replace last uses of bcopy() with memcpy()
memcpy() / memmove() are standard everywhere, this lets us remove the configure script checking around bcopy()
which helps building on Haiku OS.
2018-11-11 01:07:31 +11:00
Kevin Easton
d897a3b753 Fix /HISTORY *pattern* and /HISTORY -CLEAR
This code contained a bug where any argument to /HISTORY that _didn't_ start with "-CL" would clear history,
so no number or pattern argument could successfully be passed.

With this fix only an argument that case-insensitively matches "-clear" will clear history, so a pattern
argument will also work correctly.
2018-11-05 23:25:01 +11:00
Kevin Easton
d4c6123002 No tabs should be shown when /SET TAB is OFF
This also counts beeps, tabs and non-destructive spaces in the same way.

To maintain historical behaviour, BEEP_MAX of zero indicates no beeps allowed (the same
as /SET BEEP OFF), but TAB_MAX and ND_SPACE_MAX of zero indicates no limit.
2018-05-25 11:19:02 +10:00
Kevin Easton
f859f9e2f8 Count columns used by ND_SPACE character when splitting lines
ND_SPACE take up a printable column, so they need to be counted.  Reproducer:

/eval echo $repeat(160 $chr(19))XXXXXXXXXXXXXXXXXXXXXXX
2018-05-17 16:26:17 +10:00
Kevin Easton
5cc052ee6c Use target window width rather than terminal width to wrap /list -wide output
This should make the output correct in more circumstances.  It's the same wrapping used by add_to_window, anyway.
2018-05-10 17:33:35 +10:00
Kevin Easton
99c5ec9872 Change arcfour example module to use ARC4CHAT instead of SCHAT as the DCC type
The SCHAT type is already used by some other clients for SSL CHAT.  This example module doesn't work
yet anyway, so no-one can actually be using it.
2018-03-14 16:58:10 +11:00
Kevin Easton
9e7fc85ae1 Fix various problems with adding and removing module DCC bindings
Change remove_all_dcc_binds() so that it only removes DCC binds for the module supplied, as it's supposed to.

get_dcc_type() should ignore the first entry in dcc_types[] ("<none>") otherwise the client will try to
respond to DCC requests with that name.

Explicitly track the number of entries in the dcc_types[] array rather than using a NULL terminator.  This
allows us to change dcc_types[] to use NULL entries to mark unused slots in the array, rather than pointers
to entries with a NULL .name element.  Together, this means that the dcc_types[] array is only resized when it
actually needs to be grown and removal works correctly (without eg. prematurely marking the end of the array).

Make add_dcc_bind() fail if the requested DCC type has already been bound by a module (this still allows one
module at a time to rebind a built-in DCC type).  Previously the behaviour was ill-defined in this case.
2018-02-20 23:27:32 +11:00
Kevin Easton
5ae42802ec Fix crash when unloading the arcfour module
Remove the empty Arcfour_Cleanup() function so that the default module cleanup can happen.

Define MODULE_NAME and use that when registering the module callbacks so that the default
module cleanup will remove them correctly.
2018-02-20 23:00:00 +11:00
Kevin Easton
61a926a766 Introduce a struct dcc_ops to contain all functions pointers for a custom DCC type
Modules now must pass a pointer to a struct dcc_ops when calling add_dcc_bind() instead of
a list of function pointers.
2018-02-08 22:39:49 +11:00
Kevin Easton
c7a72b79ae Fix redirecting to DCC CHATs with /REL* commands
to + 1 is the correct destination, not to + 3.
2017-12-20 20:25:27 +11:00
Kevin Easton
2c94010d65 Update arcfour example module to use exported dcc_chat_socketread() callback
This allows it to actually connect OK, but it's still nonfunctional at the moment.
2017-12-20 18:10:02 +11:00
Kevin Easton
d7688075b6 Export dcc_chat_socketread() and dcc_send_socketread() callbacks to modules
The idea here is that if you have a module which implements a new DCC type that is essentially
a lightly-modified version of CHAT or SEND you can reuse these functions.
2017-12-20 17:36:05 +11:00
Kevin Easton
3800e4b099 Replace get_server_flag() with get_server_umode()
This function gets the status of a single umode flag identified by umode char rather than
internal server flag number.

This also lets us remove all the USER_MODE* constants because they're no longer required.

Invert the sense of the +w check in e_wall() - we only echo our OPERWALL if we're *not* +w,
because if we are +w then the server will echo it back to us anyway.
2017-12-07 00:23:43 +11:00
Kevin Easton
7642e741b9 Switch to using NULL server.ssl_fd to mark new SSL connection instead of NULL server.ctx
server.ctx is now allocated once for each server on first connection, then reused for subsequent connections.

server.ctx wasn't being cleared when the server was closed (as server.ssl_fd is), so this was causing
reconnection to fail until try_connect() got called.

This also removes the last uses of the CHK_* macros in ssl.h, so remove them.
2017-12-03 02:16:39 +11:00
Kevin Easton
abc9dbdf9e Use SSL_free() when closing an SSL server connection
This avoids leaking memory.

Also change to always call SSL_shutdown() regardless of whether a QUIT message was sent.  No
need to call SSL_shutdown() from write_to_server(), close_server() will do it for us.

Remove "Closing SSL connection" message.
2017-12-03 01:06:53 +11:00
Kevin Easton
5d131bcf01 Add SSL version and cipher to SSL connect message
Similar to what EPIC5 does.
2017-12-03 00:13:47 +11:00
Kevin Easton
035063abce Add BITCHXRC_NAME to config.h
(instead of hardcoding it in irc.c).  Simplify setting of ircrc_file and bircrc_file.

Use IRCRC_NAME and BITCHXRC_NAME in help strings.
2017-12-01 23:33:13 +11:00
Kevin Easton
973ae0e4da Correctly handle case when a nick comes between a -s flag and a server name on the command line
The -s flag resets after the next server on the command line, but it was also incorrectly resetting
if a nickname was seen as well. This meant that a command line like this failed to use SSL:

BitchX -s -p 9999 gauze irc.choopa.net

Also update the help text to correctly reflect the operation of the -s flag.

Reported by gauze.
2017-12-01 23:05:58 +11:00
Kevin Easton
0ba25f02a5 Simplify and clean up find_dll_command()
The only external change here is that it now always sets *cnt to 0 when it returns NULL

Previously, it could set it to -1 in some cases, in particular when dll_commands is NULL.
This led to a bug where /HELP would show the wrong number of matching commands, because it
added the return value of find_dll_command() to the number of matching internal commands.

Also fixes a set-but-unused-variable warning.
2017-11-27 17:18:15 +11:00
Kevin Easton
ba1b9742ec Simplify calling of rsindex() and strsearch()
Remove the 'how' parameter to rsindex(), making it reverse-search for only the first matching character,
as sindex() already does.  There are only two callers, and one already passed a hardcoded value of 1.

Also change rsindex() so that it starts searching at the character BEFORE the passed in position.  This
makes it easier to repeatedly call rsindex() in a loop to search for the Nth matching character, and
also fixes a technical instance of undefined behaviour where a pointer is decremented to point before
the start of the string.

Remove the 'mark' parameter to strsearch().  Instead, always forward-search from the beginning of the
string and reverse-search from the end of the string, as this is what the two callers want anyway.

Bump the module ABI version because these functions are exported to modules.
2017-11-23 17:22:38 +11:00
Kevin Easton
de303ba554 Change scr-bx to list the detached screens if more than one matches
This appears to be the original intention.  It's certainly more friendly, anyway.
2017-11-18 00:20:36 +11:00
Kevin Easton
fea88185f8 Clean up function move_to_abs_word() and rename to move_to_word()
Remove the output argument, as it's the same as the function return value anyway, so
the callers should just use that.
2017-11-14 23:15:33 +11:00
Kevin Easton
a71ee883e1 Make "You can't hide an invisible window" message respect /SET WINDOW_QUIET
Also remove unnecessary NULL check, window->screen is already checked for NULL.
2017-11-10 17:16:58 +11:00
Kevin Easton
3ec950a7d7 Allow $mychannels() to query a window attached to a different server
Otherwise, there's really no point in passing this function a window refnum at all.
2017-11-10 16:57:26 +11:00
Kevin Easton
a028aebdb9 Fix crash when passing $mychannels() a non-existent window refnum 2017-11-10 16:53:32 +11:00
Kevin Easton
50999b3d5b Remove six dll_ variables from the module exports table
The removed variables are:

	dll_functions
	dll_numeric
	dll_commands
	dll_variable
	dll_ctcp
	dll_window

These are not actually directly used by any modules, and hiding them allows us to more easily
change their implementation later.
2017-11-06 17:14:12 +11:00
Kevin Easton
fcda7a4d55 Switch cavlink and nap plugins to use save_dllvar() function for saving SETs
This removes the only module uses of dll_variable, allowing it to be removed from the module
exports.
2017-11-06 17:01:36 +11:00
Kevin Easton
3f047ab2a9 Add save_dllvar() function exported to modules
This helper function is for modules to save the contents of their module variables to a file
as SET commands.

It will remove the need to export the raw dll_variable list to modules.
2017-11-06 16:54:51 +11:00
Kevin Easton
ff048fbee9 Shitlist level 3/4 should kick regardless of /CSET KICK_IF_BANNED
As reported by Ancient, this is how it is documented to work.  It's also how shitlist level 2 works, so
it's consistent this way.

Some other cleanups in check_auto() while we're here.
2017-10-23 00:32:05 +11:00
gdinit
bac141898b Correct spelling of some client messages, comments and function names 2017-10-20 14:57:17 +11:00
Kevin Easton
5839f2b393 Support fractional-second intervals on recurring timers
A fractional-second timeout was already supported for the initial timeout of a /TIMER, but
if the timer was recurring then the interval was rounded to a whole number of seconds for
the subsequent timeouts.

Change the type of interval from long to double to fix this.
2017-10-11 23:21:14 +11:00
Kevin Easton
5bd8a40cf8 Change $geom() to return current screen's geometry, not the original terminal's
This only affects additional screens created with /window create, which is an unusual
configuration.
2017-09-15 17:39:52 +10:00
Kevin Easton
4a3cff53f4 Simplify and improve justification step of status formatting, and use the same code for $statsparse()
Separate out the justification step of make_status() into a new function, so it can be wired in to
stat_convert_format() as well.  This makes $statsparse() work correctly with right-justified status
formats.

Minimise the amount of copying around that is done during the justification - instead, we can just
remember pointers into the buffer returned by strip_ansi() for the left-hand-side, right-hand-side and
padding character.

Don't keep concatenating onto the same buffer with strlcat() when generating the padding - that gives
n^2 behaviour.  Instead keep a pointer to the current end and concatenate there.

Ensure buffer is null-terminated before calling strlcat() on it, in stat_convert_format().
2017-08-23 02:21:42 +10:00
Kevin Easton
742eeb33f7 Restore terminal settings after flushing output, not before 2017-08-22 22:26:50 +10:00
Kevin Easton
0fea2b97a4 Remove exported function create_server_list()
The guts of this function doesn't need to be in server.c - it only uses extern server functions so it
makes sense just to move it into the body of function_servers(), the only caller.

That means it's no longer accessible for loadable modules, but it isn't much use for them anyway.  They
can always directly access the server list if they need that info.

(Requires rolling the module table version).
2017-07-17 12:59:49 +10:00
Kevin Easton
d2e576a774 Fix $myservers(1) to only return registered server refnums
When $myservers() is called with an argument of 1 it is supposed to only return the refnums of servers
that are registered (ie. those which it is legal to send a command to).  This is the way EPIC works, and
it was always intended to work this way in BX too.

Also fix the warning about a NULL itsname - we use our name for the server if it isn't registered yet.

Remove the slightly bogus use of strncat() while we're here, by removing the temporary stack buffer and
just directly creating the result string with m_s3cat().
2017-07-17 12:48:28 +10:00
Kevin Easton
cd9c358eed Fix CHANGE_NICK_ON_KILL feature
Remove the 'resend_only' flag option to fudge_nickname().  The only caller passing it was the CHANGE_NICK_ON_KILL
feature, and in that case it was the wrong thing too (and stopped that function from working at all).

Some other minor cleanups in fudge_nickname() while we're there.
2017-07-15 23:29:14 +10:00
Kevin Easton
9c46ddddb6 Check for unset MSGLOG_FILE or CTOOLZ_DIR, or failed stat(), in readlog()
Unset MSGLOG_FILE or CTOOLZ_DIR could cause a null pointer dereference.

If stat() failed it dereferenced the bogus 'struct stat', and in the directory case
just silently failed.  Now it falls through to the "error opening" path.
2017-07-15 00:07:25 +10:00
Kevin Easton
a6a5a19e28 Fix memory leak in /QUEUE -FLUSH
The queue->name must be freed.
2017-07-11 19:01:09 +10:00
Kevin Easton
dbd37bc35d Messages sent by /SV and /PASTE should be logged in the send log
This looks like an oversight.
2017-07-09 00:14:15 +10:00
Kevin Easton
bb616e0626 Change send_text() to combine command, hook and log arguments into one set of flags
This function is exported to modules, so it requires updating a few modules and rolling the module table version.
2017-07-09 00:08:04 +10:00
Kevin Easton
ac84793dd6 Switch from direct tcl_interp->result access to Tcl_GetStringResult() and Tcl_AppendResult()
This allows building against recent libtcl versions.

A fallback definition of Tcl_GetStringResult() is included so that building against libtcl 7 still works.
2017-07-01 00:47:20 +10:00
Kevin Easton
c62e099d80 Add /FSET SEND_ENCRYPTED_PUBLIC format
Used when sending an encrypted message to a channel.
2017-06-28 00:03:09 +10:00
Kevin Easton
72ee3e6297 Correct order of arguments to /FSET SEND_ENCRYPTED_MSG and SEND_ENCRYPTED_NOTICE and improve default formatting
The argument order and default format now mirrors SEND_MSG / SEND_NOTICE but with different colours.
2017-06-27 16:27:59 +10:00
Kevin Easton
ed597221f2 Add ENCRYPTED_PUBLIC and ENCRYPTED_PUBLIC_NOTICE formats
Encrypted messages to a channel need to use their own format.  This also fixes the use of ENCRYPTED_PRIVMSG
and ENCRYPTED_NOTICE - they were being called with too many arguments so the destination nick was being prepended
to the message text.
2017-06-27 14:21:12 +10:00
Kevin Easton
06aa5cb671 Move all handling of SED messages and notices into ctcp.c, re-enable SED notices
Actual encryped messages and notices are now printed directly from do_sed() / do_reply_sed().
Inline CTCP replacement is only done if the message cannot be decrypted (for the [ENCRYPTED MESSAGE]
placeholder).

This removes the need for the global flag 'sed' to alter the NOTICE and PRIVMSG handling.

A side-effect of this is that SED PRIVMSGs now do not go through the usual PRIVMSG ignore
and flood handling.  This is acceptable because messages can only go through this path if
the sender has actually been added as a SED peer with /ENCRYPT, and it still goes through
the CTCP ignore and flood handling.
2017-06-26 15:13:40 +10:00