Commit Graph

1613 Commits

Author SHA1 Message Date
Valentin Lorentz
009b900100 Make TimeoutQueue.iter() actually expire items
It is functionally fine not to, but causes objects to never be freed
if iter() is the only method called on the queue (ie. no
enqueue/dequeue, len(), ...)
2022-10-24 23:43:52 +02:00
Valentin Lorentz
2c5dc405fc test: Revert generic 'The Limnoria Contributors' in copyright notices
I forgot to include these in 63eb6672ea

(This is fine because noone but me touched these files since the initial
change in db7ef3f025).
2022-10-24 23:41:26 +02:00
Valentin Lorentz
47253e032e Add test for structures.TimeoutQueue.__iter__ 2022-10-24 23:21:11 +02:00
Valentin Lorentz
96b7f51e71 callbacks: Ignore chathistory batches in PluginRegexp
This is consistent with what we already do with commands; and generally
makes sense, as we don't want to re-send titles and others when cycling
on UnrealIRCd (which includes a chathistory batch when joining when
chmode +H is set, despite umode +B)
2022-07-06 22:07:37 +02:00
Valentin Lorentz
3ecb37de10 test_callbacks: Add PluginRegexpTestCase.testReply to check basic behavior 2022-07-06 22:05:30 +02:00
Valentin Lorentz
6a943b8342 test_callbacks: Fix PluginRegexpTestCase to actually check regexp callbacks 2022-07-06 22:04:33 +02:00
Valentin Lorentz
109f938b0c Implement +draft/channel-context 2022-04-22 18:30:31 +02:00
Valentin Lorentz
088d0f54dd irclib: Catch exception from outFilter, as with inFilter 2022-03-17 22:29:10 +01:00
Valentin Lorentz
78bdc469e4 htmlToText: Don't replace inline element tags with spaces
They are not meant to be displayed like this, so they look weird sometimes.
For example, Mastodon splits long links between spans, so the Fediverse plugin
always displayed them broken.
2022-02-19 21:00:51 +01:00
Valentin Lorentz
74f86654b1 Remove fallbacks for old Python versions. 2022-01-01 18:11:36 +01:00
Valentin Lorentz
ce7e4b754c Replace deprecated unittest function calls. 2021-11-08 21:29:59 +01:00
Valentin Lorentz
749b8e18ad fix test 2021-09-14 21:03:15 +02:00
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
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
747ef77106 Fix tests when pyxmpp2_scram is not installed. 2021-07-31 14:40:44 +02:00
Valentin Lorentz
ade5a02457 Fix/update SASL tests, broken by the previous commit. 2021-07-31 13:05:39 +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
e19282a2d3 Actually parse weird hostmasks like RFC1459 recommends
Thanks to @Noisytoot for pointing out the RFC actually specific them
with this:

<user>       ::= <nonwhite> { <nonwhite> }
2021-07-14 23:43:11 +02:00
Valentin Lorentz
5baf87ddba ircutils: Improve robustness when faced with invalid hostmasks
eg. @ in nicks, which happened on pissnet earlier today.
2021-07-14 23:25:11 +02:00
Valentin Lorentz
65ab65cbb1 irclib: Fix crashes when ERROR is part of a batch. 2021-06-20 23:59:51 +02:00
Clark Boylan
67a39a3adb
Fix joins to many channels (#1473)
* Fix joins to many channels

If you have enough channels that the 512 byte message limit on the JOIN
message is hit then limnoria was losing the channel that put it over the
limit and not including it in the next JOIN message. This resulted in
losing one channel for every JOIN message that pushed us over 512 bytes.

We fix this by generating the JOIN message immediately after resetting
the channels list to ensure we include the channel that pushed us over
the limit. Then the next time through our JOIN msg construction we'll
add subsequent channels without forgetting the one that pushed us over.

* Add test for channel join lists

This adds a test for the issue that is fixed in the previous commit. We
ensure that when JOINs are split over multiple messages we JOIN to all
channels that were part of the input list and don't forget any of them.
2021-06-14 23:15:43 +02:00
Valentin Lorentz
8a52902727 irclib: Fix overhead computation by using the real target computation algo 2021-06-08 21:56:08 +02:00
Valentin Lorentz
43aada5b33 Store ignored hostmasks in Expiring HostmaskSet to prevent their pattern cache from expiring too soon
See e0fdcb67c0 for the rationale
(tl;dr: prevents triggering a degenerate case of the LRU cache when
there are over 1000 ignore masks)
2021-05-30 19:35:05 +02:00
Valentin Lorentz
86b1741fdd Fix nondeterministic test on Python < 3.7. 2021-05-27 22:36:27 +02:00
Valentin Lorentz
e0fdcb67c0 Store IrcUser hostmasks in HostmaskSet to prevent their pattern cache from expiring
When the number of hostmasks exceeds 1000 (the hardcoded size of
_patternCache and _hostmaskPatternEqualCache), this triggers
a pathological case in the LRU caches, that causes all calls to be
a cache miss.
This means that on every IRC message received, ircdb.checkIgnored triggers
a recompilation of *all* user hostmasks, which is very expensive
computationally.

This commit stores them in their own cache to prevent them from
expiring.
2021-05-27 22:15:52 +02:00
Valentin Lorentz
d452a7051c callbacks: Don't write nick prefixes in the middle of multiline messages. 2021-04-01 20:10:17 +02:00
Valentin Lorentz
bbc2e9de0d irclib: 'lift' message tags to the batch when sending a multiline batch 2021-04-01 20:10:17 +02:00
Valentin Lorentz
bf90a7c94d callbacks: Make reply() send multiline batches when supybot.reply.mores.instant > 1 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
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
11e79e44c5 Remove the '(XX more messages)' when the next message is sent immediately after
It's pointless and looks stupid.

It will look even more stupid when we enable multiline, because the
suffixes will be in the middle of the concatenated message.
2021-03-05 21:19:02 +01:00
Valentin Lorentz
f98542e884 Add testReplyInstant
I'm going to mess with instant replies to add support for multiline,
so it's good to have a safety net.
2021-03-05 21:11:43 +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
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
f4d6bd11be registry: forbid direct access to Regexp.setValue.
This is not a regression; this was already forbidden before
23417b0675, and this commit was not
tagged/released yet at the moment I'm writing this one.
2020-09-15 09:59:08 +02:00
Valentin Lorentz
ac94c5291e registry: fix Regexp initialization when the default value is not None. 2020-09-15 09:57:15 +02:00
Valentin Lorentz
23417b0675 registry: Fix regression preventing default None value for Regexp. 2020-09-05 22:20:38 +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
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
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
d205a9b5f8 Fediverse: Use ExpiringDict instead of TimeoutDict for the cache, it guarantees expiry after the timeout. 2020-05-10 08:34:36 +02:00
Valentin Lorentz
43a8724d3a Don't strip spaces when parsing registry values.
It breaks plugins.Messageparser.listSeparator, and probably others.
2020-05-08 22:18:27 +02:00
Valentin Lorentz
0d89b2352b Add plugin load case-insensitivity test. 2020-05-08 11:58:12 +02:00
Valentin Lorentz
83a8afde16 Add experimental support for +draft/reply client capability on outgoing messages. 2020-05-07 21:17:55 +02:00