Commit Graph

289 Commits

Author SHA1 Message Date
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
f920f27e02 Add ELIST support in single-upstream mode
We just forward the command as-is, so we can pass down the ISUPPORT
token as well.

Closes: https://todo.sr.ht/~emersion/soju/148
2021-11-09 22:12:46 +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
802e82c272 Add context support to service
References: https://todo.sr.ht/~emersion/soju/141
2021-11-08 19:40:48 +01:00
Simon Ser
c21202160c Add context support to user and network mutations
References: https://todo.sr.ht/~emersion/soju/141
2021-11-08 19:36:10 +01:00
Simon Ser
8b3e5e7465 Plumb context in downstreamConn.handleMessageRegistered
References: https://todo.sr.ht/~emersion/soju/141
2021-11-08 18:11:24 +01:00
Simon Ser
c2047dc1a8 Add plus sign in RPL_UMODEIS reply 2021-11-03 22:02:19 +01:00
Simon Ser
26cdb0d328 Set mode +o on admins for bouncer-only connections 2021-11-03 21:42:42 +01:00
Simon Ser
abe5f362db Turn CHATHISTORY and backlog limits into constants 2021-11-03 18:29:21 +01:00
Simon Ser
ce69f00e3f msgstore: add context to messageStore methods
This allows setting a hard timeout.
2021-11-03 18:21:05 +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
delthas
03f8972305 Add support for draft/event-playback 2021-11-03 15:17:16 +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
07c962018d Add title config option
Closes: https://todo.sr.ht/~emersion/soju/146
2021-11-02 22:38:07 +01:00
Simon Ser
832d8b89a2 Mark bouncer users and BouncerServ as authenticated in WHOX/WHOIS 2021-11-02 18:32:39 +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
8c7c907d6f Fix operator flag in RPL_WHOREPLY
@ and + indicate channel privileges. * indicates that the user is
a server operator.
2021-11-01 18:36:21 +01:00
Simon Ser
62d92c660f Mark admins as server operators in self WHO/WHOIS replies 2021-11-01 18:32:01 +01:00
Simon Ser
3ab8ef17df Mark BouncerServ as server operator
That's what some widely used IRC servers do for their own services
(e.g. NickServ and ChanServ). This adds an additional level of
trust to make sure BouncerServ isn't typo'ed or impersonated.
2021-11-01 18:28:19 +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
0cd18a78db Unify BOUNCER ADDNETWORK and CHANGENETWORK 2021-10-29 15:51:13 +02:00
Simon Ser
de38d93085 Always reply ERR_SASLABORTED on SASL abort
Some clients (Hexchat) always expect AUTHENTICATE * to succeed with
ERR_SASLABORTED even if SASL hasn't been started.
2021-10-28 11:29:34 +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
4be6c4b19c Remove unnecessary downstream cap checks
downstreamConn.SendMessage already performs this cap checking.
2021-10-18 09:20:11 +02:00
Simon Ser
1507e88b36 Remove incorrect AWAY TODO in downstreamConn.SendMessage
PRIVMSG/NOTICE get RPL_AWAY, not AWAY.
2021-10-18 09:08:52 +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
2f495e9768 Remove unused REGISTRATION_IS_COMPLETED in handleMessageUnregistered
downstreamConn.handleMessageUnregistered is only called when the
user isn't registered.
2021-10-16 11:42:32 +02:00
Simon Ser
ade59beb8c Send BOUNCER REGISTRATION_IS_COMPLETED error 2021-10-16 11:41:37 +02:00
Alexey Yerin
3109340651 downstream: handle name=... in BOUNCER 2021-10-14 16:03:14 +02:00
Simon Ser
a9a066faac Add bouncer MOTD
Closes: https://todo.sr.ht/~emersion/soju/137
2021-10-13 10:58:34 +02:00
Simon Ser
e55d0d7552 Stop sending RPL_CREATED
There's no point in sending this numeric if it doesn't contain any
useful info.
2021-10-12 19:28:44 +02:00
Simon Ser
6e8b6fa153 Fix printf formatting in error message 2021-10-12 17:36:00 +02:00
Hubert Hirtz
3a171607e0 Correctly send back PRIVMSGs and NOTICEs to self 2021-10-10 12:05:41 +02:00
Hubert Hirtz
d4b7bb02da Send back TAGMSGs to self 2021-10-10 12:05:41 +02:00
Hubert Hirtz
0fd81f38fa Dismiss TAGMSGs directed to BouncerServ 2021-10-10 12:05:40 +02:00
Simon Ser
1d56ef19e7 Add WHOIS reply for BouncerServ 2021-10-06 11:50:12 +02:00
Hubert Hirtz
2554c92df7 Allow CAP negotiation to happen with CAP REQ
See https://ircv3.net/specs/extensions/capability-negotiation

> Upon receiving either a CAP LS or CAP REQ command during connection
> registration, the server MUST not complete registration until the
> client sends a CAP END command to indicate that capability negotiation
> has ended.

This commit should prevent soju from trying to authenticate the user
prior to having received AUTHENTICATE messages, when the client eagerly
requests capabilities with CAP REQ seeing available capabilities
beforehand with CAP LS.
2021-09-19 16:50:47 +02:00
Simon Ser
0f2f4de275 Send empty history for service
Fixes error when fetching chat history for BouncerServ.
2021-09-13 11:36:25 +02:00
Simon Ser
fba1fdb31e Don't require upstream to be connected for CHATHISTORY
Closes: https://todo.sr.ht/~emersion/soju/127
2021-09-13 11:25:38 +02:00
Simon Ser
cd64a7ffda Split unmarshalEntity into two functions
Some command handlers need to unmarshal without requiring the
upstream to be connected.
2021-09-13 11:14:47 +02:00
Simon Ser
c5d5259243 Pass-through CLIENTTAGDENY in ISUPPORT 2021-07-09 22:48:58 +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
f3f864dddc Disallow '$' in nicks 2021-06-23 19:54:22 +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
eca4c41223 Unify downstream PRIVMSG and NOTICE handling
We were doing some things wrong here, e.g. not sending echo messages
for NOTICE.
2021-06-23 18:17:30 +02:00
Simon Ser
faa89333bf Add support for utf8-only 2021-06-15 15:48:10 +02:00
Simon Ser
b609b86f97 Add support for account-tag 2021-06-14 21:44:38 +02:00
Simon Ser
0557ca5871 Don't suggest users to /motd in multi-upstream mode 2021-06-10 12:16:33 +02:00