334 Commits

Author SHA1 Message Date
contact
0327068bdd 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@789 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-03-03 07:35:34 +00:00
contact
488107b3d4 downstream: panic when registering twice
This would be a soju bug.

git-svn-id: file:///srv/svn/repo/suika/trunk@788 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-03-03 07:33:10 +00:00
contact
3dbc059a7b Introduce formatServerTime
It's too easy to forget to convert to UTC.

git-svn-id: file:///srv/svn/repo/suika/trunk@784 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-16 13:45:09 +00:00
contact
37cc949032 Ignore READ commands for service
git-svn-id: file:///srv/svn/repo/suika/trunk@783 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-12 18:07:30 +00:00
delthas
9b1a5bd469 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@781 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-11 18:41:46 +00:00
delthas
81e4b057c5 Fix echo-message for TAGMSG
A previous fix (d4b7bb02da1c) 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

git-svn-id: file:///srv/svn/repo/suika/trunk@780 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-09 15:58:54 +00:00
contact
6cbc9f985a Drop user.forEachNetwork
It's a trivial for loop.

git-svn-id: file:///srv/svn/repo/suika/trunk@768 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-04 13:01:27 +00:00
contact
6de32aea34 Handle upstream multi-line SASL
References: https://todo.sr.ht/~emersion/soju/173

git-svn-id: file:///srv/svn/repo/suika/trunk@761 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-10 09:46:41 +00:00
contact
28994d6bde Add support for downstream multi-line AUTHENTICATE commands
Useful for long passwords.

git-svn-id: file:///srv/svn/repo/suika/trunk@760 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-09 22:21:08 +00:00
contact
8a03d66c9f Don't forward duplicate JOIN commands
Closes: https://todo.sr.ht/~emersion/soju/171

git-svn-id: file:///srv/svn/repo/suika/trunk@758 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-08 17:23:46 +00:00
contact
d5a071dd91 Add context to {conn,upstreamConn}.SendMessage
This avoids blocking on upstream message rate limiting for too
long.

git-svn-id: file:///srv/svn/repo/suika/trunk@757 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-08 17:03:40 +00:00
contact
6487d245a4 Use dc.nick instead of "*" for RPL_* messages
Makes it clearer what these fields are used for. The default value
for dc.nick is "*".

git-svn-id: file:///srv/svn/repo/suika/trunk@754 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-07 08:42:32 +00:00
contact
9a91517fc5 Improve error message when downstream doesn't authenticate
git-svn-id: file:///srv/svn/repo/suika/trunk@753 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-07 08:40:02 +00:00
contact
2a56c11036 Disallow ',' in nicknames
It breaks lists as in `PRIVMSG a,b,c :foo`.

git-svn-id: file:///srv/svn/repo/suika/trunk@751 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 18:23:28 +00:00
contact
c1b86bbf9c Add username to downstreamConn log messages
git-svn-id: file:///srv/svn/repo/suika/trunk@750 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:56:00 +00:00
contact
da3d8aaa8c 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@742 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-04 18:29:39 +00:00
contact
f60544b6f8 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

git-svn-id: file:///srv/svn/repo/suika/trunk@729 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-30 11:02:54 +00:00
contact
501daacf2f downstream: improve unmarshalEntityNetwork error message
Closes: https://todo.sr.ht/~emersion/soju/162

git-svn-id: file:///srv/svn/repo/suika/trunk@727 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-29 15:41:52 +00:00
contact
14fe903059 Return more descriptive auth failure errors
git-svn-id: file:///srv/svn/repo/suika/trunk@726 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-29 12:14:16 +00:00
contact
d8ef203c84 Remove sasl cap after registration if network doesn't support it
This will stop clients from trying to issue AUTHENTICATE requests
after connection registration.

git-svn-id: file:///srv/svn/repo/suika/trunk@725 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-21 15:28:38 +00:00
contact
756a37c778 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@724 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-21 15:10:54 +00:00
contact
27bc8188ff Send RPL_LOGGEDIN with bouncer account in multi-upstream mode
git-svn-id: file:///srv/svn/repo/suika/trunk@723 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-21 10:00:57 +00:00
contact
c9c288b749 Use RPL_LOGGEDIN/OUT to mirror upstream status
This will allow clients to properly show/hide UI to login and
register.

git-svn-id: file:///srv/svn/repo/suika/trunk@722 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-19 18:21:48 +00:00
contact
8d130a9d92 Abort SASL if in-progress while completing registration
Implements the following recommendation from the spec:

> If the client completes registration (with CAP END, NICK, USER and any other
> necessary messages) while the SASL authentication is still in progress, the
> server SHOULD abort it and send a 906 numeric, then register the client
> without authentication.

git-svn-id: file:///srv/svn/repo/suika/trunk@721 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-19 17:55:07 +00:00
contact
292ad7748c Add missing account-notify to permanentUpstreamCaps
git-svn-id: file:///srv/svn/repo/suika/trunk@720 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-19 10:55:22 +00:00
tomvig38
4b4d3d4543 Add CHATHISTORY LATEST support
This patch adds a bit more compliance to the chathistory IRCv3 specification.

git-svn-id: file:///srv/svn/repo/suika/trunk@719 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-18 20:06:26 +00:00
contact
6dde2649b6 Disallow empty string for nick
git-svn-id: file:///srv/svn/repo/suika/trunk@717 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-18 08:44:33 +00:00
hubert
bb7b240a5b Allow AUTHENTICATE before NICK
Now that dc.nick is not blank during registration, sasl replies from the
server are correct and cap handling can be a bit simplified.

git-svn-id: file:///srv/svn/repo/suika/trunk@716 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-18 08:40:23 +00:00
contact
ca58716f6c Add message counter metrics
git-svn-id: file:///srv/svn/repo/suika/trunk@711 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +00:00
contact
99b503c800 Update downstream caps/nick/realname before sending MOTD
The MOTD indicates the end of the registration's message burst, and
the server can send arbitrary messages before it.

Update the supported capabilities, the nick and the realname before
MOTD to make it so client logic that runs on MOTD can work with
up-to-date info.

git-svn-id: file:///srv/svn/repo/suika/trunk@706 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:27:34 +00:00
contact
56e1247cf4 Add timeout for downstream connection registration
git-svn-id: file:///srv/svn/repo/suika/trunk@704 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 13:54:03 +00:00
contact
896462a4b0 Introduce conn.NewContext
This function wraps a parent context, and returns a new context
cancelled when the connection is closed. This will make it so
operations started from downstreamConn.handleMessage will be
cancelled when the connection is closed.

git-svn-id: file:///srv/svn/repo/suika/trunk@703 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 12:13:55 +00:00
contact
e7502fa150 Lift up context to downstreamConn.handleMessage
git-svn-id: file:///srv/svn/repo/suika/trunk@702 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:38:08 +00:00
contact
c4dc482d71 Add context arg to downstreamConn.welcome()
git-svn-id: file:///srv/svn/repo/suika/trunk@701 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:33:30 +00:00
contact
aa4b02c1bb Add context to downstreamConn.handleMessageUnregistered
git-svn-id: file:///srv/svn/repo/suika/trunk@700 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:29:23 +00:00
contact
c07a0ddcbe Lower sanityCheckServer timeout to 15s
Should still be more than enough to connect even if the network is
somewhat flaky.

git-svn-id: file:///srv/svn/repo/suika/trunk@699 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:12:40 +00:00
contact
e88bc359cf Add context arg to sanityCheckServer
As a bonus, the timeout now applies to the whole TLS dial
operation. Before the timeout only applied to the net dial
operation, making it possible for a bad server to stall the request
by making the TLS handshake extremely slow.

git-svn-id: file:///srv/svn/repo/suika/trunk@698 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:10:56 +00:00
contact
d473fb1a5d Add config option to globally disable multi-upstream mode
Closes: https://todo.sr.ht/~emersion/soju/122

git-svn-id: file:///srv/svn/repo/suika/trunk@694 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 10:41:11 +00:00
contact
729d41ba86 Set isMultiUpstream flag in downstreamConn.welcome()
This will make it easier to globally disable multi-upstream mode.

git-svn-id: file:///srv/svn/repo/suika/trunk@693 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 10:22:26 +00:00
contact
e76b51543f Add downstreamConn.isMultiUpstream
git-svn-id: file:///srv/svn/repo/suika/trunk@692 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 10:17:09 +00:00
contact
8f1a6e4432 Allow most config options to be reloaded
Closes: https://todo.sr.ht/~emersion/soju/42

git-svn-id: file:///srv/svn/repo/suika/trunk@691 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 23:38:04 +00:00
contact
132ca8f555 Don't send user in prefix for echo messages
This is not very useful and confuses clients.

git-svn-id: file:///srv/svn/repo/suika/trunk@690 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 22:53:25 +00:00
delthas
d90513bee4 Return an empty CHATHISTORY TARGETS batch when in multi-upstream
When on an unbound bouncer network downstream, we should return no
targets (there are none, because there are no upstreams at all).

When on a multi-upstream downstream, we should return no targets as we
don't support multi-upstream CHATHISTORY TARGETS.

Before this patch, we returned a misleading error message:
:example.com 403 :Missing network suffix in name

git-svn-id: file:///srv/svn/repo/suika/trunk@688 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 20:30:04 +00:00
delthas
a056e2f696 Send the downstream host for PRIVMSG echo messages
If a downstream of prefix host `foo` sends a message, the other
downstream of prefix host `bar` should receive an echo PRIVMSG with
prefix host bar.

This fixes a regression where no prefix host was sent at all.

git-svn-id: file:///srv/svn/repo/suika/trunk@686 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 16:45:23 +00:00
delthas
14e0806745 Add support for draft/extended-monitor
References: https://github.com/ircv3/ircv3-specifications/pull/466

git-svn-id: file:///srv/svn/repo/suika/trunk@685 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 13:38:19 +00:00
contact
5bb767bf62 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>

git-svn-id: file:///srv/svn/repo/suika/trunk@684 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 13:34:04 +00:00
contact
c4562a004e 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

git-svn-id: file:///srv/svn/repo/suika/trunk@683 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-09 21:12:46 +00:00
contact
54c906a82c 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@682 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-09 21:09:17 +00:00
contact
c652cb0188 Remove support for mixed multi-upstream LIST
Multi-upstream connections can still send LIST commands with a
network suffix.

git-svn-id: file:///srv/svn/repo/suika/trunk@681 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-09 20:32:26 +00:00
contact
a3ca35f09e Add context support to service
References: https://todo.sr.ht/~emersion/soju/141

git-svn-id: file:///srv/svn/repo/suika/trunk@677 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-08 18:40:48 +00:00