Commit Graph

443 Commits

Author SHA1 Message Date
Valentin Lorentz
ee9f0dc1bf STS: When persisting STS keys, use the actual port instead of the one from the policy
'Servers MAY send this key to securely connected clients, but it will be ignored.'
-- https://ircv3.net/specs/extensions/sts\#the-port-key
2021-09-03 20:15:18 +02:00
Valentin Lorentz
74073b2736 irclib: Log the server's error message on SASL failure. 2021-09-01 18:25:54 +02:00
Valentin Lorentz
db7ef3f025 all: Add generic 'The Limnoria Contributors' to copyright notices.
No need to bother with details (that are all outdated / out of sync
anyway), just look up the git history.
2021-08-01 21:54:49 +02:00
Valentin Lorentz
8fe517f48a irclib: Fix previous commits so RPL_NAMREPLY actually works
Turns out irclib parses ISUPPORT PREFIX properly, so it's not just
a raw string; but I didn't test the change live...
2021-07-16 22:53:38 +02:00
Valentin Lorentz
45c7615f4a irclib: Properly populate nickToHostmasks on RPL_NAMREPLY
It used to set the nick instead of the hostmask as values...
2021-07-16 19:53:25 +02:00
Valentin Lorentz
d308329461 irclib: Fix support of power prefix chars in RPL_NAMREPLY
nickFromHostmask now (legitimately) complains when it's getting @ or !
at the beginning of a hostmask; so we need to strip them before passing
it to nickFromHostmask.

Then re-add them before calling c.addUser, because it uses them to
sort users in the right sets (ops/halfops/voices).

Additionally, this commit replaces the hardcoded set of prefix chars
(`@%+&~!`) with the one advertised in ISUPPORT when possible.
2021-07-16 19:50:13 +02:00
Valentin Lorentz
65ab65cbb1 irclib: Fix crashes when ERROR is part of a batch. 2021-06-20 23:59:51 +02:00
Valentin Lorentz
225c249ec2 irclib: Fix crash on SASL authentication failure 2021-06-05 15:50:05 +02:00
Valentin Lorentz
710d16f301 Admin: Fix python 3.4 support. 2021-05-25 19:24:21 +02:00
Valentin Lorentz
177c20267c irclib: Fix crash caused by 4d2efc65ef.
dynamicScope inspects the stack looking for this variable, so we need to keep it.
2021-04-24 21:21:57 +02:00
David Macek
151fcf8caf Don't throttle when delay is exactly equal
If throttle time is set to 0.0 (e.g. in tests) and the reported time
since last dequeue is also 0.0 (maybe because the timer resolution is
too low), takeMsg would throttle.  This would make tests fail because
they expect messages immediately.

This issue was observed on Windows 10 20H2 with both a mingw-w64 Python
v3.8.9 from MSYS2 and several version of official Python v3.x.
Confirmed at least as far back as
aa98d987a7.

Since it's a non-integer comparison, the change shouldn't have any
observable effect in normal operation.
2021-04-24 21:04:42 +02:00
David Macek
4d2efc65ef Remove some unused names 2021-04-24 21:01:40 +02:00
Valentin Lorentz
c28d517d6f irclib: Copy messages before altering them at all
Fixes a bug triggered by Relay when it relays to a network that supports
labeled-response and an other that doesn't
2021-04-02 20:54:21 +02:00
Valentin Lorentz
7cb3ae12da Misc: Make @more reply in batches when possible. 2021-04-01 20:10:17 +02:00
Valentin Lorentz
567618392f Add tests + fix bugs 2021-04-01 20:10:17 +02:00
Valentin Lorentz
99a6a7cde9 raise exceptions instead of logging, so we get a helpful traceback 2021-04-01 20:10:16 +02:00
Valentin Lorentz
c7939d3eb5 [wip] typo 2021-04-01 20:10:16 +02:00
Valentin Lorentz
26f2d9a292 [wip] idea for ordering batches in Irc.queue 2021-04-01 20:10:16 +02:00
Valentin Lorentz
e19436a4ba [wip] support outgoing batches 2021-04-01 20:10:16 +02:00
Valentin Lorentz
8b90884fa0 irclib: Copy messages before echoing them
Fixes a bug triggered by Relay when it relays between three or more networks.
2021-04-01 20:09:28 +02:00
Valentin Lorentz
d60cc5c92a irclib: add method getClientTagDenied
To allow plugins to check if they should send a tag or not.
2021-03-18 19:56:30 +01:00
Valentin Lorentz
cb7a395444 irclib: truncate outgoing messages to 512 bytes, not 512 chars 2021-03-11 19:02:55 +01:00
Valentin Lorentz
4aca6e3d5a Add support for receiving commands from draft/multiline batches. 2021-03-04 21:34:25 +01:00
Valentin Lorentz
f8c5221efd do43x: add the current nick to the list of tried nicks.
The original nick was never added to the list...
2021-03-04 21:29:23 +01:00
Valentin Lorentz
6f6dad8f7b Add proper support for nested batches. 2021-03-03 23:32:00 +01:00
Valentin Lorentz
9719bb799e irclib: Send the bot user mode when advertized by the server
It is enabld by default in order to be a good netizen,
but can be overridden by admins if needed.

References:
*
* https://github.com/ircv3/ircv3-specifications/pull/439
2021-02-28 11:11:29 +01:00
Valentin Lorentz
772ec8d6a9 When getting STS policy over insecure connection, reuse the exact same IP address
Otherwise, if some IP addresses don't work (eg. all odd ones), the bot will
consecutively fail because it can't connect, then connect + get STS + reconnect,
then fail again, then connect + get STS, etc.
2021-01-11 23:22:21 +01:00
Valentin Lorentz
771c05c666 irclib: Fix test failure
FAIL: testMoreIsCaseInsensitive (Misc.test.MiscTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 214, in runTest
    originalRunTest()
  File ./plugins/Misc/test.py, line 260, in testMoreIsCaseInsensitive
    self.assertNotError('more %s' % nick.upper())
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 355, in assertNotError
    m = self._feedMsg(query, **kwargs)
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/test.py, line 526, in _feedMsg
    response = self.irc.takeMsg()
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/log.py, line 368, in m
    return f(self, *args, **kwargs)
  File /home/travis/virtualenv/python3.8-dev/lib/python3.8/site-packages/supybot/irclib.py, line 1308, in takeMsg
    assert not msg.tagged('emulatedEcho')
AssertionError

I don't understand why it's happening or why it's only that specific test,
but there we go.
2020-11-10 09:47:36 +01:00
Valentin Lorentz
c062787436 irclib: use a dedicated tag to detect emulated echo-messages, instead of receivedAt.
Plugins implementing inFilter do not set receivedAt, so incoming messages
rewritten by inFilter would be detected as echo messages, and ignored
by most plugins.
2020-11-04 11:32:20 +01:00
Valentin Lorentz
160bcc8b6b Revert "irclib: Fill the nick and prefix of simulated echo messages."
This reverts commit 1fe414764c.

I initially wrote that commit so that plugins with echoMessage=True can
get the nick/prefix from the message (eg. the SkypeRelay plugin in my
personal repo).
Unfortunately, this breaks any test that does equality comparison on
between the result of getMsg()/takeMsg() and an IrcMsg object they
crafted themselves.

Additionally, the filled in nick and prefix might be inaccurate if the
bot changes nick/host at the same time. So instead plugins should check
for the None value.

(Also, editing IrcMsgs on the fly like this isn't great, and the commit
forgot to reset the `_str` attribute.)
2020-10-22 20:04:23 +02:00
Valentin Lorentz
1fe414764c irclib: Fill the nick and prefix of simulated echo messages. 2020-10-17 14:22:48 +02:00
Valentin Lorentz
48b24769c2 irclib: Document classes better, especially instance attributes. 2020-09-27 15:51:01 +02:00
Valentin Lorentz
5d80b2eec9 irclib: Fix crash when MOTD is sent again later in the connection.
This can happen with this ZNC module: https://wiki.znc.in/Missingmotd
or if a plugin sends a 'MOTD' command.
2020-09-19 17:08:52 +02:00
Valentin Lorentz
0a6bb49fe6 irclib: Fix crash on CAP NEW.
Turns out, it wasn't tested so it never worked...
2020-09-19 16:55:51 +02:00
Valentin Lorentz
5dc72d2b34 Rename IrcCallback.echo_message to IrcCallback.echoMessage.
For consistency with 'alwaysCall' and 'noIgnore'.
2020-08-23 16:27:22 +02:00
Valentin Lorentz
0284ed9ebd irclib: Don't error when 004 is missing umodes and chanmodes. 2020-07-05 19:45:08 +02:00
Valentin Lorentz
6c4a8edb9c irclib: Ignore 'sts' in case of missing keys instead of aborting the connection.
In case https://github.com/ircv3/ircv3-specifications/pull/390 gets adopted.
2020-06-20 20:15:28 +02:00
Valentin Lorentz
568b84847b irclib: Fix hang in cap nego when echo-message is available but not labeled-response.
echo-message ended up in self.state.capabilities_req even though it wasn't
requested, so the bot was stuck in state:
"Waiting for ACK/NAK of capabilities: {'echo-message'}".
2020-05-18 20:50:14 +02:00
Valentin Lorentz
e9a8826805 irclib: catch exception when calling callback.reset()
We don't want the Irc driver to hang when a plugin crashes
in this function.
2020-05-17 12:46:01 +02:00
Valentin Lorentz
759fca5eba Switch names of TimeoutDict and ExpiringDict.
For consistency, as TimeoutQueue has guaranteed deletion after the timeout,
like the new TimeoutDict (ex-ExpiringDict).
2020-05-10 08:42:25 +02:00
Valentin Lorentz
eb1e27e20b Add echo messages, either with the echo-message capability or simulated.
Plugin can opt in to getting echo messages by setting the class attribute
'echo_message = True' if they want to get echos.
This defaults to False in order not to break existing plugins, and because
they usually don't need it (there's outFilter for most cases).
2020-05-07 21:08:07 +02:00
Valentin Lorentz
572c609181 Add labels to outgoing messages when labeled-response is supported.
This is going to be useful for implementing echo-message; and to plugins
targetting only networks with labeled-response support.
2020-05-07 20:56:59 +02:00
Valentin Lorentz
307a2367f4 Don't add line breaks in the middle of capability names. 2020-05-07 18:38:18 +02:00
Valentin Lorentz
fc06aa72a6 Fix parsing ISUPPORT MODES with empty value. 2020-05-07 18:38:18 +02:00
Valentin Lorentz
2008f7b815 Exclude server_tags from truncation.
They have their own 8191 bytes.
2020-05-07 18:38:17 +02:00
Valentin Lorentz
da328b4985 Expire batches that never ended to avoid leaking memory. 2020-05-06 20:39:21 +02:00
Valentin Lorentz
cc0af4e790 Include start and end messages in a batch.
They may have useful server tags (especially when we start
supporting labeled-response).
2020-05-06 18:29:17 +02:00
Valentin Lorentz
a58c994954 Negotiate the 'setname' capability.
We don't store the name anywhere, but it can be useful to plugins.
2020-05-05 19:56:24 +02:00
Valentin Lorentz
309fc1233b Add postTransition method to IrcCallback, called when irc.state.fsm changes. 2020-05-01 20:19:53 +02:00
Valentin Lorentz
f7130f2629 Add missing transition trigger on MOTD start. 2020-05-01 20:19:00 +02:00