Commit Graph

99 Commits

Author SHA1 Message Date
Simon Ser
07cd1f2f5d Use generics for casemapMap 2023-03-01 13:15:38 +01:00
delthas
b920facdff service: Return the error rather than printing it
This enables callers to make the difference between a successful
service call and a failed one.
2023-02-06 15:15:09 +01:00
delthas
f05bd84787 service: Enable running additional commands from a global context
Some commands do not require admin rights but are also useful to
run in a global context. For example, help.
2023-02-06 15:15:09 +01:00
delthas
d17c7d57f2 service: Enable running service commands without users
This enables support for global service contexts, that are run
independently from a user context.

These contexts are considered to be admin. They only have access
to admin commands, because those are relevant in a global context.
2023-02-06 15:15:09 +01:00
delthas
4bd600c651 service: Store the admin capability independently the user
We can acquire admin contexts independently of the user.

This is mainly for a future commit that will introduce events
without a user.
2023-02-06 15:15:09 +01:00
Kirill Primak
b2d9af22c3 service: update "user {create,update}" help 2023-01-30 20:33:30 +01:00
Simon Ser
979fb319fe service: add -disable-password
This can be used to disable password authentication for a user.
This is useful to prevent a disabled user account from being
auto-enabled when enable-user-on-auth is on.
2023-01-26 20:03:37 +01:00
Simon Ser
05d7813835 service: indicate which users are disabled in "user status" 2023-01-26 19:42:13 +01:00
Simon Ser
d7d9d45b45 Add a flag to disable users
Add a new flag to disable users. This can be useful to temporarily
deactivate an account without erasing data.

The user goroutine is kept alive for simplicity's sake. Most of the
infrastructure assumes that each user always has a running goroutine.
A disabled user's goroutine is responsible for sending back an error
to downstream connections, and listening for potential events to
re-enable the account.
2023-01-26 18:33:55 +01:00
Simon Ser
bbf234d441 user: take context in user.stop 2023-01-26 17:12:58 +01:00
delthas
959baa964f service: add user status
This lists all the users of the instances, along with the number
of networks they have.

Limited to 50 users to avoid flooding with thousands of messages
on large instances.
2023-01-18 16:24:12 +01:00
Simon Ser
1ad2ee7ef5 service: drop unnecessary admin check in handleUserRun
The command is marked as admin-only already.
2023-01-18 16:05:41 +01:00
delthas
b29c9ef09a service: add user run
This enables to run commands as other users, like sudo.

This is useful for eg fixing a user networks on their behalf.
2023-01-18 15:12:33 +01:00
delthas
e7a06fe208 service: refactor downstreamConn to serviceContext
This will enable running service commands from other contexts.
2023-01-18 15:12:33 +01:00
delthas
e71cdbf6e3 service: reject commands with unexpected arguments
This avoids issues where a user misstypes the following message:

     network update foobar enabled -false

This is obviously a typo of:

     network update foobar -enabled false

But we currently accept it without failing, and ignore the trailing
parameter "false".

This fixes this behavior by failing on unexpected arguments.
2023-01-15 16:52:37 +01:00
Simon Ser
bd4aee3f31 service: fix typo in network -cerfp flag name
Reported-by: rj1 <rj1@riseup.net>
Fixes: be185fba33 ("Implement TLS fingerprint pinning")
2022-12-18 17:55:31 +01:00
rj1
be185fba33 Implement TLS fingerprint pinning
Closes: https://todo.sr.ht/~emersion/soju/56
2022-12-16 17:44:14 +01:00
Simon Ser
6ddfc943f5 service: send PART in channel delete 2022-12-08 16:04:01 +01:00
Simon Ser
0edf3a40c2 service: add channel delete command 2022-12-08 16:00:00 +01:00
Simon Ser
106d40dcd4 Upgrade to gopkg.in/irc.v4 2022-11-14 12:06:58 +01:00
zsrv
926dcb37ac Make the auto-away functionality configurable 2022-09-26 19:52:07 +02:00
Simon Ser
c3ab11de4e downstream: drop downstreamConn.unmarshalEntity{,Network} 2022-09-26 16:57:05 +02:00
gildarts
0777ca0d29 Add ability for a user to delete themselves
Adds user self delete
Adds confirmation of user deletion
2022-07-12 18:14:11 +02:00
Simon Ser
dc0a847240 Add per-user default nickname
The soju username is immutable. Add a separate nickname setting so
that users can change their nickname for all networks.

References: https://todo.sr.ht/~emersion/soju/110
2022-07-08 18:01:05 +02:00
gildarts
4bc9aaf659 Add detach option to channel update
Add `-detached` to `channel update` command

Co-authored-by: Simon Ser <contact@emersion.fr>
Closes: https://todo.sr.ht/~emersion/soju/140
2022-06-24 22:04:12 +02:00
Simon Ser
fe40c51ff0 database: add User.{Check,Set}Password 2022-06-08 13:27:33 +02:00
Simon Ser
09f2cf8489 Don't provide name in channel casemapMap Set and ForEach
The name is already provided in the struct.
2022-06-06 10:05:31 +02:00
Simon Ser
657e25b25c Make casemapMap more type-safe
In addition to a type-safe getter, also define type-safe setters
and iterators.

References: https://lists.sr.ht/~emersion/soju-dev/patches/32777
2022-06-06 09:58:39 +02:00
Simon Ser
3a7dee8128 Introduce a database package 2022-05-09 15:08:04 +02: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
Simon Ser
c7039da54b service: limit number of -connect-command flags 2022-03-14 19:37:12 +01:00
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
0b5da29916 Drop user.forEachNetwork
It's a trivial for loop.
2022-02-04 14:01:27 +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
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
43c440e600 Add "sasl status" command 2021-12-01 11:03:27 +01:00
Simon Ser
efc4c62725 Add number of upstream connections to metrics 2021-11-17 15:58:19 +01:00
Simon Ser
73295e4fa7 Allow most config options to be reloaded
Closes: https://todo.sr.ht/~emersion/soju/42
2021-11-16 00:38:04 +01:00
Simon Ser
d870efa666 Add context support to Server.createUser 2021-11-08 20:29:14 +01:00
Simon Ser
e3b1930bf2 Add partial context support to handleUserUpdate
More plumbing needed to make sure we don't block too long waiting
for the reply.
2021-11-08 19:48:32 +01:00
Simon Ser
22f9ce1b86 Check context cancellation in handleServiceServerNotice
This prevents this function from blocking forever if it exceeds the
deadline.
2021-11-08 19:42:36 +01:00
Simon Ser
802e82c272 Add context support to service
References: https://todo.sr.ht/~emersion/soju/141
2021-11-08 19:40:48 +01:00
Simon Ser
c21202160c Add context support to user and network mutations
References: https://todo.sr.ht/~emersion/soju/141
2021-11-08 19:36:10 +01:00
Simon Ser
a6aa7f0008 Make Network.Nick optional
Make Network.Nick optional, default to the user's username. This
will allow adding a global setting to set the nickname in the
future, just like we have for the real name.

References: https://todo.sr.ht/~emersion/soju/110
2021-11-02 23:33:17 +01:00
Simon Ser
9ec1f1a5b0 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.
2021-10-18 19:15:15 +02:00
Simon Ser
4e9ddf78ab service: allow updating other users 2021-10-12 09:11:14 +02:00
Simon Ser
5a2d6246ec Add "server notice" command 2021-10-08 10:52:03 +02:00
Simon Ser
e3b4687ac7 Split CertFP logic into separate file 2021-10-08 09:47:25 +02:00