Commit Graph

1172 Commits

Author SHA1 Message Date
Simon Ser
3f91cfb8c3 service: make name arg optional for network commands
Makes commands less verbose.
2022-02-07 21:33:16 +01:00
Simon Ser
57715d8ce2 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.
2022-02-04 16:47:34 +01:00
Simon Ser
64ad2164de Fix capitalization of handleServiceSASLStatus 2022-02-04 15:41:40 +01:00
Simon Ser
49b77d630a 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.
2022-02-04 15:03:13 +01:00
Simon Ser
0b5da29916 Drop user.forEachNetwork
It's a trivial for loop.
2022-02-04 14:01:27 +01:00
Simon Ser
f2a03cf7a1 Fix incorrect listen addr in error message
The various server goroutines would always capture the last listen
addr in the loop.
2022-01-19 22:38:13 +01:00
Simon Ser
69e9b6a439 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
2022-01-19 22:35:46 +01:00
Theodor Thornhill
950198a2b7 contrib/clients: Add information about emacs irc clients 2022-01-13 16:06:54 +01:00
Simon Ser
7060547809 Don't send RPL_NOTOPIC on JOIN
As per https://modern.ircdocs.horse/#join-message
2022-01-10 10:37:55 +01:00
Chris Howey
bc727496d0 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
2022-01-03 21:01:44 +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
e7f9d2332b Add support for downstream multi-line AUTHENTICATE commands
Useful for long passwords.
2021-12-09 23:21:08 +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
bad8154da8 Don't forward duplicate JOIN commands
Closes: https://todo.sr.ht/~emersion/soju/171
2021-12-08 18:23:46 +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
d21fc06d88 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.
2021-12-08 15:00:02 +01:00
Simon Ser
9caa6f9ca0 service: send summary when executing "server notice"
Sometimes this command times out. Display the number of skipped
users.
2021-12-08 14:55:31 +01:00
Simon Ser
f7e151396d Use dc.nick instead of "*" for RPL_* messages
Makes it clearer what these fields are used for. The default value
for dc.nick is "*".
2021-12-07 09:42:32 +01:00
Simon Ser
aae0fb9f22 Improve error message when downstream doesn't authenticate 2021-12-07 09:40:02 +01:00
Simon Ser
b6c47a517c Use more descriptive errors when aborting pending commands 2021-12-06 22:33:50 +01:00
Simon Ser
5c819a2c6c Disallow ',' in nicknames
It breaks lists as in `PRIVMSG a,b,c :foo`.
2021-12-06 19:23:28 +01:00
Simon Ser
1a78b3d905 Add username to downstreamConn log messages 2021-12-06 18:56:00 +01:00
Simon Ser
d7f7e351af Improve msgStore.Append log message wording 2021-12-06 18:46:10 +01:00
Simon Ser
8b7df6dd46 Downgrade conn log messages to debug 2021-12-06 18:40:37 +01:00
Simon Ser
d829d2ab12 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
2021-12-06 18:35:49 +01:00
Simon Ser
7dd884d3da Remove Logger.Print
Callers can just use Logger.Printf instead.
2021-12-06 18:27:36 +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
b2957c05d5 Use golang.org/x/time/rate
Instead of hand-rolling our own rate-limiter based on goroutines,
use golang.org/x/time/rate.
2021-12-02 23:52:29 +01:00
Simon Ser
f75ee272a4 Add context to network.storeClientDeliveryReceipts 2021-12-02 23:32:12 +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
578020e553 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
2021-12-02 12:14:35 +01:00
Simon Ser
8acc07d591 Add soju_upstream_connect_errors_total metric 2021-12-02 11:15:51 +01:00
Simon Ser
d11216917b Fix upstream gauge metric
It wasn't decremented on error. While at it, increment it when
connecting to the upstream network.
2021-12-02 11:03:56 +01:00
Simon Ser
73287f242e Add context to connectToUpstream 2021-12-02 10:53:43 +01:00
Simon Ser
33a639ecf0 Validate address in user.checkNetwork 2021-12-01 15:57:54 +01:00
Simon Ser
43c440e600 Add "sasl status" command 2021-12-01 11:03:27 +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
e42b507377 doc/soju.1: add network create example 2021-11-30 09:26:07 +01:00
Simon Ser
522e20cca1 downstream: improve unmarshalEntityNetwork error message
Closes: https://todo.sr.ht/~emersion/soju/162
2021-11-29 16:41:52 +01:00
Simon Ser
c36192ab02 Return more descriptive auth failure errors 2021-11-29 13:14:16 +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
4e84b41592 Send RPL_LOGGEDIN with bouncer account in multi-upstream mode 2021-11-21 11:00:57 +01:00