207 Commits

Author SHA1 Message Date
contact
ba0f309c71 Get rid of io.EOF errors in logs
Closes: https://todo.sr.ht/~emersion/soju/150

git-svn-id: file:///srv/svn/repo/suika/trunk@655 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-29 14:03:04 +00:00
contact
2748715183 Add context args to Database interface
This is a mecanical change, which just lifts up the context.TODO()
calls from inside the DB implementations to the callers.

Future work involves properly wiring up the contexts when it makes
sense.

git-svn-id: file:///srv/svn/repo/suika/trunk@652 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-18 17:15:15 +00:00
contact
7ed749a0c2 Unify away-notify and account-notify handling
git-svn-id: file:///srv/svn/repo/suika/trunk@649 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-17 19:54:18 +00:00
contact
cbf11ae498 Add support for account-notify
git-svn-id: file:///srv/svn/repo/suika/trunk@648 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-10-17 19:54:18 +00:00
contact
474d6e3ccd 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@568 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-25 18:33:13 +00:00
contact
ae0ac7c6f0 Allow admins to broadcast message to all bouncer users
Typically done via:

    /notice $<bouncer> <message>

Or, for a connection not bound to a specific network:

    /notice $* <message>

The message is broadcast as BouncerServ, because that's the only
user that can be trusted to belong to the bouncer by users. Any
other prefix would conflict with the upstream network.

git-svn-id: file:///srv/svn/repo/suika/trunk@563 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-23 17:23:09 +00:00
contact
645cae89bf Forward LUSERS and STATS messages after initial registration
git-svn-id: file:///srv/svn/repo/suika/trunk@561 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-23 09:45:14 +00:00
contact
d0fa8cd516 Add support for account-tag
git-svn-id: file:///srv/svn/repo/suika/trunk@559 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-14 19:44:38 +00:00
greg
594bd5bf30 Forward user mode changes in single-upstream mode
References: https://todo.sr.ht/~emersion/soju/20

git-svn-id: file:///srv/svn/repo/suika/trunk@553 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-10 09:17:00 +00:00
greg
be96d9078b Forward MOTD messages downstream
The first MOTD upon connection is ignored, but subsequent MOTD messages
(requested by the "MOTD" message from the client, typically using a
/motd command) are forwarded.

git-svn-id: file:///srv/svn/repo/suika/trunk@552 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-06-09 19:29:36 +00:00
contact
b4ffea243d Add support for IRCv3 setname
References: https://todo.sr.ht/~emersion/soju/41

git-svn-id: file:///srv/svn/repo/suika/trunk@540 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-25 18:24:45 +00:00
hubert
96082ecef8 Don't forward label tags
We don't want to have the label tag when calling uc.produce, otherwise
downstream will end up with junk labels.

git-svn-id: file:///srv/svn/repo/suika/trunk@526 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-05-23 10:32:27 +00:00
hubert
9b274dd916 Drop TAGMSG in detached channels
- Do not relay TAGMSG as notices,
- Do not reattach when a TAGMSG is received,
- Do not reset the detach timer when a TAGMSG is received.

git-svn-id: file:///srv/svn/repo/suika/trunk@505 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-20 14:17:28 +00:00
contact
edc4b60e04 Add user prefix to upstream logger
git-svn-id: file:///srv/svn/repo/suika/trunk@502 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 18:16:37 +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
ad0b3e4eb1 Move isHighlight to irc.go
git-svn-id: file:///srv/svn/repo/suika/trunk@498 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-04-13 16:54:58 +00:00
contact
83a6c849fd Save delivery receipts in DB
This avoids loosing history on restart for clients that don't
support chathistory.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@489 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-31 16:04:13 +00:00
contact
862be4f5b8 Rename user.clients to clientNames
This doesn't contain anything other than just the names. Make this
clearer.

git-svn-id: file:///srv/svn/repo/suika/trunk@487 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-30 10:44:56 +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
84b3a5d057 Move network.clients to user
No need to have this list per-network.

git-svn-id: file:///srv/svn/repo/suika/trunk@483 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-29 14:58:56 +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
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
df382ec139 Don't update downstream caps in upstream RPL_WELCOME handler
Prior to being registered, upstreamConn.handleMessage doesn't run
in the user goroutine, it runs in a goroutine specific to the
network. Thus we shouldn't access any user data structure from
there.

downstreamConn.updateSupportedCaps is already called from the
eventUpstreamConnected handler in user.run, the call being removed
was unnecessary.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@469 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-16 17:25:21 +00:00
contact
edca8b005f Don't store history for NickServ
Closes: https://todo.sr.ht/~emersion/soju/104

git-svn-id: file:///srv/svn/repo/suika/trunk@468 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-16 08:54:29 +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
d9616cc92a Properly handle all ISUPPORT negations
git-svn-id: file:///srv/svn/repo/suika/trunk@462 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 22:11:42 +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
contact
f21599af1d Maintain state for upstream ISUPPORT
git-svn-id: file:///srv/svn/repo/suika/trunk@460 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 22:06:36 +00:00
contact
8df7d55f30 Simplify if block in ISUPPORT handler
git-svn-id: file:///srv/svn/repo/suika/trunk@459 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 21:54:32 +00:00
contact
debb110ae8 Extract ISUPPORT CHANMODES/PREFIX to separate functions
git-svn-id: file:///srv/svn/repo/suika/trunk@458 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-15 21:53:46 +00:00
contact
37c710b832 Add Network.{URL,GetUsername,GetRealname}
Just a bunch of helpers that can be re-used.

git-svn-id: file:///srv/svn/repo/suika/trunk@457 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-03-09 17:55:34 +00:00
contact
266a158b44 Add irc to ALPN protocols
The new ALPN token has been approved [1]. We can start using it now.

[1]: https://mailarchive.ietf.org/arch/msg/tls-reg-review/i8YyT82XUtEgR-oXMG3sbyWYT8E/

git-svn-id: file:///srv/svn/repo/suika/trunk@455 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-24 18:41:12 +00:00
hubert
5864fdf0e6 if true return true else return false
Trivial improvement

git-svn-id: file:///srv/svn/repo/suika/trunk@454 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-02-18 08:40:51 +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
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
hubert
34cda63f5b Don't forward batch tags
We don't want to have the batch tag when calling uc.produce, otherwise
downstream will end up with junk batch ids.

git-svn-id: file:///srv/svn/repo/suika/trunk@443 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2021-01-10 21:48:08 +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
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
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
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
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
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
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
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