Commit Graph

64 Commits

Author SHA1 Message Date
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
Simon Ser
e177977c30 Add DB stats 2021-10-05 19:31:06 +02:00
Simon Ser
5405923aa2 Add limit for RSA bits 2021-10-05 19:21:43 +02:00
Simon Ser
f93616fb41 Add "server status" command
Right now, it prints the number of active users and number of
downstream connections.
2021-10-05 19:13:53 +02:00
delthas
896caebfcf service: Introduce network quote
This command enables sending a raw line to a specific network.
2021-07-07 10:34:46 +02:00
Alexey Yerin
12545c07ef service: show SHA-512 fingerprint
Closes: https://todo.sr.ht/~emersion/soju/130
2021-07-06 16:34:15 +02:00
Jake Nelson
fc841b0ba2 Sort channel status channels by name 2021-06-29 22:19:19 +02:00
Simon Ser
acde97ca37 Introduce user.updateUser
Unify updatePassword and updateRealname into a single function. This
allows "user update" to be atomic.
2021-06-28 18:05:03 +02:00
Simon Ser
09b04792b9 Merge "change-password" into "user update"
Add a -password flag to the "user update" command.
2021-06-28 16:55:44 +02:00
Simon Ser
f8e853fab1 Only update realname if specified in "user udpate"
This will allow adding more flags.
2021-06-28 16:40:49 +02:00
Simon Ser
a14f646135 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.
2021-06-25 20:33:13 +02:00
Hubert Hirtz
a21585ac41 Hand-made word splitter for BouncerServ
Remove the (direct) dependency on shlex (go-scfg still depends on it).

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-06-24 19:33:46 +02:00
Simon Ser
b0b913293e Send placeholder when no network/channel is returned by BouncerServ 2021-05-26 11:27:59 +02:00
Simon Ser
7d648f702e Allow networks to be disabled 2021-05-26 10:51:02 +02:00
Simon Ser
1b43b05588 Add channel status service command 2021-05-25 19:22:22 +02:00
Eyal Sawady
9b40cfe95c handleUserDelete: delete the correct user
Prior to this, we deleted the user issuing the deletion rather than the
user which should've been deleted.
2021-04-22 10:37:05 +02:00
Hubert Hirtz
bdd0c7bc06
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.
2021-03-24 18:15:52 +01:00
delthas
0ddc0de7e5 service: Introduce channel update
This adds the `channel update` service command, which is used to set the
auto-detach, auto-reattach, and message relaying settings of a channel.

Of note is that currently the parser parses `#` as a comment, which
means any `channel update #foo ...` will actually need to be escaped to
`channel update "#foo" ...`
2020-12-14 20:54:02 +01:00
Simon Ser
fa16337d97
Switch DB API to user IDs
This commit changes the Network schema to use user IDs instead of
usernames. While at it, a new UNIQUE(user, name) constraint ensures
there is no conflict with custom network names.

Closes: https://todo.sr.ht/~emersion/soju/86
References: https://todo.sr.ht/~emersion/soju/29
2020-10-24 15:14:23 +02:00
Simon Ser
ccc8768435
Add user delete command
References: https://todo.sr.ht/~emersion/soju/17
2020-08-10 15:04:01 +02:00
Hubert Hirtz
5e2910ba9d
Fix help message for BouncerServ's network update
It was missing the network name as first argument.
2020-08-03 11:03:39 +02:00
Simon Ser
cc01ffc19d
Rename certfp reset to sasl reset
And make it reset all SASL credentials.
2020-07-22 12:20:52 +02:00
Simon Ser
2a3ae55f52
Add a sasl set-plain command
This allows to manually set the SASL credentials for a network.
2020-07-22 12:16:13 +02:00
Simon Ser
907da56311
Add unix as supported upstream URL scheme to service 2020-07-09 12:19:51 +02:00
Simon Ser
90250f5be5
Reply to WHO BouncerServ
Closes: https://todo.sr.ht/~emersion/soju/75
2020-06-29 18:09:48 +02:00
Simon Ser
6c453aa5ca
service: list commands in lexicographic order 2020-06-24 12:08:35 +02:00
Simon Ser
67f8773320
Fix missing appendServiceCommandSetHelp argument 2020-06-10 16:34:45 +02:00
fox.cpp
ce37fcc7c2
Do not panic if BouncerServ command without handler is sent 2020-06-10 16:33:13 +02:00
Kenny Levinsen
1cbdb26dd1
service: Handle zero-value in stringPtrFlag.String
FlagSet.PrintDefaults uses reflection to construct a zero value, calls
.String on it, and compares the result with the current flag value to
detect zero-value flags. For stringPtrFlag, this would result in a
panic, as String() always dereferenced the first level of its **string.

Add another check so that both pointer levels are nil-checked.
2020-06-10 16:18:15 +02:00
delthas
5be25711c7 Add support for the user create admin service command
This adds support for user create, a new service command only accessible
to admin users. This lets users create other users on the fly and makes
soju start the user routine immediately; unlike sojuctl which currently
requires closing soju, creating the user, and starting soju again.
2020-06-08 22:30:09 +02:00
delthas
f5611ae3f9 Add support for admin-restricted service commands
This is preparatory work for creating new users from a service command.

This adds support for specifying specific service commands as
admin-restricted. Only admin users can run these commands. These
commands won't show up in the help when run from a non-admin
user, unless the user is requesting help for that specific command.
2020-06-08 22:30:09 +02:00
delthas
17fe033adc Rename handleServiceCreateNetwork to handleServiceNetworkCreate
This renames handleServiceCreateNetwork for consistency with other
service commands.
2020-06-08 22:30:09 +02:00
Simon Ser
283d4bf14c
Introduce ircConn
This interface will allow a conn to be backed by a websocket.
2020-06-04 17:27:57 +02:00
Simon Ser
c709ebfc91
Add network update command
The user.updateNetwork function is a bit involved because we need to
make sure that the upstream connection is closed before re-connecting
(would otherwise cause "Nick already used" errors) and that the
downstream connections' state is kept in sync.

References: https://todo.sr.ht/~emersion/soju/17
2020-06-04 13:04:39 +02:00
fox.cpp
203dc3df6a
Implement upstream SASL EXTERNAL support
Closes: https://todo.sr.ht/~emersion/soju/47
2020-06-02 11:24:22 +02:00
Simon Ser
e7e4311160
Remove network.upstream
This is an artifact from when we used locks. No need for this anymore.
2020-04-30 10:25:16 +02:00