37 Commits

Author SHA1 Message Date
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
6de426954b Add channel status service command
git-svn-id: file:///srv/svn/repo/suika/trunk@539 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 17:22:22 +00:00
ecs
e3c909c007 handleUserDelete: delete the correct user
Prior to this, we deleted the user issuing the deletion rather than the
user which should've been deleted.

git-svn-id: file:///srv/svn/repo/suika/trunk@508 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-22 08:37:05 +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
delthas
5843897b92 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" ...`

git-svn-id: file:///srv/svn/repo/suika/trunk@436 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-14 19:54:02 +00:00
contact
28c243adec 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

git-svn-id: file:///srv/svn/repo/suika/trunk@421 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 13:14:23 +00:00
contact
d6696ca80c Add user delete command
References: https://todo.sr.ht/~emersion/soju/17

git-svn-id: file:///srv/svn/repo/suika/trunk@379 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-10 13:04:01 +00:00
hubert
6293d8dfe9 Fix help message for BouncerServ's network update
It was missing the network name as first argument.

git-svn-id: file:///srv/svn/repo/suika/trunk@374 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-03 09:03:39 +00:00
contact
e0210a0ced Rename certfp reset to sasl reset
And make it reset all SASL credentials.

git-svn-id: file:///srv/svn/repo/suika/trunk@364 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-22 10:20:52 +00:00
contact
869942603b Add a sasl set-plain command
This allows to manually set the SASL credentials for a network.

git-svn-id: file:///srv/svn/repo/suika/trunk@363 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-22 10:16:13 +00:00
contact
c00ddb8ec3 Add unix as supported upstream URL scheme to service
git-svn-id: file:///srv/svn/repo/suika/trunk@358 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-09 10:19:51 +00:00
contact
35c7c0df7f Reply to WHO BouncerServ
Closes: https://todo.sr.ht/~emersion/soju/75

git-svn-id: file:///srv/svn/repo/suika/trunk@343 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:09:48 +00:00
contact
b371ea1bf2 service: list commands in lexicographic order
git-svn-id: file:///srv/svn/repo/suika/trunk@339 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-24 10:08:35 +00:00
contact
3b3d7c4f5a Fix missing appendServiceCommandSetHelp argument
git-svn-id: file:///srv/svn/repo/suika/trunk@335 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:34:45 +00:00
fox.cpp
c3141986b1 Do not panic if BouncerServ command without handler is sent
git-svn-id: file:///srv/svn/repo/suika/trunk@334 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:33:13 +00:00
kl
969469c37d 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@333 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-10 14:18:15 +00:00
delthas
6a71f953cb 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@329 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
ff63d3e24e 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@328 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
delthas
e853516870 Rename handleServiceCreateNetwork to handleServiceNetworkCreate
This renames handleServiceCreateNetwork for consistency with other
service commands.

git-svn-id: file:///srv/svn/repo/suika/trunk@325 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
contact
5aef4e44a8 Introduce ircConn
This interface will allow a conn to be backed by a websocket.

git-svn-id: file:///srv/svn/repo/suika/trunk@315 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 15:27:57 +00:00
contact
d7d1f89ecf 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

git-svn-id: file:///srv/svn/repo/suika/trunk@313 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 11:04:39 +00:00
fox.cpp
5f49770e07 Implement upstream SASL EXTERNAL support
Closes: https://todo.sr.ht/~emersion/soju/47

git-svn-id: file:///srv/svn/repo/suika/trunk@307 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-02 09:24:22 +00:00
contact
e74291b093 Remove network.upstream
This is an artifact from when we used locks. No need for this anymore.

git-svn-id: file:///srv/svn/repo/suika/trunk@279 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-30 08:25:16 +00:00
contact
eef5879a61 Abbreviate net status service reply
Don't print the nickname if it's the same as the downstream
connection's.

git-svn-id: file:///srv/svn/repo/suika/trunk@271 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 14:27:53 +00:00
delthas
67237abdea 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@270 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 09:41:13 +00:00
delthas
d94fe63d8a 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@269 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 09:41:13 +00:00
delthas
218af4327e 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).

git-svn-id: file:///srv/svn/repo/suika/trunk@263 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:38:47 +00:00
admin
017d8be225 Allow users to change password in client
Added a BouncerServ command for that.

git-svn-id: file:///srv/svn/repo/suika/trunk@252 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 08:16:25 +00:00
contact
60d04d512d Only print addr if necessary in network status service command
git-svn-id: file:///srv/svn/repo/suika/trunk@224 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-05 13:20:13 +00:00
delthas
ac110eaccc 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@220 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:34:30 +00:00
delthas
4ccc12d584 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

git-svn-id: file:///srv/svn/repo/suika/trunk@219 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:34:12 +00:00
delthas
c03e14ee9e 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

git-svn-id: file:///srv/svn/repo/suika/trunk@218 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:33:09 +00:00
contact
d317a87876 Add "network delete" service command
And add all the infrastructure required to stop and delete networks.

References: https://todo.sr.ht/~emersion/soju/17

git-svn-id: file:///srv/svn/repo/suika/trunk@202 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 13:40:20 +00:00
contact
23af40ce3d Add a "network status" command
git-svn-id: file:///srv/svn/repo/suika/trunk@151 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 21:57:48 +00:00
contact
d64a0f318a Make BouncerServ commands a tree
For instance, replace "create-network" with "network create".

git-svn-id: file:///srv/svn/repo/suika/trunk@150 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 20:03:13 +00:00
delthas
c4fc09cea0 Add create-network bouncer service command
git-svn-id: file:///srv/svn/repo/suika/trunk@120 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 00:14:44 +00:00
contact
0504ff78cf Add basic infrastructure for bouncer service
git-svn-id: file:///srv/svn/repo/suika/trunk@117 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-18 11:23:08 +00:00