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!
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.
The idea here is not to expose the internal server implementation for storing umodes,
but instead have callers just work in terms of umode characters.
The 'possible umodes' have always been the same for all servers anyway. We just assume
that [a-zA-Z] is the bounding set.
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.
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.
CLOSING_SERVER was never referenced outside of server.h where it's defined, and CLOSE_PENDING was cleared
but never set by any code.
Rename LOGGED_IN to namespace it (in anticipation of other flag variables in the server struct being
consolidated into a set of server flags).
Also put correct parantheses around the definition of SF_LOGGED_IN.
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).
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().
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.
This test is done quite a bit across the tree, and the open-coded variants make it easy to have an
accidental mismatch between the length of the prefix being tested and the length actually passed to
strncmp().
This fixes an issue of that type comparing the server version against the prefix "u2.10", where the old
code used an incorrect length of 4.
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.
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().
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.
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.
This means that settings like CONNECT_DELAY and CONNECT_TIMEOUT are compared
against the current time with sub-second resolution. With the old way, the
delays could be up to a second longer than asked for, which had the effect of
almost doubling the default CONNECT_DELAY value of 1.
set_server_bits() now returns -1 for "no timeout", so 0 is a legitimate
return value.
io() should only update real_timeout from server_timeout if server_timeout
is not -1 (real_timeout == -1 ends up meaning "wait indefinitely").
Note that if you set CONNECT_DELAY to zero you get a lag check ping sent off
first thing in the server connection, this should be fixed.
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.
An snprintf() call that creates IRC protocol messages must use
(MAX_PROTOCOL_SIZE + 1) as 'n' rather than the buffer size.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@461 13b04d17-f746-0410-82c6-800466cd88b0
This includes all of the underlying support, but doesn't hook it up to the
/SERVER command yet, so it's not useable at this point.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@216 13b04d17-f746-0410-82c6-800466cd88b0
huge amount of work on each keystroke if you have a long server list and
start it up disconnected (-N).
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@150 13b04d17-f746-0410-82c6-800466cd88b0
on a socket.
I also added a wrapper function around strerror() for dgets_errno, since
we did the same thing in a few places. This all needs to be cleaned up
a little - the -1 value we use could in theory clash with an actual
errno error number.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@104 13b04d17-f746-0410-82c6-800466cd88b0
per-server, and apply new version of do_oops from flewid (the BX2 version).
This means that /oops, "/query .", "/query ,", "/msg ." and "/msg ," are now
per-server, along with the $. $, and $B aliases.
git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@87 13b04d17-f746-0410-82c6-800466cd88b0