111 Commits

Author SHA1 Message Date
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
contact
d36068af4e Store last internal msg ID in DB when detaching
References: https://todo.sr.ht/~emersion/soju/98

git-svn-id: file:///srv/svn/repo/suika/trunk@497 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 16:15:30 +00:00
contact
e32cf2acd9 Take msg ID in sendTargetBacklog
git-svn-id: file:///srv/svn/repo/suika/trunk@495 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 15:49:37 +00:00
contact
fec819c48a Panic on unknown user event type
This should never happen. Complain loudly if it does.

git-svn-id: file:///srv/svn/repo/suika/trunk@494 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 11:08:48 +00:00
contact
63c2238407 Introduce per-user logger
Adds the username to log lines.

git-svn-id: file:///srv/svn/repo/suika/trunk@493 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 11:04:23 +00:00
contact
83a6c849fd Save delivery receipts in DB
This avoids loosing history on restart for clients that don't
support chathistory.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@489 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-31 16:04:13 +00:00
contact
862be4f5b8 Rename user.clients to clientNames
This doesn't contain anything other than just the names. Make this
clearer.

git-svn-id: file:///srv/svn/repo/suika/trunk@487 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-30 10:44:56 +00:00
contact
e94da85df6 Introduce deliveredStore
This hides the double-map complexity behind a dedicated type.

git-svn-id: file:///srv/svn/repo/suika/trunk@485 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 15:49:50 +00:00
contact
84b3a5d057 Move network.clients to user
No need to have this list per-network.

git-svn-id: file:///srv/svn/repo/suika/trunk@483 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 14:58:56 +00:00
contact
a313a3aead Simplify network.offlineClients
Replace it with a list of all clients (online or offline).

git-svn-id: file:///srv/svn/repo/suika/trunk@482 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 14:55:57 +00:00
contact
2cba08b50e Introduce deliveredClientMap
Adds more semantics to map[string]string. Simplifies the complicated
mapStringStringCasemapMap type.

git-svn-id: file:///srv/svn/repo/suika/trunk@480 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-26 10:21:14 +00:00
hubert
1b73446cbb Implement casemapping
TL;DR: supports for casemapping, now logs are saved in
casemapped/canonical/tolower form
(eg. in the #channel directory instead of #Channel... or something)

== What is casemapping? ==

see <https://modern.ircdocs.horse/#casemapping-parameter>

== Casemapping and multi-upstream ==

Since each upstream does not necessarily use the same casemapping, and
since casemappings cannot coexist [0],

1. soju must also update the database accordingly to upstreams'
   casemapping, otherwise it will end up inconsistent,
2. soju must "normalize" entity names and expose only one casemapping
   that is a subset of all supported casemappings (here, ascii).

[0] On some upstreams, "emersion[m]" and "emersion{m}" refer to the same
user (upstreams that advertise rfc1459 for example), while on others
(upstreams that advertise ascii) they don't.

Once upstream's casemapping is known (default to rfc1459), entity names
in map keys are made into casemapped form, for upstreamConn,
upstreamChannel and network.

downstreamConn advertises "CASEMAPPING=ascii", and always casemap map
keys with ascii.

Some functions require the caller to casemap their argument (to avoid
needless calls to casemapping functions).

== Message forwarding and casemapping ==

downstream message handling (joins and parts basically):
When relaying entity names from downstreams to upstreams, soju uses the
upstream casemapping, in order to not get in the way of the user.  This
does not brings any issue, as long as soju replies with the ascii
casemapping in mind (solves point 1.).

marshalEntity/marshalUserPrefix:
When relaying entity names from upstreams with non-ascii casemappings,
soju *partially* casemap them: it only change the case of characters
which are not ascii letters.  ASCII case is thus kept intact, while
special symbols like []{} are the same every time soju sends them to
downstreams (solves point 2.).

== Casemapping changes ==

Casemapping changes are not fully supported by this patch and will
result in loss of history.  This is a limitation of the protocol and
should be solved by the RENAME spec.

git-svn-id: file:///srv/svn/repo/suika/trunk@478 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-24 17:15:52 +00:00
contact
35272526d6 Send NOTICE to downstream when upstream is disconnected
Closes: https://todo.sr.ht/~emersion/soju/76

git-svn-id: file:///srv/svn/repo/suika/trunk@467 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-16 08:41:07 +00:00
contact
4dfac575f6 Use sendTargetBacklog when re-attaching a channel
No need to attempt to send backlog for all targets in the network.
We're only interested in a single channel.

git-svn-id: file:///srv/svn/repo/suika/trunk@453 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 12:50:10 +00:00
contact
77f0241cf5 Rename network.history to network.delivered
"History" is over-loaded with e.g. CHATHISTORY support.

git-svn-id: file:///srv/svn/repo/suika/trunk@451 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 10:31:34 +00:00
contact
5c1bf5b701 Rename sendNetworkHistory to sendNetworkBacklog
"History" is a little bit over-loaded with CHATHISTORY support.

git-svn-id: file:///srv/svn/repo/suika/trunk@450 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 09:23:51 +00:00
contact
e0ef0b2c01 Add in-memory message store
Uses an in-memory ring buffer.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@442 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-04 16:18:30 +00:00
contact
ee6517993f Turn messageStore into an interface
This allows for other implementations that aren't based on a filesystem.

git-svn-id: file:///srv/svn/repo/suika/trunk@439 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-04 13:24:00 +00:00
hubert
ee16ab9833 Advertise all caps, CAP DEL them on registration
... so that the JOIN/history batch takes into account all capabilities.
Without this commit for example, enabling multi-prefix after the batch
makes the client send NAMES requests for all channels, which generate
needless traffic.

git-svn-id: file:///srv/svn/repo/suika/trunk@437 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-25 12:35:20 +00:00