Commit Graph

947 Commits

Author SHA1 Message Date
Simon Ser
9f002d0409 server: print panic stack trace as string
debug.Stack() returns a byte slice.
2022-04-04 09:54:48 +02:00
Simon Ser
747263fc2d Simplify and improve WHOIS forwarding
Group together most WHOIS replies. While at it, add a few missing
replies.
2022-04-04 09:28:04 +02:00
Simon Ser
303c663d02 Refuse to change nick on bouncer connection
Also simplify the code.

Closes: https://todo.sr.ht/~emersion/soju/192
2022-04-01 14:55:36 +02:00
Simon Ser
29b1e6f47b downstream: update user realname on SETNAME 2022-03-30 17:51:04 +02:00
Simon Ser
a45f9c3274 Use SETNAME when updating user-wide realname 2022-03-30 15:11:25 +02:00
Simon Ser
d7b5f5d12c downstream: set realname for network-less connections
Send the user-wide realname config. We still need to handle SETNAME
properly.
2022-03-30 14:17:09 +02:00
Simon Ser
f6655fbe11 Allow nil network in Get{Nick,Username,Realname}
Will simplify callers.
2022-03-30 14:17:09 +02:00
Simon Ser
3d8022d030 doc/getting-started: mention TLS and on-disk logs 2022-03-26 18:42:34 +01:00
Simon Ser
ad8192cb82 doc/getting-started: add paragraph about client names 2022-03-26 18:22:33 +01:00
Simon Ser
8efc125f51 contrib/clients: senpai now supports soju.im/bouncer-networks 2022-03-24 19:19:15 +01:00
Simon Ser
18bb3e6138 doc: split off multi-upstream documentation
Multi-upstream mode is confusing for new users. Let's explain how
it works in a separate file.
2022-03-24 19:16:43 +01:00
Simon Ser
0ec3e63ace downstream: send RPL_ENDOFWHO on unmarshalEntity error
Also remove a couple of outdated comments.
2022-03-23 19:15:52 +01:00
Simon Ser
44efe37292 downstream: clarify "user not active" error message 2022-03-23 13:11:37 +01:00
Simon Ser
16e43ee3a3 upstream: don't populate time tag for numerics
Allows us to save a few bytes, e.g. in WHO replies.
2022-03-22 21:14:02 +01:00
Simon Ser
09513e63fe Remove unnecessary zero initialization 2022-03-22 21:10:06 +01:00
Simon Ser
43371bf347 Add the soju.im/no-implicit-names extension
References: https://github.com/ircv3/ircv3-ideas/issues/87
2022-03-22 21:03:20 +01:00
Simon Ser
128aefcc50 downstream: strip back "*" prefix 2022-03-21 17:16:02 +01:00
Simon Ser
8e4c8f7e5a downstream: copy message when degrading extended-join
Otherwise we mutate the input argument and loops over downstream
connections to send messages will be messed up.
2022-03-21 17:13:55 +01:00
Simon Ser
5defd29509 Ensure all incoming messages have a prefix set
Per the spec:

> If the source is missing from a message, it’s is assumed to have originated
> from the client/server on the other end of the connection the message was
> received on.
2022-03-21 17:01:15 +01:00
Simon Ser
883683c0b7 downstream: always populate downstreamConn.username
This ensures we don't send a prefix without a username in it.
2022-03-21 16:37:04 +01:00
Simon Ser
069625d30d downstream: rejigger hostname logic in newDOwnstreamConn
I find it easier to read this way.
2022-03-21 16:33:58 +01:00
Simon Ser
e403b88a3d Add support for chghost 2022-03-21 16:30:58 +01:00
Simon Ser
86f08ec35d doc/soju.1: fix syntax error 2022-03-21 16:11:11 +01:00
Simon Ser
78d9a84a6f Add support for RPL_VISIBLEHOST 2022-03-21 16:09:45 +01:00
Simon Ser
b0dbb3cef1 downstream: explain when downstreamConn.sasl is nil 2022-03-21 15:11:43 +01:00
Simon Ser
70ba7032f1 downstream: move negotiatingCaps to downstreamRegistration
This field is only relevant during connection registration.
2022-03-21 15:09:31 +01:00
Simon Ser
884bfec6a6 downstream: improve grouping of downstreamConn fields 2022-03-21 15:08:12 +01:00
Simon Ser
b3425ba1a3 downstream: process BOUNCER BIND in downstreamConn.welcome
This allows clients to send BOUNCER BIND before SASL auth, or to
use BOUNCER BIND with PASS.
2022-03-21 15:02:54 +01:00
Simon Ser
2c691d012d downstream: reject negative or zero network IDs in parseBouncerNetID 2022-03-21 15:00:30 +01:00
Simon Ser
d9468b983f downstream: move multi-upstream name handling to loadNetwork 2022-03-21 14:54:23 +01:00
Simon Ser
bed50c10ce downstream: ignore nickname during connection registration
Just force-set the nickname and completely disregard what the client
sets during connection registration. Clients must discover their
effective nickname via RPL_WELCOME.
2022-03-21 14:54:21 +01:00
delthas
2ac9bd9c94 Require an explicit * network suffix for multi-upstream
Most users will connect to their server with `<username>` as their
username in order to configure their upstreams.

Multi-upstream can be unintuitive to them and should not be enabled on
that first connection that is usually used for upstream configuration.

Multi-upstream is instead a power-user feature that should be explicitly
enabled with a specific network suffix.

We reserve the network suffix `*` and use it a special case to mean that
it requests multi-upstream mode.
2022-03-21 09:56:20 +01:00
delthas
f5b16dc00c Send any welcome error messages to the downstream
Currently, if we fail connecting to a new networking during welcome, we
send no error message to the client, and the connection remains open in
an undefined state.

Given the input:

  NICK nick
  USER user/invalid.xyz s e r
  PASS pass

soju will fail to connect, add a message to its own logs, but will
return no message to the downstream.

This fixes the issue by forwarding the error message if it is an IRC
error message (which it is for connecting to new networks).

We should probably also close the connection after the message is
written, because it leaves the connection in an undefined state. This is
TODO for now because we'd have to wait for the error message to be
written out first, which is non-trivial.
2022-03-21 09:49:37 +01:00
delthas
9647711921 Fix build on systems without syscall.Rlimit
On some systems (namely Windows), syscall.Rlimit is not defined, and
makes the build fail.

This fixes the build by making the rlimit calls only run on archs where
it is defined, defaulting to a stub on other systems.

See: 8427429c59
2022-03-21 09:39:54 +01:00
Simon Ser
744c6e3f6d Enable bot mode for BouncerServ
See [1] for details.

[1]: https://ircv3.net/specs/extensions/bot-mode
2022-03-16 18:35:48 +01:00
Simon Ser
777adbd5e1 downstream: improve ERR_ERRONEUSNICKNAME message a bit 2022-03-16 12:33:23 +01:00
Simon Ser
5feae506d4 doc/soju.1: recommend using a FQDN for the hostname 2022-03-15 23:01:08 +01:00
Simon Ser
8b926be817 Warn about non-FQDN hostnames
References: https://github.com/ircdocs/modern-irc/pull/148
2022-03-15 20:45:23 +01:00
Simon Ser
c7039da54b service: limit number of -connect-command flags 2022-03-14 19:37:12 +01:00
Simon Ser
35b09f069c downstream: atomically ack/nak capabilities 2022-03-14 19:30:29 +01:00
Simon Ser
6e094b1099 Use capRegistry for upstreamConn 2022-03-14 19:25:49 +01:00
Simon Ser
74fd506fef Use capRegistry for downstreamConn 2022-03-14 19:25:49 +01:00
Simon Ser
347a4979da irc: introduce capRegistry 2022-03-14 19:25:49 +01:00
delthas
9376c8885c downstream: Enable handling READ when upstream is disconnected
Previously, when we sent READ for an upstream which was disconnected,
we would fail with an error. This is because we called unmarshalEntity,
which checked that the upstream was in the connected status.

But we don't need to be connected to update the READ timestamp, this is
a purely offline (wrt the upstream) operation.

This simply switches the call from unmarshalEntity to
unmarshalEntityNetwork to fix the issue.
2022-03-08 22:35:46 +01:00
Simon Ser
fdf9727600 Mark BouncerServ as online in MONITOR, don't forward to upstream 2022-03-08 21:29:04 +01:00
Simon Ser
d8f5f8481f downstream: set case-mapping for monitored 2022-03-08 21:28:43 +01:00
Simon Ser
9a79c66921 upstream: use network case-mapping in updateMonitor
We were using the downstream case-mapping.
2022-03-08 21:27:43 +01:00
Simon Ser
2060ae05cf downstream: drop delivery receipts when client supports chathistory
When the client supports draft/chathistory, no need to request
delivery receipts via PING messages. Let's just not leave delivery
receipts alone. They'll go stale but should be never used (or used
by a non-chathistory client).
2022-03-08 16:45:45 +01:00
Simon Ser
421d3f258a db_postgres: report network metrics with hostname label
This can help figure out when it's necessary to discuss with
network operators to request a connection limit bump.
2022-03-08 11:04:23 +01:00
Simon Ser
dac003960c db: allow registering multiple metrics collectors 2022-03-08 10:36:59 +01:00