229 Commits

Author SHA1 Message Date
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
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
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
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
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
2ebc03a712 Change unix:// to irc+unix://
When Unix socket support will be added for listeners, unix:// will be
ambiguous. It won't be clear whether to setup an IRC server, or some
other kind of server (e.g. identd).

unix:// is still recognized to avoid breaking existing DBs.

git-svn-id: file:///srv/svn/repo/suika/trunk@369 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-22 13:44:19 +00:00
contact
dddac6e178 Broadcast unhandled messages to downstream connections
In case labelled-response isn't supported, broadcast unhandled messages
to all downstream connections. That's better than silently dropping the
messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@355 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-08 16:21:52 +00:00
contact
e55e59080e Add support for upstream Unix socket connections
References: https://todo.sr.ht/~emersion/soju/51

git-svn-id: file:///srv/svn/repo/suika/trunk@353 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-06 15:31:11 +00:00
contact
e4b56520f9 Parse upstream URLs with net/url
This allows us to ignore the path part of the URL. This is preliminary
work for unix URLs.

git-svn-id: file:///srv/svn/repo/suika/trunk@352 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-06 15:18:13 +00:00
contact
04309085c4 Check upstream address with net.SplitHostPort
Looking for a colon is incorrect, IPv6 addresses can contain colons too.

git-svn-id: file:///srv/svn/repo/suika/trunk@351 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-06 14:04:56 +00:00
contact
1a16d0b47a Sort and split JOIN messages
Sort channels so that channels with a key appear first. Split JOIN
messages so that we don't reach the message size limit.

git-svn-id: file:///srv/svn/repo/suika/trunk@350 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-06 09:06:20 +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
929f7b48c6 Handle registration failures
References: https://todo.sr.ht/~emersion/soju/30

git-svn-id: file:///srv/svn/repo/suika/trunk@342 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 15:52:49 +00:00
delthas
a97dcd348b Fix sending messages from detached channels
Currently, a downstream receives MODE, RPL_CHANNELMODEIS and
RPL_CREATIONTIME messages from soju for detached channels. It should not
be sent any of these messages.

This adds a detach check to the handling of these messages to avoid
receiving these messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@338 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-12 12:43:45 +00:00
contact
f38af41317 Add support for WebSocket connections
WebSocket connections allow web-based clients to connect to IRC. This
commit implements the WebSocket sub-protocol as specified by the pending
IRCv3 proposal [1].

WebSocket listeners can now be set up via a "wss" protocol in the
`listen` directive. The new `http-origin` directive allows the CORS
allowed origins to be configured.

[1]: https://github.com/ircv3/ircv3-specifications/pull/342

git-svn-id: file:///srv/svn/repo/suika/trunk@323 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-07 12:13:46 +00:00
fox.cpp
69e7615895 Fix handling of empty response to SASL challenge
git-svn-id: file:///srv/svn/repo/suika/trunk@318 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 09:35:43 +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
cc7baf5863 Only send JOIN message if we have channels to join
Don't send a JOIN command to upstream server when no channels are configured.

git-svn-id: file:///srv/svn/repo/suika/trunk@310 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-03 15:18:57 +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
ecs
bd6074df78 Join all channels with a single JOIN message
git-svn-id: file:///srv/svn/repo/suika/trunk@305 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-28 14:26:28 +00:00
delthas
0f15604644 Fix parsing upstream RPL_INVITING messages
Previously, we did not skip the first RPL_INVITING parameter, which is
the user nick (like in all replies), which made the parsing for that
reply incorrect.

This fixes RPL_INVITING parsing by skipping the first parameter.

git-svn-id: file:///srv/svn/repo/suika/trunk@304 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:51:44 +00:00
delthas
dd583107cd Add support for TAGMSG and client message tags
Previously we dropped all TAGMSG as well as any client message tag sent
from downstream.

This adds support for properly forwarding TAGMSG and client message tags
from downstreams and upstreams.

TAGMSG messages are intentionally not logged, because they are currently
typically used for +typing, which can generate a lot of traffic and is
only useful for a few seconds after it is sent.

git-svn-id: file:///srv/svn/repo/suika/trunk@303 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:48:08 +00:00
delthas
85d6b50f07 Forward all labeled errors and unknown messages to their downstream
This adds support for forwarding all errors and unknown messages labeled
with a specific downstream to that downstream.

Provided that the upstream supports labeled-response, users will now be
able to receive an error only on their client when making a command that
returns an error, as well as receiving any reply unknown to soju.

git-svn-id: file:///srv/svn/repo/suika/trunk@302 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:47:49 +00:00
delthas
d4088ba6a9 Add support for upstream ban, invite, and exception lists
This does not try to marshal nicks in masks, for simplicity and
consistency with the current behaviour of marshaling MODE messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@300 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:45:13 +00:00
delthas
fe27882fd8 Update downstream nicks in single-server mode and after NICK
Previously, the downstream nick was never changed, even when the
downstream sent a NICK message or was in single-server mode with a
different nick.

This adds support for updating the downstream nick in the following
cases:
- when a downstream sends NICK
- additionally, in single-server mode:
  - when a downstream connects and its single network is connected
  - when an upstream connects
  - when an upstream sends NICK

git-svn-id: file:///srv/svn/repo/suika/trunk@296 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:42:38 +00:00
delthas
5740d21ec1 Fix sending CAP END twice when SASL is not used
When SASL is not used, we should only send CAP END after we send a CAP
REQ. Previously CAP END was sent both after a CAP REQ and a CAP ACK,
resulting in two CAP END messages.

Sending a CAP END right after the CAP REQ rather than waiting for the
CAP ACK/NAK saves 1 RTT.

git-svn-id: file:///srv/svn/repo/suika/trunk@295 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-21 20:38:07 +00:00
delthas
087d9b5493 Fix a null access due to assigning nil to the member memberships map
Even though the memberships map has type map[string]*memberships
(with memberships being defined as []membership), the default value for
that map should not be `nil` but a pointer to a nil slice.

This fixes a segfault on some servers before user channel prefixes are
sent.

git-svn-id: file:///srv/svn/repo/suika/trunk@294 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-21 20:37:37 +00:00