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
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
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
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
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
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
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
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
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
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
Previously, we only considered channel modes in the modes of a MODE
messages, which means channel membership changes were ignored. This
resulted in bugs where users channel memberships would not be properly
updated and cached with wrong values. Further, mode arguments
representing entities were not properly marshaled.
This adds support for correctly parsing and updating channel memberships
when processing MODE messages. Mode arguments corresponding to channel
memberships updates are now also properly marshaled.
MODE messages can't be easily sent from history because marshaling these
messages require knowing about the upstream available channel types and
channel membership types, which is currently only possible when
connected. For now this is not an issue since we do not send MODE
messages in history.
git-svn-id: file:///srv/svn/repo/suika/trunk@293 f0ae65fe-ee39-954e-97ec-027ff2717ef4
User channel memberships are actually a set of memberships, not a single
value. This introduces memberships, a type representing a set of
memberships, stored as an array of memberships ordered by descending
rank.
This also adds multi-prefix to the permanent downstream and upstream
capabilities, so that we try to get all possible channel memberships.
git-svn-id: file:///srv/svn/repo/suika/trunk@292 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Channels can now be detached by leaving them with the reason "detach",
and re-attached by joining them again. Upon detaching the channel is
no longer forwarded to downstream connections. Upon re-attaching the
history buffer is sent.
git-svn-id: file:///srv/svn/repo/suika/trunk@284 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Instead of adding one field per capability, let's just have a map, just
like downstreamConn.
git-svn-id: file:///srv/svn/repo/suika/trunk@278 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This makes use of cap-notify to dynamically advertise support for
away-notify. away-notify is advertised to downstream connections if all
upstreams support it.
git-svn-id: file:///srv/svn/repo/suika/trunk@276 f0ae65fe-ee39-954e-97ec-027ff2717ef4
We should broadcast the message, not send it to a specific downstream
connection.
git-svn-id: file:///srv/svn/repo/suika/trunk@274 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Some servers do not support TLS, or have invalid, expired or self-signed
TLS certificates. While the right fix would be toi contact each server
owner to add support for valid TLS, supporting plaintext upstream
connections is sometimes necessary.
This adds support for the irc+insecure address scheme, which connects to
a network in plain-text over TCP.
git-svn-id: file:///srv/svn/repo/suika/trunk@270 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This is preparatory work for adding other connection types to upstream
servers. The service command `network create` now accepts a scheme in
the address flag, which specifies how to connect to the upstream server.
The only supported scheme for now is ircs, which is also the default if
no scheme is specified. ircs connects to a network over a TLS TCP
connection.
git-svn-id: file:///srv/svn/repo/suika/trunk@269 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Store the list of configured channels in the network data structure.
This removes the need for a database lookup and will be useful for
detached channels.
git-svn-id: file:///srv/svn/repo/suika/trunk@267 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Some servers use custom IRC bots with custom commands for registering to
specific services after connection.
This adds support for setting custom raw IRC messages, that will be
sent after registering to a network.
It also adds support for a custom flag.Value type for string
slice flags (flags taking several string values).
git-svn-id: file:///srv/svn/repo/suika/trunk@263 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This will be used when sending history while upstream is disconnected.
git-svn-id: file:///srv/svn/repo/suika/trunk@260 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Instead of having one ring buffer per network, each network has one ring
buffer per entity (channel or nick). This allows history to be more
fair: if there's a lot of activity in a channel, it won't prune activity
in other channels.
We now track history sequence numbers per client and per network in
networkHistory. The overall list of offline clients is still tracked in
network.offlineClients.
When all clients have received history, the ring buffer can be released.
In the future, we should get rid of too-old offline clients to avoid
having to maintain history for them forever. We should also add a
per-user limit on the number of ring buffers.
git-svn-id: file:///srv/svn/repo/suika/trunk@253 f0ae65fe-ee39-954e-97ec-027ff2717ef4
There's no reason why messgeLogger needs access to the whole connection,
the network is enough.
git-svn-id: file:///srv/svn/repo/suika/trunk@248 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This allows messages added to logs to be handled just like messages
added to the ring buffer.
git-svn-id: file:///srv/svn/repo/suika/trunk@245 f0ae65fe-ee39-954e-97ec-027ff2717ef4
- uc.nicl was compared to msg.Prefix.Name after being updated to the new
nick
- The new nick wasn't marshaled
git-svn-id: file:///srv/svn/repo/suika/trunk@244 f0ae65fe-ee39-954e-97ec-027ff2717ef4
We no longer need long-lived ring buffer consumers now that
upstreamConn.produce dispatches messages to downstream connections.
git-svn-id: file:///srv/svn/repo/suika/trunk@231 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Just dispatch from the user goroutine. This allows removes a lot of complexity.
git-svn-id: file:///srv/svn/repo/suika/trunk@227 f0ae65fe-ee39-954e-97ec-027ff2717ef4
The logic in this function is about to get more complicated. It'll soon
also dispatch messages in connected downstreams.
git-svn-id: file:///srv/svn/repo/suika/trunk@226 f0ae65fe-ee39-954e-97ec-027ff2717ef4
Since the logging refactoring in 27e090, entityLog is not used anymore
and can be removed.
git-svn-id: file:///srv/svn/repo/suika/trunk@221 f0ae65fe-ee39-954e-97ec-027ff2717ef4
In order to notify the user when we are disconnected from a network
(either due to an error, or due a QUIT), and when we fail reconnecting,
this commit adds support for sending a short NOTICE message from the
service user to all relevant downstreams.
The last error is stored, and cleared on successful connection, to
ensure that the user is *not* flooded with identical connection error
messages, which can often happen when a server is down.
No lock is needed on lastError because it is only read and modified from
the user goroutine.
Closes: https://todo.sr.ht/~emersion/soju/27
git-svn-id: file:///srv/svn/repo/suika/trunk@218 f0ae65fe-ee39-954e-97ec-027ff2717ef4