Commit Graph

419 Commits

Author SHA1 Message Date
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
Valentin Lorentz
22120ee862 Fix various issues with STS handling. 2020-05-01 19:46:19 +02:00
Valentin Lorentz
51ff013fcc Apply STS policies when connecting to a server. 2020-05-01 19:46:19 +02:00
Valentin Lorentz
ecc2c32950 Add support for storing STS policies.
If on an insecure connection: reconnect.
If on a secure connect: store it and do nothing else.

For now, stored STS policies are not read when connecting to an
insecure server.
2020-05-01 19:46:19 +02:00
Valentin Lorentz
45ff70907f [WIP] Start reworking Irc around a FSM.
To keep track of connection state instead of a complex implicit flow
between handling functions.
2020-05-01 19:43:27 +02:00
Valentin Lorentz
e7553dcca4 Add subcommand dispatching for CAP/FAIL/WARN/NOTE. 2020-01-23 14:25:10 +01:00
Valentin Lorentz
c4d073a9be Rename doAuthenticate* functions to not conflict with callback names. 2020-01-23 14:24:41 +01:00
Valentin Lorentz
ac07b440dc Rewrite ecdsa-nist256p-challenge using python-cryptography instead of python-ecdsa.
Which is more secure. Closes GH-1389.

It also fixes the protocol/format to use the same one as Atheme.
See also: 8a81224ba8
2020-01-01 12:07:59 +01:00
Valentin Lorentz
1ed47f802f Request msgid capability. 2019-12-05 21:11:35 +01:00
Valentin Lorentz
2dddfefa98 Fix log on SASL failure.
Broken by 04b55805b8.
2019-11-09 18:38:40 +01:00
Valentin Lorentz
6a9462be00 Fix reset of capabilities_ls.
Broken by 0014b206ad.
2019-11-09 18:27:07 +01:00
Valentin Lorentz
04b55805b8 Log SASL mechanism on failure. Closes GH-1014. 2019-11-02 20:52:58 +01:00
Valentin Lorentz
9268356e97 Split 'CAP REQ' commands to not exceed 512 bytes. 2019-10-25 23:07:31 +02:00
Valentin Lorentz
0014b206ad Reset capability set state on reconnection. 2019-10-25 22:40:51 +02:00
Valentin Lorentz
cfbbed3da9 Truncate incoming lines to 512-2, not 500. 2019-10-25 22:31:09 +02:00
Valentin Lorentz
84c1f1572d Don't temporarily set msg.channel to invalid values.
This causes issue when multiple command threads deal with the same message.
2019-09-20 21:25:32 +02:00
Valentin Lorentz
c1ae3f5c81 all plugins: Use msg.channel instead of msg.args[0] + give network name to self.registryValue. 2019-08-24 23:35:01 +02:00
Valentin Lorentz
8bb31a54e7 Strip statusmsg chars in core to determine the actual channel.
Use msg.channel if relevant, otherwise strip them locally.
2019-08-24 14:52:59 +02:00
Valentin Lorentz
5b40b5136d Limit statusmsg prefix stripping to PRIVMSG and NOTICE. 2019-08-18 10:09:11 +02:00
Valentin Lorentz
7a7cdb9f05 Add a 'channel' attribute to IrcMsg objects.
It's nicer to use 'irc.channel' instead of 'irc.args[0]', and .channel
provides the actual channel name (stripped of the statusmsg prefix),
so it can be used by plugins when they want to use the actual channel
name.
2019-08-17 22:23:51 +02:00
Valentin Lorentz
696254ff1b Use irc.isChannel instead of ircutils.isChannel when possible.
It's aware of the network's 'chantypes'.
2019-08-04 21:52:40 +02:00
Valentin Lorentz
76699ec063 Add support for 'message-tags' capability, to receive TAGMSGs. 2019-05-08 21:19:53 +02:00
Valentin Lorentz
624553c069 irclib: Don't return the same nick twice when duplicates in supybot.nick.alternates + supybot.nick.
It migt crash on: 'assert newNick != self.nick'
2019-01-27 09:10:06 +01:00
Valentin Lorentz
c433f05190 Add a config var to require SASL auth when connecting. 2018-09-10 22:48:49 +02:00
Valentin Lorentz
7e98802809 Drop STARTTLS support, it complicates the connection initialization too much. 2018-01-24 09:27:39 +01:00