778 Commits

Author SHA1 Message Date
contact
1735c59993 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
together.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@428 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-11-24 13:13:24 +00:00
hubert
3cabab7275 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@427 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-11-20 10:37:43 +00:00
contact
55806cb0b0 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@426 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-25 17:22:12 +00:00
contact
913aa6a8a6 Upgrade dependencies
git-svn-id: file:///srv/svn/repo/suika/trunk@425 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-25 17:15:54 +00:00
contact
9ff097eeed Switch to go-scfg
We don't use child directives yet, but likely will in the future.

git-svn-id: file:///srv/svn/repo/suika/trunk@424 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-25 17:10:50 +00:00
contact
2010feb337 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@423 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-25 16:47:38 +00:00
contact
5da0737bb4 Switch to sql.NullString
Not really better than what we had before, however new contributors will
maybe be familiar with it.

git-svn-id: file:///srv/svn/repo/suika/trunk@422 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 13:47:53 +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
9f4e3bad1b Add id column to User table
We used rowid before, but an explicit ID column is cleaner.

git-svn-id: file:///srv/svn/repo/suika/trunk@420 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-10-24 12:52:55 +00:00
delthas
56f2464404 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@419 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-10 22:10:58 +00:00
contact
40d0ab8c62 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

git-svn-id: file:///srv/svn/repo/suika/trunk@418 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-07 19:28:24 +00:00
contact
1c6e0cabf5 Set Server.AcceptProxyIPs
git-svn-id: file:///srv/svn/repo/suika/trunk@417 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-07 18:58:49 +00:00
hubert
8ca570988a Make DB.DeleteChannel take the channel ID
... to allow the caller to correctly do any necessary casemapping.

git-svn-id: file:///srv/svn/repo/suika/trunk@416 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-07 09:40:18 +00:00
hubert
e6d1490b49 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:
<https://golang.org/src/strings/strings.go?s=15815:15861#L623>

git-svn-id: file:///srv/svn/repo/suika/trunk@415 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-09-02 15:09:32 +00:00
contact
0c8fa71ada 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
connections.

git-svn-id: file:///srv/svn/repo/suika/trunk@414 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-28 11:35:55 +00:00
contact
b844d9f7bd 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

git-svn-id: file:///srv/svn/repo/suika/trunk@413 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-26 13:28:10 +00:00
contact
f9a89d4f22 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

git-svn-id: file:///srv/svn/repo/suika/trunk@412 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-26 13:18:57 +00:00
contact
d5af5da512 Allow '/' in nickname
This allows to specify a network name in the nickname.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@411 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-25 09:49:22 +00:00
contact
1651025402 Update dependencies
git-svn-id: file:///srv/svn/repo/suika/trunk@410 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-24 17:05:56 +00:00
contact
922e9512f2 Nuke in-memory ring buffer
Instead, always read chat history from logs. Unify the implicit chat
history (pushing history to clients) and explicit chat history
(via the CHATHISTORY command).

Instead of keeping track of ring buffer cursors for each client, use
message IDs.

If necessary, the ring buffer could be re-introduced behind a
common MessageStore interface (could be useful when on-disk logs are
disabled).

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

git-svn-id: file:///srv/svn/repo/suika/trunk@409 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 18:05:01 +00:00
contact
a0994a843d Introduce loadHistoryLatestID
This loads latest messages from logs up to a given message ID. This is
similar to the IRCv3 CHATHISTORY LATEST command [1].

[1]: 0c271a5f1d/extensions/chathistory.md (latest)

git-svn-id: file:///srv/svn/repo/suika/trunk@408 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 18:05:01 +00:00
contact
42ce282232 Introduce internal message IDs
For now, these can be used as cursors in the logs. Future patches will
introduce functions that perform log queries with message IDs.

The IDs are state-less tokens containing all the required information to
refer to an on-disk log line: network name, entity name, date and byte
offset. The byte offset doesn't need to point to the first byte of the
line, any byte will do (note, this makes it so message IDs aren't
necessarily unique, we may want to change that in the future).

These internal message IDs are not exposed to clients because we don't
support upstream message IDs yet.

git-svn-id: file:///srv/svn/repo/suika/trunk@407 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 18:05:01 +00:00
contact
1e0a17e1e9 Replace networkHistory.offlineClients with clients
Keep the ring buffer alive even if all clients are connected. Keep the
ID of the latest delivered message even for online clients.

As-is, this is a net downgrade: memory usage increases because ring
buffers aren't free'd anymore. However upcoming commits will replace the
ring buffer with log files. This change makes reading from log files
easier.

git-svn-id: file:///srv/svn/repo/suika/trunk@406 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 15:38:57 +00:00
hubert
4fcc1638f0 Forward RPL_TOPICWHOTIME to downstreams
git-svn-id: file:///srv/svn/repo/suika/trunk@405 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 09:12:54 +00:00
hubert
d102dd2fa0 Reject downstream NICK with illegal characters
This should avoid confusion when mixing up nickname and user name.
Also it avoid breaking downstreams (since '@' and '!' are used for host
masks).

git-svn-id: file:///srv/svn/repo/suika/trunk@404 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 08:00:58 +00:00
hubert
686edb6bbd Fix marshalling of channel name in RPL_CREATIONTIME
git-svn-id: file:///srv/svn/repo/suika/trunk@403 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 07:15:47 +00:00
contact
a3c470c0fd go fmt
git-svn-id: file:///srv/svn/repo/suika/trunk@402 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 07:13:56 +00:00
hubert
f95079a5b7 More explicit error message on INVITE with the wrong network
git-svn-id: file:///srv/svn/repo/suika/trunk@401 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-20 07:13:38 +00:00
hubert
da24989ccf More explicit error message on KICK with the wrong network
git-svn-id: file:///srv/svn/repo/suika/trunk@400 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 21:57:25 +00:00
contact
5f7e385a0e Improve registration error messages
- Don't print the raw IRC message, since we already show the original
  error message
- Avoid double-printing "registration failed"

git-svn-id: file:///srv/svn/repo/suika/trunk@399 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 21:35:12 +00:00
contact
5ae82a781a Implement rate limiting for upstream messages
Allow up to 10 outgoing messages in a burst, then throttle to 1 message
each 2 seconds.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@398 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 17:42:33 +00:00
contact
440f06c282 Escape user/network/entity characters in log file path
ZNC replaces slashes and backslashes with a dashes.

git-svn-id: file:///srv/svn/repo/suika/trunk@397 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 10:22:32 +00:00
contact
79ae95be13 Strip message tags in error message
The time tag was causing the registration error messages to be
continuously sent to downstream connections.

git-svn-id: file:///srv/svn/repo/suika/trunk@396 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 09:50:19 +00:00
contact
4ab774fcd4 Encode idents to hex instead of base64
base64 strings may contain characters rejected by ident clients such
as "+". Use hex encoding and shorten the string a little.

git-svn-id: file:///srv/svn/repo/suika/trunk@395 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-19 09:24:25 +00:00
contact
143f8d8f90 ident: remove leftover debug log
git-svn-id: file:///srv/svn/repo/suika/trunk@394 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-18 15:57:12 +00:00
dan.shick
10e3974799 Fix store user query values
git-svn-id: file:///srv/svn/repo/suika/trunk@393 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-17 22:26:59 +00:00
contact
bca99f433a Format CTCP ACTION messages in logs
git-svn-id: file:///srv/svn/repo/suika/trunk@392 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-17 13:01:53 +00:00
contact
b657817a8a Parse NOTICE messages from logs
git-svn-id: file:///srv/svn/repo/suika/trunk@391 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-17 11:55:22 +00:00
contact
01ab1f06b8 Handle upstream ERROR messages
git-svn-id: file:///srv/svn/repo/suika/trunk@390 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-13 13:31:07 +00:00
contact
5bcf511d5c Handle ERR_NOPERMFORHOST and ERR_YOUREBANNEDCREEP
git-svn-id: file:///srv/svn/repo/suika/trunk@389 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-13 13:31:03 +00:00
contact
fd15fd5482 Add missing ident.go
Forgot to check in this file.

Fixes: 65302d3c1e8e ("Add an ident server")

git-svn-id: file:///srv/svn/repo/suika/trunk@388 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-13 10:58:29 +00:00
contact
c7e29a966a Extract history loading into functions
These will get re-used for sending history to clients that don't support
the chathistory extension.

git-svn-id: file:///srv/svn/repo/suika/trunk@387 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 13:58:50 +00:00
contact
4b7854b268 doc: add ident server to man page
git-svn-id: file:///srv/svn/repo/suika/trunk@386 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 09:03:20 +00:00
contact
d4a0c5bd48 Add an ident server
Closes: https://todo.sr.ht/~emersion/soju/69

git-svn-id: file:///srv/svn/repo/suika/trunk@385 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:59:06 +00:00
contact
7fce9bcc76 Add conn.{Local,Remote}Addr
git-svn-id: file:///srv/svn/repo/suika/trunk@384 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:35:05 +00:00
contact
9880c34024 Add ircConn.LocalAddr
git-svn-id: file:///srv/svn/repo/suika/trunk@383 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:34:38 +00:00
contact
aa04c4bf88 Add User.ID
For now it's just a new field that'll be useful to generate user ident
strings. It uses the SQLite implicit rowid column. In the future the DB
interface will need to be updated to use user IDs instead of usernames.

git-svn-id: file:///srv/svn/repo/suika/trunk@382 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:26:42 +00:00
contact
f1aa33eb16 Don't perform TLS handshake in connectToUpstream
This defers TLS handshake until the first read or write operation. This
allows the upcoming identd server to register the connection before the
TLS handshake is complete, and is necessary because some IRC servers
send an ident request before that.

git-svn-id: file:///srv/svn/repo/suika/trunk@381 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:24:54 +00:00
contact
d000ec491a cmd/sojuctl: read user from DB before updating it
This makes sure we don't overwrite other fields, such as Admin.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@380 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-08-11 08:21:49 +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