Commit Graph

45 Commits

Author SHA1 Message Date
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
Simon Ser
6899e748c6
Abbreviate net status service reply
Don't print the nickname if it's the same as the downstream
connection's.
2020-04-28 16:27:53 +02:00
delthas
7b35757bac Add support for the irc+insecure address scheme
Some servers do not support TLS, or have invalid, expired or self-signed
TLS certificates. While the right fix would be toi contact each server
owner to add support for valid TLS, supporting plaintext upstream
connections is sometimes necessary.

This adds support for the irc+insecure address scheme, which connects to
a network in plain-text over TCP.
2020-04-28 11:41:13 +02:00
delthas
19795a2321 Add support for IRC address schemes
This is preparatory work for adding other connection types to upstream
servers. The service command `network create` now accepts a scheme in
the address flag, which specifies how to connect to the upstream server.

The only supported scheme for now is ircs, which is also the default if
no scheme is specified. ircs connects to a network over a TLS TCP
connection.
2020-04-28 11:41:13 +02:00
delthas
7f74055380 Add support for custom network on-connect commands
Some servers use custom IRC bots with custom commands for registering to
specific services after connection.

This adds support for setting custom raw IRC messages, that will be
sent after registering to a network.

It also adds support for a custom flag.Value type for string
slice flags (flags taking several string values).
2020-04-16 17:38:47 +02:00
Thorben Günther
20a58b1fa3
Allow users to change password in client
Added a BouncerServ command for that.
2020-04-10 10:16:25 +02:00
Simon Ser
70f54f685a
Only print addr if necessary in network status service command 2020-04-05 15:20:13 +02:00
delthas
4bcfeae5a6
Fill all fields of the service user prefix
On some IRC clients, NOTICE messages from a user which does not have a
user or host in its prefix (and therefore only have a Name, and look
like prefixes of servers), are treated as server notices rather than
user notices, and are treated differently. (For that matter, soju also
considers NOTICE messages from users with only a Name in their prefix as
special server messages). On most of these clients, NOTICE messages from
a user are formatted differently and stand out from the large flow of
incoming misceallenous server messages.

This fills the service user with fake User and Host values so that
NOTICE messages from it correctly appear as coming from a user. This
is particularly useful in the context of connection and disconnect
errors NOTICE messages that are broadcast from the service user to all
relevant downstreams.
2020-04-04 17:34:30 +02:00
delthas
8c11205ee6
Send the last error for disconnected networks in network status
This adds support for sending the exact error message of a network when
it is disconnected, in the reply to the service command `network
status`. This lets users easily examine why a network is currently
disconnected.

No lock is needed because all reads and writes of network.lastError are
made in the user goroutine.

Closes: https://todo.sr.ht/~emersion/soju/28
2020-04-04 17:34:12 +02:00
delthas
eb941d2d2b
Send one NOTICE on new upstream disconnect/connect errors
In order to notify the user when we are disconnected from a network
(either due to an error, or due a QUIT), and when we fail reconnecting,
this commit adds support for sending a short NOTICE message from the
service user to all relevant downstreams.

The last error is stored, and cleared on successful connection, to
ensure that the user is *not* flooded with identical connection error
messages, which can often happen when a server is down.

No lock is needed on lastError because it is only read and modified from
the user goroutine.

Closes: https://todo.sr.ht/~emersion/soju/27
2020-04-04 17:33:09 +02:00
Simon Ser
96039320b6
Add "network delete" service command
And add all the infrastructure required to stop and delete networks.

References: https://todo.sr.ht/~emersion/soju/17
2020-04-01 15:40:20 +02:00
Simon Ser
44d808be8d
Add a "network status" command 2020-03-25 22:57:48 +01:00
Simon Ser
448464b0e4
Make BouncerServ commands a tree
For instance, replace "create-network" with "network create".
2020-03-25 21:03:13 +01:00
delthas
37eb162b75 Add create-network bouncer service command 2020-03-19 01:14:44 +01:00
Simon Ser
e3d97bb164
Add basic infrastructure for bouncer service 2020-03-18 12:23:08 +01:00