783 Commits

Author SHA1 Message Date
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
fd58864d3f Add "sasl status" command
git-svn-id: file:///srv/svn/repo/suika/trunk@730 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-12-01 10:03:27 +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
7f11c8a67b doc/soju.1: add network create example
git-svn-id: file:///srv/svn/repo/suika/trunk@728 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-30 08:26:07 +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
4961e5f107 contrib/clients: WeeChat 3.3 enables all IRCv3 caps by default
git-svn-id: file:///srv/svn/repo/suika/trunk@718 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-18 20:05:58 +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
bd1a481bfb doc/per-user-ip: new documentation article
git-svn-id: file:///srv/svn/repo/suika/trunk@715 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 17:04:14 +00:00
contact
9faf7f6b8f Upgrade dependencies
git-svn-id: file:///srv/svn/repo/suika/trunk@714 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 15:57:41 +00:00
contact
467c6df654 Add pprof HTTP server
This enables production debugging of the bouncer.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@713 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 15:18:52 +00:00
contact
8b44d4ce3c Add Prometheus instrumentation for the database
git-svn-id: file:///srv/svn/repo/suika/trunk@712 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +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
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
edb293a257 Add int64 gauge abstraction
We want to serve metrics via both BouncerServ and Prometheus. Add
a tiny abstraction to avoid updating multiple metrics at once.

git-svn-id: file:///srv/svn/repo/suika/trunk@709 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +00:00
contact
f3ca203794 Add basic active users and downstreams metrics
git-svn-id: file:///srv/svn/repo/suika/trunk@708 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:19 +00:00
contact
7eaaf2b78f Add basic Prometheus metrics exporter
This only exports the default metrics for now.

References: https://todo.sr.ht/~emersion/soju/142

git-svn-id: file:///srv/svn/repo/suika/trunk@707 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 14:58:18 +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
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
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
caf05fd066 Use background context in tests
git-svn-id: file:///srv/svn/repo/suika/trunk@697 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 11:04:24 +00:00
contact
bcc7fa6ffa contrib/znc-import: use background context
git-svn-id: file:///srv/svn/repo/suika/trunk@696 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 10:56:16 +00:00
contact
ef39ddf576 sojuctl: use background context
git-svn-id: file:///srv/svn/repo/suika/trunk@695 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-17 10:54:28 +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
contact
f8cbb93de1 Add panic handlers for user and downstream goroutines
This only brings down a single user or downstream on panic, instead
or bringing down the whole bouncer.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@689 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 20:40:17 +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
contact
ae9ecc0718 cmd/soju: bump max number of opened files
The bouncer process may be dealing with many opened FDs. The default
on Linux is 1024. To support bouncers with a lot of users, bump
RLIMIT_NOFILE to the max as advised in [1].

[1]: http://0pointer.net/blog/file-descriptor-limits.html

git-svn-id: file:///srv/svn/repo/suika/trunk@687 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-11-15 20:22:43 +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