328 Commits

Author SHA1 Message Date
contact
b736ba981b Introduce the soju.im/bouncer-networks-notify capability
git-svn-id: file:///srv/svn/repo/suika/trunk@535 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
8ceceb932c Send network settings in LISTNETWORKS
git-svn-id: file:///srv/svn/repo/suika/trunk@534 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
66c64aa42f Add pass to bouncer network attributes
git-svn-id: file:///srv/svn/repo/suika/trunk@533 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
contact
f00821626a Implement the soju.im/bouncer-networks extension
git-svn-id: file:///srv/svn/repo/suika/trunk@532 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 14:42:51 +00:00
philipk
63e19e8add Directly return self-messages to user in multi-upstream mode
git-svn-id: file:///srv/svn/repo/suika/trunk@529 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-24 11:31:24 +00:00
contact
d5ca492750 Pass-through the BOT ISUPPORT token
References: https://github.com/ircv3/ircv3-specifications/pull/439

git-svn-id: file:///srv/svn/repo/suika/trunk@528 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-24 09:41:04 +00:00
hubert
2b8a6e1a59 Fix CAP LIST listing disabled capabilities
git-svn-id: file:///srv/svn/repo/suika/trunk@521 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-21 08:03:39 +00:00
contact
de72d133a9 Relay self-WHO/WHOIS in single-upstream mode
In multi-upstream mode, we can't relay WHO/WHOIS messages for the
current user, because we can't decide which upstream server the
message should be relayed to.

In single-upstream server, we do know which upstream server to use,
so we can just blindly relay the message.

This allows users to send a self-WHO/WHOIS to check their cloak and
other information.

git-svn-id: file:///srv/svn/repo/suika/trunk@520 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-20 09:13:14 +00:00
hubert
84c329faff Implement CHATHISTORY BETWEEN
git-svn-id: file:///srv/svn/repo/suika/trunk@516 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-18 08:44:10 +00:00
contact
0f0bc90e97 Add more context to chathistory errors
git-svn-id: file:///srv/svn/repo/suika/trunk@515 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-11 10:42:12 +00:00
hubert
fc31a8fa58 Don't directly reply to network-specific NICK
The NICK must only apply to the specific network, not to the downstream
connection.

git-svn-id: file:///srv/svn/repo/suika/trunk@512 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-30 10:17:23 +00:00
hubert
4c8f7cd0f3 Handle casemapping on BouncerServ
git-svn-id: file:///srv/svn/repo/suika/trunk@511 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-30 10:10:49 +00:00
contact
a958ddadee Relay detached channel backlog as BouncerServ NOTICE if necessary
Instead of ignoring detached channels wehn replaying backlog,
process them as usual and relay messages as BouncerServ NOTICEs
if necessary. Advance the delivery receipts as if the channel was
attached.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@499 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 17:11:05 +00:00
contact
562beca198 Skip backlog logic in downstreamConn.welcome on chathistory
git-svn-id: file:///srv/svn/repo/suika/trunk@496 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 15:50:03 +00:00
contact
e32cf2acd9 Take msg ID in sendTargetBacklog
git-svn-id: file:///srv/svn/repo/suika/trunk@495 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 15:49:37 +00:00
contact
00fbbb9d0d Use BARE for internal message IDs
This allows to have shorter and more future-proof IDs. This also
guarantees the IDs will only use reasonable ASCII characters (no
spaces), removing the need to encode them for PING/PONG tokens.

git-svn-id: file:///srv/svn/repo/suika/trunk@488 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-31 15:57:24 +00:00
contact
180e314a01 Make NickServ detection casemapping-aware
git-svn-id: file:///srv/svn/repo/suika/trunk@486 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-30 10:28:45 +00:00
contact
e94da85df6 Introduce deliveredStore
This hides the double-map complexity behind a dedicated type.

git-svn-id: file:///srv/svn/repo/suika/trunk@485 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 15:49:50 +00:00
contact
10a2f92f68 Ensure targets are case-mapped before being passed to messageStore
messageStore isn't aware of the network's case-mapping. We need
to canonicalize the names before passing them to messageStore.

git-svn-id: file:///srv/svn/repo/suika/trunk@484 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 15:07:39 +00:00
contact
a313a3aead Simplify network.offlineClients
Replace it with a list of all clients (online or offline).

git-svn-id: file:///srv/svn/repo/suika/trunk@482 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 14:55:57 +00:00
contact
2cba08b50e Introduce deliveredClientMap
Adds more semantics to map[string]string. Simplifies the complicated
mapStringStringCasemapMap type.

git-svn-id: file:///srv/svn/repo/suika/trunk@480 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-26 10:21:14 +00:00
hubert
3cad542811 Fix CHATHISTORY target not being casemapped
git-svn-id: file:///srv/svn/repo/suika/trunk@479 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-26 09:39:52 +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
contact
1f128ff7fc Improve ERR_NOSUCHCHANNEL error messages
References: https://todo.sr.ht/~emersion/soju/63

git-svn-id: file:///srv/svn/repo/suika/trunk@464 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-16 08:13:46 +00:00
contact
aba32b60ab Passthrough some ISUPPORT tokens
git-svn-id: file:///srv/svn/repo/suika/trunk@463 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 22:41:37 +00:00
contact
b8b77b8f0b Use upstream ISUPPORT map for NETWORK
git-svn-id: file:///srv/svn/repo/suika/trunk@461 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 22:08:19 +00:00
hubert
75dee80758 Send correct CHATHISTORY error messages
git-svn-id: file:///srv/svn/repo/suika/trunk@456 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-05 08:53:59 +00:00
contact
6ee586ea01 Introduce downstreamConn.sendTargetBacklog
git-svn-id: file:///srv/svn/repo/suika/trunk@452 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 12:48:41 +00:00
contact
77f0241cf5 Rename network.history to network.delivered
"History" is over-loaded with e.g. CHATHISTORY support.

git-svn-id: file:///srv/svn/repo/suika/trunk@451 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 10:31:34 +00:00
contact
5c1bf5b701 Rename sendNetworkHistory to sendNetworkBacklog
"History" is a little bit over-loaded with CHATHISTORY support.

git-svn-id: file:///srv/svn/repo/suika/trunk@450 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-10 09:23:51 +00:00
hubert
f5d025bd79 Request invite-notify to upstreams
... and do not forward INVITEs to downstreams that do not support the
capability.

The downstream capability can be permanent because there is no way for a
client to get the list of people invited to a channel, thus no state can
be corrupted.

git-svn-id: file:///srv/svn/repo/suika/trunk@448 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-31 21:18:51 +00:00
contact
24d2196f8d Forward ISUPPORT NETWORK token
git-svn-id: file:///srv/svn/repo/suika/trunk@447 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-22 11:00:38 +00:00
contact
004e7a4a18 Send RPL_ISUPPORT CHATHISTORY token
git-svn-id: file:///srv/svn/repo/suika/trunk@446 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-22 10:55:06 +00:00
contact
c94290b989 Make chat history operations optional in messageStore
Some stores may want not to implement chat history operations.

git-svn-id: file:///srv/svn/repo/suika/trunk@441 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-04 16:17:35 +00:00
contact
c1308993f8 Add store-agnostic message ID format
Allow to query the network ID and entity from the message ID regardless
of the underlying store used.

git-svn-id: file:///srv/svn/repo/suika/trunk@440 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-04 15:26:30 +00:00
hubert
b1d4fde2f5 Improve dc.authenticate()'s error messages
git-svn-id: file:///srv/svn/repo/suika/trunk@438 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-25 12:37:15 +00:00
hubert
ee16ab9833 Advertise all caps, CAP DEL them on registration
... so that the JOIN/history batch takes into account all capabilities.
Without this commit for example, enabling multi-prefix after the batch
makes the client send NAMES requests for all channels, which generate
needless traffic.

git-svn-id: file:///srv/svn/repo/suika/trunk@437 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-25 12:35:20 +00:00
delthas
638a2229cb Add customizable auto-detaching, auto-reattaching, relaying.
This uses the fields added previously to the Channel struct to implement
the actual detaching/reattaching/relaying logic.

The `FilterDefault` values of the messages filters are currently
hardcoded.

The values of the message filters are not currently user-settable.

This introduces a new user event, eventChannelDetach, which stores an
upstreamConn (which might become invalid at the time of processing), and
a channel name, used for auto-detaching. Every time the channel detach
timer is refreshed (by receveing a message, etc.), a new timer is
created on the upstreamChannel, which will dispatch this event after the
duration (and discards the previous timer, if any).

git-svn-id: file:///srv/svn/repo/suika/trunk@435 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-12-14 19:54:02 +00:00
hubert
2f7629e4f7 Uphold echo-message even with BouncerServ
Fixes <https://todo.sr.ht/~emersion/soju/74>

git-svn-id: file:///srv/svn/repo/suika/trunk@431 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-11-24 13:25:19 +00:00
contact
92f6ab3b7e Fix nickname in ERR_ERRONEOUSNICKNAME
git-svn-id: file:///srv/svn/repo/suika/trunk@430 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-11-24 13:22:39 +00:00
hubert
1f2dc3a9a1 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".

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