Commit Graph

368 Commits

Author SHA1 Message Date
Simon Ser
846c99dedc Queue WHOIS commands
This avoids having more than one in flight at a time (avoids
hitting rate limits a bit) and routes back replies to the correct
downstream connection (even if labeled-response isn't supported).

Closes: https://todo.sr.ht/~emersion/soju/193
2022-04-04 09:58:26 +02:00
Simon Ser
303c663d02 Refuse to change nick on bouncer connection
Also simplify the code.

Closes: https://todo.sr.ht/~emersion/soju/192
2022-04-01 14:55:36 +02:00
Simon Ser
29b1e6f47b downstream: update user realname on SETNAME 2022-03-30 17:51:04 +02:00
Simon Ser
d7b5f5d12c downstream: set realname for network-less connections
Send the user-wide realname config. We still need to handle SETNAME
properly.
2022-03-30 14:17:09 +02:00
Simon Ser
0ec3e63ace downstream: send RPL_ENDOFWHO on unmarshalEntity error
Also remove a couple of outdated comments.
2022-03-23 19:15:52 +01:00
Simon Ser
44efe37292 downstream: clarify "user not active" error message 2022-03-23 13:11:37 +01:00
Simon Ser
43371bf347 Add the soju.im/no-implicit-names extension
References: https://github.com/ircv3/ircv3-ideas/issues/87
2022-03-22 21:03:20 +01:00
Simon Ser
128aefcc50 downstream: strip back "*" prefix 2022-03-21 17:16:02 +01:00
Simon Ser
8e4c8f7e5a downstream: copy message when degrading extended-join
Otherwise we mutate the input argument and loops over downstream
connections to send messages will be messed up.
2022-03-21 17:13:55 +01:00
Simon Ser
883683c0b7 downstream: always populate downstreamConn.username
This ensures we don't send a prefix without a username in it.
2022-03-21 16:37:04 +01:00
Simon Ser
069625d30d downstream: rejigger hostname logic in newDOwnstreamConn
I find it easier to read this way.
2022-03-21 16:33:58 +01:00
Simon Ser
e403b88a3d Add support for chghost 2022-03-21 16:30:58 +01:00
Simon Ser
78d9a84a6f Add support for RPL_VISIBLEHOST 2022-03-21 16:09:45 +01:00
Simon Ser
b0dbb3cef1 downstream: explain when downstreamConn.sasl is nil 2022-03-21 15:11:43 +01:00
Simon Ser
70ba7032f1 downstream: move negotiatingCaps to downstreamRegistration
This field is only relevant during connection registration.
2022-03-21 15:09:31 +01:00
Simon Ser
884bfec6a6 downstream: improve grouping of downstreamConn fields 2022-03-21 15:08:12 +01:00
Simon Ser
b3425ba1a3 downstream: process BOUNCER BIND in downstreamConn.welcome
This allows clients to send BOUNCER BIND before SASL auth, or to
use BOUNCER BIND with PASS.
2022-03-21 15:02:54 +01:00
Simon Ser
2c691d012d downstream: reject negative or zero network IDs in parseBouncerNetID 2022-03-21 15:00:30 +01:00
Simon Ser
d9468b983f downstream: move multi-upstream name handling to loadNetwork 2022-03-21 14:54:23 +01:00
Simon Ser
bed50c10ce downstream: ignore nickname during connection registration
Just force-set the nickname and completely disregard what the client
sets during connection registration. Clients must discover their
effective nickname via RPL_WELCOME.
2022-03-21 14:54:21 +01:00
delthas
2ac9bd9c94 Require an explicit * network suffix for multi-upstream
Most users will connect to their server with `<username>` as their
username in order to configure their upstreams.

Multi-upstream can be unintuitive to them and should not be enabled on
that first connection that is usually used for upstream configuration.

Multi-upstream is instead a power-user feature that should be explicitly
enabled with a specific network suffix.

We reserve the network suffix `*` and use it a special case to mean that
it requests multi-upstream mode.
2022-03-21 09:56:20 +01:00
Simon Ser
744c6e3f6d Enable bot mode for BouncerServ
See [1] for details.

[1]: https://ircv3.net/specs/extensions/bot-mode
2022-03-16 18:35:48 +01:00
Simon Ser
777adbd5e1 downstream: improve ERR_ERRONEUSNICKNAME message a bit 2022-03-16 12:33:23 +01:00
Simon Ser
35b09f069c downstream: atomically ack/nak capabilities 2022-03-14 19:30:29 +01:00
Simon Ser
6e094b1099 Use capRegistry for upstreamConn 2022-03-14 19:25:49 +01:00
Simon Ser
74fd506fef Use capRegistry for downstreamConn 2022-03-14 19:25:49 +01:00
delthas
9376c8885c downstream: Enable handling READ when upstream is disconnected
Previously, when we sent READ for an upstream which was disconnected,
we would fail with an error. This is because we called unmarshalEntity,
which checked that the upstream was in the connected status.

But we don't need to be connected to update the READ timestamp, this is
a purely offline (wrt the upstream) operation.

This simply switches the call from unmarshalEntity to
unmarshalEntityNetwork to fix the issue.
2022-03-08 22:35:46 +01:00
Simon Ser
fdf9727600 Mark BouncerServ as online in MONITOR, don't forward to upstream 2022-03-08 21:29:04 +01:00
Simon Ser
d8f5f8481f downstream: set case-mapping for monitored 2022-03-08 21:28:43 +01:00
Simon Ser
2060ae05cf downstream: drop delivery receipts when client supports chathistory
When the client supports draft/chathistory, no need to request
delivery receipts via PING messages. Let's just not leave delivery
receipts alone. They'll go stale but should be never used (or used
by a non-chathistory client).
2022-03-08 16:45:45 +01:00
Simon Ser
a438c34489 downstream: disallow '.' in nicknames
See [1] and [2].

[1]: https://github.com/ircdocs/modern-irc/pull/148
[2]: eff6dd242b/irc/strings.go (L29)
2022-03-03 10:54:21 +01:00
Simon Ser
7b3e46a7c2 downstream: re-format illegalNickChars doc comment 2022-03-03 10:53:33 +01:00
Simon Ser
c742726316 downstream: fix network name msimatch check being too strict
The network name can be set via BOUNCER BIND. In that case we
don't want to error out when fallbackNetworkName == "".
2022-03-03 09:08:51 +01:00
Simon Ser
8421c27544 downstream: fail on client or network name mismatch
This probably indicates a mis-configuration.
2022-03-03 08:50:37 +01:00
Simon Ser
348e6da1fc downstream: be less strict when picking up client name
Allow e.g. the SASL username to contain "username/network" and the
raw username to contain "username@client", for instance.
2022-03-03 08:35:34 +01:00
Simon Ser
df4af1856a downstream: panic when registering twice
This would be a soju bug.
2022-03-03 08:33:10 +01:00
Simon Ser
1a56b2f658 Introduce formatServerTime
It's too easy to forget to convert to UTC.
2022-02-16 14:45:09 +01:00
Simon Ser
155e811cd9 Ignore READ commands for service 2022-02-12 19:07:30 +01:00
delthas
cae248f672 Add support for the wip soju.im/read capability and READ command
READ lets downstream clients share information between each other about
what messages have been read by other downstreams.

Each target/entity has an optional corresponding read receipt, which is
stored as a timestamp.

- When a downstream sends:
  READ #chan timestamp=2020-01-01T01:23:45.000Z
  the read receipt for that target is set to that date
- soju sends READ to downstreams:
  - on JOIN, if the client uses the soju.im/read capability
  - when the read receipt timestamp is set by any downstream

The read receipt date is clamped by the previous receipt date and the
current time.
2022-02-11 19:41:46 +01:00
delthas
17cd3b3e98 Fix echo-message for TAGMSG
A previous fix (d4b7bb02da) only fixed sending echo-message for
TAGMSG to self. We also need to send echo-message for TAGMSG to
other targets.

Closes: https://todo.sr.ht/~emersion/soju/111
2022-02-09 16:58:54 +01:00
Simon Ser
0b5da29916 Drop user.forEachNetwork
It's a trivial for loop.
2022-02-04 14:01:27 +01:00
Simon Ser
fe564af756 Handle upstream multi-line SASL
References: https://todo.sr.ht/~emersion/soju/173
2021-12-10 10:46:41 +01:00
Simon Ser
e7f9d2332b Add support for downstream multi-line AUTHENTICATE commands
Useful for long passwords.
2021-12-09 23:21:08 +01:00
Simon Ser
bad8154da8 Don't forward duplicate JOIN commands
Closes: https://todo.sr.ht/~emersion/soju/171
2021-12-08 18:23:46 +01:00
Simon Ser
66aea1b4a2 Add context to {conn,upstreamConn}.SendMessage
This avoids blocking on upstream message rate limiting for too
long.
2021-12-08 18:03:40 +01:00
Simon Ser
f7e151396d Use dc.nick instead of "*" for RPL_* messages
Makes it clearer what these fields are used for. The default value
for dc.nick is "*".
2021-12-07 09:42:32 +01:00
Simon Ser
aae0fb9f22 Improve error message when downstream doesn't authenticate 2021-12-07 09:40:02 +01:00
Simon Ser
5c819a2c6c Disallow ',' in nicknames
It breaks lists as in `PRIVMSG a,b,c :foo`.
2021-12-06 19:23:28 +01:00
Simon Ser
1a78b3d905 Add username to downstreamConn log messages 2021-12-06 18:56:00 +01:00
Simon Ser
f2a28f6e22 Avoid forwarding MONITOR requests if upstream doesn't support it
Clients aren't supposed to do this, but in case they do, let's
send them an error.
2021-12-04 19:29:39 +01:00