129 Commits

Author SHA1 Message Date
koizumi.aoi
cd99ccc1de Drunk as I like
Signed-off-by: Aoi K <koizumi.aoi@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/suika/trunk@804 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2023-03-21 04:45:19 +00:00
contact
cd5d76be0e msgstore_fs: fix direct message targets
When fetching messages via draft/chathistory from a conversation
with another user, soju would send the following:

    :sender PRIVMSG sender :hey

instead of

    :sender PRIVMSG recipient :hey

because the file-system message store format doesn't contain the
original PRIVMSG target.

Fix this by doing some guesswork.

git-svn-id: file:///srv/svn/repo/suika/trunk@787 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-25 20:05:10 +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
contact
bef2bfad2b Add context to upstreamConn.register
git-svn-id: file:///srv/svn/repo/suika/trunk@777 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-08 15:38:34 +00:00
contact
6f8aa7f95a Add context to upstreamConn.runUntilRegistered
git-svn-id: file:///srv/svn/repo/suika/trunk@776 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-08 15:37:31 +00:00
contact
f1b4a2bc79 Forbid empty and flag-looking network names
git-svn-id: file:///srv/svn/repo/suika/trunk@773 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-07 20:39:39 +00:00
contact
259caf4a78 Ensure consistent network ordering
Right now there is no consistent ordering in the network list:
no ORDER BY in the DB, and network updates move entries to the end.

Let's always sort by network ID so that users don't see the entries
move around.

I've contemplated sorting by Network.GetName() instead, but:

- Clients have now way to figure out dynamic order changes, e.g.
  when renaming a network.
- Some clients might use ISUPPORT NETWORK when a user hasn't
  explicitly named a network, but soju won't use that for ordering,
  leading to non-alphabetic ordering in the client.

Let's leave it to clients to sort the networks by display name if
they want to.

git-svn-id: file:///srv/svn/repo/suika/trunk@769 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-04 14:03:13 +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
4d4886e359 Use more descriptive errors when aborting pending commands
git-svn-id: file:///srv/svn/repo/suika/trunk@752 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 21:33:50 +00:00
contact
5e2a9f86c9 Add context to network.storeClientDeliveryReceipts
git-svn-id: file:///srv/svn/repo/suika/trunk@740 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 22:32:12 +00:00
contact
0331e8241c Add context to upstreamConn.handleMessage
git-svn-id: file:///srv/svn/repo/suika/trunk@739 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 22:27:12 +00:00
contact
886ae69bc6 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@738 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 18:29:44 +00:00
contact
85e0641af8 Don't retry connecting on permanent failure
Closes: https://todo.sr.ht/~emersion/soju/164

git-svn-id: file:///srv/svn/repo/suika/trunk@736 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 16:33:11 +00:00
contact
993177a2c0 Add exponential backoff when re-connecting to upstream
The first reconnection attempt waits for 1min, the second the 2min,
and so on up to 10min. There's a 1min jitter so that multiple failed
connections don't try to reconnect at the exact same time.

Closes: https://todo.sr.ht/~emersion/soju/161

git-svn-id: file:///srv/svn/repo/suika/trunk@735 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 11:14:35 +00:00
contact
1eaf9afc48 Add soju_upstream_connect_errors_total metric
git-svn-id: file:///srv/svn/repo/suika/trunk@734 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 10:15:51 +00:00
contact
49d75b4a4b Fix upstream gauge metric
It wasn't decremented on error. While at it, increment it when
connecting to the upstream network.

git-svn-id: file:///srv/svn/repo/suika/trunk@733 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 10:03:56 +00:00
contact
6c2a942af3 Add context to connectToUpstream
git-svn-id: file:///srv/svn/repo/suika/trunk@732 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 09:53:43 +00:00
contact
a7785769b2 Validate address in user.checkNetwork
git-svn-id: file:///srv/svn/repo/suika/trunk@731 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-01 14:57:54 +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
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
867d701eed Add number of upstream connections to metrics
git-svn-id: file:///srv/svn/repo/suika/trunk@710 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +00:00
contact
5161f92e29 Add per-user IP addresses
The new upstream-user-ip directive allows bouncer operators to
assign one IP address per user.

git-svn-id: file:///srv/svn/repo/suika/trunk@705 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:07:58 +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
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
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
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
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
31f86a9f9d Add context support to user and network mutations
References: https://todo.sr.ht/~emersion/soju/141

git-svn-id: file:///srv/svn/repo/suika/trunk@676 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-08 18:36:10 +00:00
contact
21f482684d 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@666 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-03 15:37:01 +00:00
contact
2748715183 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@652 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-18 17:15:15 +00:00
contact
abc45dc323 msgstore_fs: rename log dir when network is renamed
git-svn-id: file:///srv/svn/repo/suika/trunk@644 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-15 16:11:04 +00:00
contact
c0502705d1 service: allow updating other users
git-svn-id: file:///srv/svn/repo/suika/trunk@625 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-12 07:11:14 +00:00
contact
8dda53c683 Add max-user-networks config option
git-svn-id: file:///srv/svn/repo/suika/trunk@612 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-07 18:43:10 +00:00
contact
b24bf38d54 Don't send network notification when removed
Closes: https://todo.sr.ht/~emersion/soju/123

git-svn-id: file:///srv/svn/repo/suika/trunk@583 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-09-13 08:33:46 +00:00
contact
b275567411 Introduce user.updateUser
Unify updatePassword and updateRealname into a single function. This
allows "user update" to be atomic.

git-svn-id: file:///srv/svn/repo/suika/trunk@572 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-28 16:05:03 +00:00
contact
474d6e3ccd 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@568 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-25 18:33:13 +00:00
contact
ae0ac7c6f0 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@563 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-23 17:23:09 +00:00
contact
70e6f1fb5a Fix typo in BOUNCER notifications: s/status/state/
git-svn-id: file:///srv/svn/repo/suika/trunk@544 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-26 09:08:10 +00:00
contact
b3d039ec5b Broadcast BOUNCER notifications to all downstream connections
We weren't sending them to downstreams which weren't bound to a
network.

git-svn-id: file:///srv/svn/repo/suika/trunk@543 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-26 09:04:33 +00:00
contact
30c6e9e954 Allow networks to be disabled
git-svn-id: file:///srv/svn/repo/suika/trunk@542 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-26 08:51:02 +00:00
contact
b4ffea243d Add support for IRCv3 setname
References: https://todo.sr.ht/~emersion/soju/41

git-svn-id: file:///srv/svn/repo/suika/trunk@540 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 18:24:45 +00:00
contact
74c1f24258 Don't send connection status NOTICEs with bouncer-networks
git-svn-id: file:///srv/svn/repo/suika/trunk@536 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
b736ba981b Introduce the soju.im/bouncer-networks-notify capability
git-svn-id: file:///srv/svn/repo/suika/trunk@535 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
f00821626a Implement the soju.im/bouncer-networks extension
git-svn-id: file:///srv/svn/repo/suika/trunk@532 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
5472ad31ca Add per-network logger
git-svn-id: file:///srv/svn/repo/suika/trunk@501 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 18:12:49 +00:00
contact
db50fb13e5 Error out on network name conflict
Closes: https://todo.sr.ht/~emersion/soju/29

git-svn-id: file:///srv/svn/repo/suika/trunk@500 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 17:33:06 +00:00
contact
a958ddadee Relay detached channel backlog as BouncerServ NOTICE if necessary
Instead of ignoring detached channels wehn replaying backlog,
process them as usual and relay messages as BouncerServ NOTICEs
if necessary. Advance the delivery receipts as if the channel was
attached.

Closes: https://todo.sr.ht/~emersion/soju/98

git-svn-id: file:///srv/svn/repo/suika/trunk@499 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 17:11:05 +00:00