586c7ee3 — Kalyan Sriram a day ago master
sojuctl: change-password: check if user exists

When changing the password, checks if the user exists *before* prompting
for a password change, instead of after.
Uphold echo-message even with BouncerServ

Fixes <https://todo.sr.ht/~emersion/soju/74>
Prevent downstreams from changing their nick to service's

This commit prevents downstream from sending those commands:
- NICK BouncerServ
- NICK BouncerServ/<network>

The later is necessary because soju would otherwise save the nick change
and, in the event that the downstream connects in single-upstream mode
to <network>, it will end up with the nickname "BouncerServ".
Implement delivery receipts via PING messages

This patch implements basic message delivery receipts via PING and PONG.

When a PRIVMSG or NOTICE message is sent, a PING message with a token is
also sent. The history cursor isn't immediately advanced, instead the
bouncer will wait for a PONG message before doing so.

Self-messages trigger a PING for simplicity's sake. We can't immediately
advance the history cursor in this case, because a prior message might
still have an outstanding PING.

Future work may include optimizations such as removing the need to send
a PING after a self-message, or groupping multiple PING messages

Closes: https://todo.sr.ht/~emersion/soju/11
Don't send TAGMSG to upstreams that don't support it

TAGMSG are (in current specs and drafts from IRCv3) only used for
client tags. These are optional information by design (since they are
not distributed to all users), therefore it is preferable to discard
them accordingly to upstream, instead of waiting for all upstreams to
support the capability to advertise it.
Don't accept any IP as a proxy by default

It's too easy to setup a reverse proxy which doesn't support the PROXY
protocol, or lets the X-Forwarded-For header fields pass through.
Disable this by default.

To restore the previous behaviour, add `accept-proxy-ip localhost` to
the config file.
Upgrade dependencies
Switch to go-scfg

We don't use child directives yet, but likely will in the future.
Add message store abstraction

Introduce a messageStore type, which will allow for multiple
implementations (e.g. in the DB or in-memory instead of on-disk).

The message store is per-user so that we don't need to deal with locking
and it's easier to implement per-user limits.
Switch to sql.NullString

Not really better than what we had before, however new contributors will
maybe be familiar with it.
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
Add id column to User table

We used rowid before, but an explicit ID column is cleaner.
Add support for the extended-join capability

This simple implementation only advertises extended-join to downstreams
when all upstreams support it.

In the future, it could be modified so that soju buffers incoming
upstream JOINs, sends a WHO, waits for the reply, and sends an extended
join to the downstream; so that soju could advertise that capability
even when some or all upstreams do not support it. This is not the case
in this commit.
Add support for the PROXY protocol

IPs whitelisted in accept-proxy-ip can now use the PROXY protocol to
indicate the original source/destination addresses.

Closes: https://todo.sr.ht/~emersion/soju/81
Set Server.AcceptProxyIPs
7310f67f — Hubert Hirtz 2 months ago
Make DB.DeleteChannel take the channel ID

... to allow the caller to correctly do any necessary casemapping.
42828d68 — Hubert Hirtz 2 months ago
Make sure that WebSocket messages are valid UTF-8

... by replacing invalid bytes with the REPLACEMENT CHARACTER U+FFFD

This is better than:
- discarding the whole message, since the user would not see it...
- removing invalid bytes, since the user would not see their presence,
- converting the encoding (this is actually not possible).

Contrary to its documentation, strings.ToValidUTF8 doesn't copy the
string if it's valid UTF-8:
Don't update history when msgID is empty in appendLog

Log files don't record all message types. If the message isn't inserted
in the log file, don't update the history cursors for downstream
Fix panic in downstreamConn.sendNetworkHistory

This panic happens when sending history to a multi-upstream client.
sendNetworkHistory is called on each network, but dc.network is nil.

Closes: https://todo.sr.ht/~emersion/soju/93
Fix downstream PING argument handling

The PONG message should have these arguments:

- Our server name
- The PING message's source name

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