783 Commits

Author SHA1 Message Date
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
contact
85d375e157 doc: move read spec to ext/
git-svn-id: file:///srv/svn/repo/suika/trunk@782 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-11 18:49:21 +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
71a0ed4052 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).

git-svn-id: file:///srv/svn/repo/suika/trunk@779 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-09 14:20:32 +00:00
contact
801dc26f68 Refactor generateWHOXReply
Isolate the field letter -> value logic into a separate function.

git-svn-id: file:///srv/svn/repo/suika/trunk@778 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-09 14:16:54 +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
5e54c4b726 makefile: switch to BSD/GNU make
Let's stop using POSIX make, it's too much of a pain.

git-svn-id: file:///srv/svn/repo/suika/trunk@775 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-08 15:10:19 +00:00
contact
ec2d1bd2d8 db_postgres: use enum for sasl_mechanism
Ensures only supported mechanisms get stored in the DB.

git-svn-id: file:///srv/svn/repo/suika/trunk@774 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-08 14:38:41 +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
31f8b05eea service: make name arg optional for network commands
Makes commands less verbose.

git-svn-id: file:///srv/svn/repo/suika/trunk@772 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-07 20:33:16 +00:00
contact
ad8763469f service: switch to -network flag for certfp and sasl commands
Instead of always requiring users to explicitly specify the network
name, guess it from the downstream connection.

Network commands are left as-is because it's not yet clear how to
handle them.

git-svn-id: file:///srv/svn/repo/suika/trunk@771 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-04 15:47:34 +00:00
contact
6ee303a377 Fix capitalization of handleServiceSASLStatus
git-svn-id: file:///srv/svn/repo/suika/trunk@770 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-02-04 14:41:40 +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
cf4b0a76c5 Fix incorrect listen addr in error message
The various server goroutines would always capture the last listen
addr in the loop.

git-svn-id: file:///srv/svn/repo/suika/trunk@767 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-01-19 21:38:13 +00:00
contact
f7264b0bef Retry on temporary net.Listener failure
Instead of stopping to listen, retry on temporary failure. This
can happen when running out of FDs.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@766 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-01-19 21:35:46 +00:00
theo
487e4a3232 contrib/clients: Add information about emacs irc clients
git-svn-id: file:///srv/svn/repo/suika/trunk@765 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-01-13 15:06:54 +00:00
contact
e1f09398b1 Don't send RPL_NOTOPIC on JOIN
As per https://modern.ircdocs.horse/#join-message

git-svn-id: file:///srv/svn/repo/suika/trunk@764 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-01-10 09:37:55 +00:00
chris
8d94f8a743 bump required go version to 1.15
requires functions added to the stdlib in 1.15

downstream.go references tls.Dialer
user.go references Resolver.LookupIP

git-svn-id: file:///srv/svn/repo/suika/trunk@763 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2022-01-03 20:01:44 +00:00
contact
1793b83dc4 Add context to upstreamConn.handleCapAck
git-svn-id: file:///srv/svn/repo/suika/trunk@762 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-10 11:28:16 +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
52e40a3e0e Block RPL_{CREATIONTIME,TOPICWHOTIME} for detached channels
Closes: https://todo.sr.ht/~emersion/soju/132

git-svn-id: file:///srv/svn/repo/suika/trunk@759 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-09 11:12:20 +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
bafd6c3e41 server: cleanup user in defer
If a user goroutine panics, this correctly removes it from the
global map instead of leaving a dangling entry behind.

git-svn-id: file:///srv/svn/repo/suika/trunk@756 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-08 14:00:02 +00:00
contact
fcac9d5cdd service: send summary when executing "server notice"
Sometimes this command times out. Display the number of skipped
users.

git-svn-id: file:///srv/svn/repo/suika/trunk@755 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-08 13:55:31 +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
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
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
1059ee4607 Improve msgStore.Append log message wording
git-svn-id: file:///srv/svn/repo/suika/trunk@749 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:46:10 +00:00
contact
8646b0e5db Downgrade conn log messages to debug
git-svn-id: file:///srv/svn/repo/suika/trunk@748 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:40:37 +00:00
contact
ab7067fa48 Add Logger.Debugf
Makes it easy to print debugging messages which aren't targeted at
the user. See [1] for motivation.

[1]: https://dave.cheney.net/2015/11/05/lets-talk-about-logging

git-svn-id: file:///srv/svn/repo/suika/trunk@747 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:35:49 +00:00
contact
608d415c30 Remove Logger.Print
Callers can just use Logger.Printf instead.

git-svn-id: file:///srv/svn/repo/suika/trunk@746 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:27:36 +00:00
contact
c74b16c19f Stop incrementing hopcount in RPL_WHOREPLY
It's extra code for something clients should ignore because it's
unreliable and useless.

git-svn-id: file:///srv/svn/repo/suika/trunk@745 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 17:08:53 +00:00
contact
5dd0243bb1 Read nickname from RPL_WELCOME
References: https://github.com/ircdocs/modern-irc/pull/146

git-svn-id: file:///srv/svn/repo/suika/trunk@744 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-06 16:58:54 +00:00
contact
f638c52c9b 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

git-svn-id: file:///srv/svn/repo/suika/trunk@743 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-04 19:07:23 +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
5d8bf4f0ef Use golang.org/x/time/rate
Instead of hand-rolling our own rate-limiter based on goroutines,
use golang.org/x/time/rate.

git-svn-id: file:///srv/svn/repo/suika/trunk@741 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 22:52:29 +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
b9180f0b42 Mark ACCOUNT_REQUIRED error as permanent connection failure
There's no point in retrying to connect in this case.

git-svn-id: file:///srv/svn/repo/suika/trunk@737 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-02 16:58:56 +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