Commit graph

247 commits

Author SHA1 Message Date
Simon Ser 78d9a84a6f Add support for RPL_VISIBLEHOST 2022-03-21 16:09:45 +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
Simon Ser fdf9727600 Mark BouncerServ as online in MONITOR, don't forward to upstream 2022-03-08 21:29:04 +01:00
Simon Ser 9a79c66921 upstream: use network case-mapping in updateMonitor
We were using the downstream case-mapping.
2022-03-08 21:27:43 +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
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
Simon Ser b1a83529e1 Fix flags variable name in RPL_WHOREPLY handler
This param doesn't contain modes, it contains user flags (such as
H/G for away status).
2022-02-09 15:20:32 +01:00
Simon Ser e72c896bb4 Add context to upstreamConn.register 2022-02-08 16:38:34 +01:00
Simon Ser 375ac53f74 Add context to upstreamConn.runUntilRegistered 2022-02-08 16:37:31 +01:00
Simon Ser de7d1f7784 Add context to upstreamConn.handleCapAck 2021-12-10 12:28:16 +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 e397cc2a1f Block RPL_{CREATIONTIME,TOPICWHOTIME} for detached channels
Closes: https://todo.sr.ht/~emersion/soju/132
2021-12-09 12:12:20 +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 b6c47a517c Use more descriptive errors when aborting pending commands 2021-12-06 22:33:50 +01:00
Simon Ser d7f7e351af Improve msgStore.Append log message wording 2021-12-06 18:46:10 +01:00
Simon Ser f881a42b4b Stop incrementing hopcount in RPL_WHOREPLY
It's extra code for something clients should ignore because it's
unreliable and useless.
2021-12-06 18:08:53 +01:00
Simon Ser 548b1c6930 Read nickname from RPL_WELCOME
References: https://github.com/ircdocs/modern-irc/pull/146
2021-12-06 17:58:54 +01:00
Simon Ser 1c285a1b72 Fallback to alt nick
If the nickname we want is taken, fallback to another one by
appending underscores. Use MONITOR to figure out when we can request
our desired nick again.

Closes: https://todo.sr.ht/~emersion/soju/35
2021-12-04 20:07:23 +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
Simon Ser 04b0c2fd6b Add context to upstreamConn.handleMessage 2021-12-02 23:27:12 +01:00
Simon Ser a413681253 Cancel pending commands on downstream disconnect
If a client queues a high number of commands and then disconnects,
remove all of the pending commands. This avoids unnecessarily
sending commands whose results won't be used.
2021-12-02 19:29:44 +01:00
Simon Ser 1620344f0a Mark ACCOUNT_REQUIRED error as permanent connection failure
There's no point in retrying to connect in this case.
2021-12-02 17:58:56 +01:00
Simon Ser fd9a935f3e Don't retry connecting on permanent failure
Closes: https://todo.sr.ht/~emersion/soju/164
2021-12-02 17:33:11 +01:00
Simon Ser 73287f242e Add context to connectToUpstream 2021-12-02 10:53:43 +01:00
Simon Ser 23fd727618 Add support for draft/account-registration proxying
This adds support for the draft/account-registration extension [1].
This allows downstreams to register on upstream networks.

[1]: https://ircv3.net/specs/extensions/account-registration
2021-11-30 12:02:54 +01:00
Simon Ser e3d7c33bcd Remove sasl cap after registration if network doesn't support it
This will stop clients from trying to issue AUTHENTICATE requests
after connection registration.
2021-11-21 16:28:38 +01:00
Simon Ser 313c6e7f97 Add support for post-connection-registration upstream SASL auth
Once the downstream connection has logged in with their bouncer
credentials, allow them to issue more SASL auths which will be
redirected to the upstream network. This allows downstream clients
to provide UIs to login to transparently login to upstream networks.
2021-11-21 16:10:54 +01:00
Simon Ser c2a5461cb8 Use RPL_LOGGEDIN/OUT to mirror upstream status
This will allow clients to properly show/hide UI to login and
register.
2021-11-19 19:21:48 +01:00
Simon Ser c6f5508765 Add missing account-notify to permanentUpstreamCaps 2021-11-19 11:55:22 +01:00
Simon Ser 5a5c93a756 Add message counter metrics 2021-11-17 15:58:19 +01:00
Simon Ser 55840312b4 Add per-user IP addresses
The new upstream-user-ip directive allows bouncer operators to
assign one IP address per user.
2021-11-17 15:07:58 +01:00
delthas 840d142f1c Add support for draft/extended-monitor
References: https://github.com/ircv3/ircv3-specifications/pull/466
2021-11-15 14:38:19 +01:00
Simon Ser 5d46dd72a4 Add support for MONITOR
Add support for MONITOR in single-upstream mode.

Each downstream has its own set of monitored targets. These sets
are merged together to compute the MONITOR commands to send to
upstream.

Each upstream has a set of monitored targets accepted by the server
alongside with their status (online/offline). This is used to
directly send replies to downstreams adding a target another
downstream has already added, and send MONITOR S[TATUS] replies.

Co-authored-by: delthas <delthas@dille.cc>
2021-11-15 14:34:04 +01:00
Simon Ser 0b6ff2e61a Add a queue for WHO commands
This has the following upsides:

- We can now routes WHO replies to the correct client, without
  broadcasting them to everybody.
- We are less likely to hit server rate limits when multiple downstreams
  are issuing WHO commands at the same time.
2021-11-09 22:09:17 +01:00
Simon Ser 0c360d24c5 Remove support for mixed multi-upstream LIST
Multi-upstream connections can still send LIST commands with a
network suffix.
2021-11-09 21:32:26 +01:00
Simon Ser 659083c781 Fix upstream USER command when both username and nick are empty 2021-11-07 18:33:59 +01:00
Simon Ser 2b4f0a870f msgstore: take Network as arg instead of network
The message stores don't need to access the internal network
struct, they just need network metadata such as ID and name.

This can ease moving message stores into a separate package in the
future.
2021-11-03 16:37:01 +01:00
Simon Ser a6aa7f0008 Make Network.Nick optional
Make Network.Nick optional, default to the user's username. This
will allow adding a global setting to set the nickname in the
future, just like we have for the real name.

References: https://todo.sr.ht/~emersion/soju/110
2021-11-02 23:33:17 +01:00
Simon Ser 241e27b00e Add support for WHOX
This adds support for WHOX, without bothering about flags and mask2
because Solanum and Ergo [1] don't support it either.

The motivation is to allow clients to reliably query account names.

It's not possible to use WHOX tokens to route replies to the right
client, because RPL_ENDOFWHO doesn't contain it.

[1]: https://github.com/ergochat/ergo/pull/1184

Closes: https://todo.sr.ht/~emersion/soju/135
2021-11-02 18:25:43 +01:00
Simon Ser aa407a46e6 Get rid of io.EOF errors in logs
Closes: https://todo.sr.ht/~emersion/soju/150
2021-10-29 16:03:04 +02:00
Simon Ser 9ec1f1a5b0 Add context args to Database interface
This is a mecanical change, which just lifts up the context.TODO()
calls from inside the DB implementations to the callers.

Future work involves properly wiring up the contexts when it makes
sense.
2021-10-18 19:15:15 +02:00
Simon Ser 324d0fb0ac Unify away-notify and account-notify handling 2021-10-17 21:54:18 +02:00
Simon Ser 455fef2421 Add support for account-notify 2021-10-17 21:54:18 +02:00
Simon Ser a14f646135 Add per-user realname setting
This allows users to set a default realname used if the per-network
realname isn't set.

A new "user update" command is introduced and can be extended to edit
other user properties and other users in the future.
2021-06-25 20:33:13 +02:00
Simon Ser d7b1c5a9a2 Allow admins to broadcast message to all bouncer users
Typically done via:

    /notice $<bouncer> <message>

Or, for a connection not bound to a specific network:

    /notice $* <message>

The message is broadcast as BouncerServ, because that's the only
user that can be trusted to belong to the bouncer by users. Any
other prefix would conflict with the upstream network.
2021-06-23 19:23:09 +02:00
Simon Ser fb50d70b70 Forward LUSERS and STATS messages after initial registration 2021-06-23 11:45:14 +02:00
Simon Ser b609b86f97 Add support for account-tag 2021-06-14 21:44:38 +02:00
Gregory Anders 0e9ef1f97c Forward user mode changes in single-upstream mode
References: https://todo.sr.ht/~emersion/soju/20
2021-06-10 11:17:00 +02:00
Gregory Anders 2fe0a57e43 Forward MOTD messages downstream
The first MOTD upon connection is ignored, but subsequent MOTD messages
(requested by the "MOTD" message from the client, typically using a
/motd command) are forwarded.
2021-06-09 21:29:36 +02:00