106 Commits

Author SHA1 Message Date
contact
b487a7dff2 Use clientName to decide whether or not history should be sent
Closes: https://todo.sr.ht/~emersion/soju/31

git-svn-id: file:///srv/svn/repo/suika/trunk@185 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 16:36:09 +00:00
contact
40efde6626 Remove downstreamConn.username
Replace it with downstreamConn.user.Username

git-svn-id: file:///srv/svn/repo/suika/trunk@184 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 16:28:28 +00:00
contact
0e1223c13d Add downstreamConn.clientName
git-svn-id: file:///srv/svn/repo/suika/trunk@183 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 16:25:48 +00:00
contact
ac7553c1fb Update password on NickServ SET PASSWORD message
git-svn-id: file:///srv/svn/repo/suika/trunk@182 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 09:40:33 +00:00
contact
ec1777f84e s/List/LIST/ when referring to the command
git-svn-id: file:///srv/svn/repo/suika/trunk@181 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 00:03:00 +00:00
contact
5396567c1b Document functions safe to call from any goroutine
git-svn-id: file:///srv/svn/repo/suika/trunk@180 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 23:54:42 +00:00
contact
003b8f8ec6 Introduce eventUpstreamDisconnected
This allows us to perform cleanup actions in the user goroutine. This
removes the need for pendingLISTsLock.

git-svn-id: file:///srv/svn/repo/suika/trunk@179 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 23:51:58 +00:00
delthas
9aeb067b1b Add LIST support
This commit adds support for downstream LIST messages from multiple
concurrent downstreams to multiple concurrent upstreams, including
support for multiple pending LIST requests from the same downstream.

Because a unique RPL_LISTEND message must be sent to the requesting
downstream, and that there might be multiple upstreams, each sending
their own RPL_LISTEND, a cache of RPL_LISTEND replies of some sort is
required to match RPL_LISTEND together in order to only send one back
downstream.

This commit adds a list of "pending LIST" structs, which each contain a
map of all upstreams that yet need to send a RPL_LISTEND, and the
corresponding LIST request associated with that response. This list of
pending LISTs is sorted according to the order that the requesting
downstreams sent the LIST messages in. Each pending set also stores the
id of the requesting downstream, in order to only forward the replies to
it and no other downstream. (This is important because LIST replies can
typically amount to several thousands messages on large servers.)

When a single downstream makes multiple LIST requests, only the first
one will be immediately sent to the upstream servers. The next ones will
be buffered until the first one is completed. Distinct downstreams can
make concurrent LIST requests without any request buffering.

Each RPL_LIST message is forwarded to the downstream of the first
matching pending LIST struct.

When an upstream sends an RPL_LISTEND message, the upstream is removed
from the first matching pending LIST struct, but that message is not
immediately forwarded downstream. If there are no remaining pending LIST
requests in that struct is then empty, that means all upstreams have
sent back all their RPL_LISTEND replies (which means they also sent all
their RPL_LIST replies); so a unique RPL_LISTEND is sent to downstream
and that pending LIST set is removed from the cache.

Upstreams are removed from the pending LIST structs in two other cases:
- when they are closed (to avoid stalling because of a disconnected
upstream that will never reply to the LIST message): they are removed
from all pending LIST structs
- when they reply with an ERR_UNKNOWNCOMMAND or RPL_TRYAGAIN LIST reply,
which is typically used when a user is not allowed to LIST because they
just joined the server: they are removed from the first pending LIST
struct, as if an RPL_LISTEND message was received

git-svn-id: file:///srv/svn/repo/suika/trunk@177 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 23:07:20 +00:00
delthas
f8dc7b05a1 Make upstream.SendMessageLabeled use an uint64 id
This commit is preparatory work for code that will call
SendMessageLabeled with a direct downstream id rather than a
downstreamConnection pointer.

git-svn-id: file:///srv/svn/repo/suika/trunk@176 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 23:07:20 +00:00
contact
a17e0acde2 Stop accessing user data in downstreamConn.authenticate
This becomes racy once user.Password is updated on-the-fly.

git-svn-id: file:///srv/svn/repo/suika/trunk@173 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 21:38:38 +00:00
contact
d288ab6aad Nuke user.lock
Split user.register into two functions, one to make sure the user is
authenticated, the other to send our current state. This allows to get
rid of data races by doing the second part in the user goroutine.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@168 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 18:17:58 +00:00
contact
520585d901 Add eventDownstreamDisconnected
This should remove the need for protecting user.downstreamConns with a
mutex.

git-svn-id: file:///srv/svn/repo/suika/trunk@167 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 16:55:03 +00:00
contact
0def23b671 Add eventDownstreamConnected
In a later commit, we'll be able to move part of downstreamConn.register
into the user goroutine to prevent races.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@166 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 16:21:05 +00:00
contact
f4631f5dd6 Introduce a user.events channel
This allows to easily add new events, and also guarantees ordering
between different event types.

git-svn-id: file:///srv/svn/repo/suika/trunk@165 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 15:33:19 +00:00
delthas
43fd40bf31 Add downstream NOTICE support
git-svn-id: file:///srv/svn/repo/suika/trunk@164 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 08:40:51 +00:00
delthas
fc905bc9ed Add downstream INVITE support
git-svn-id: file:///srv/svn/repo/suika/trunk@163 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-26 21:43:48 +00:00
delthas
290366abfb Add upstream RPL_CREATIONTIME support
git-svn-id: file:///srv/svn/repo/suika/trunk@162 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-26 21:33:44 +00:00
delthas
9ba13fd38b Add downstream TOPIC support
git-svn-id: file:///srv/svn/repo/suika/trunk@160 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-26 21:27:46 +00:00
delthas
3318e3fbfe Add KICK support
Downstream and upstream message handling are slightly different because
downstreams can send KICK messages with multiple channels or users,
while upstreams can only send KICK messages with one channel and one
user (according to the RFC).

git-svn-id: file:///srv/svn/repo/suika/trunk@159 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 23:15:26 +00:00
delthas
8a4a0173a4 Simplify error handling for downstream JOIN/PART
downstreamConnection.unmarshalEntity already returns an ircError of
command ERR_NOSUCHCHANNEL, so there's no need to explicitly return
another ircError of that type.

git-svn-id: file:///srv/svn/repo/suika/trunk@158 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 23:12:53 +00:00
delthas
c0ddc1fec5 Route NAMES, WHO, WHOIS replies to the requesting downstream
Using labeled-response, the replies to several commands such as NAMES,
WHO, WHOIS can be routed back to a specific downstream, rather than
being broadcast to all downstreams.

For example, after this commit, if the server supports labeled-response,
if a downstream requests the NAMES or WHO or WHOIS of a channel, the
replies of the upstream will only be sent back to that downstream, and
the other downstreams won't receive these messages.

git-svn-id: file:///srv/svn/repo/suika/trunk@156 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:21:14 +00:00
delthas
472306d40a Add a server-unique id to each downstream
Adding a simple uint64 id to each downstream is preparatory work
for labeled-responses tags targeting a specific downstream.

git-svn-id: file:///srv/svn/repo/suika/trunk@154 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:17:46 +00:00
contact
dd844bdefc Add support for channel keys
git-svn-id: file:///srv/svn/repo/suika/trunk@146 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 10:54:08 +00:00
contact
3773283aa6 Handle downstream JOIN/PART with multiple channel names
Closes: https://todo.sr.ht/~emersion/soju/19

git-svn-id: file:///srv/svn/repo/suika/trunk@145 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 10:32:44 +00:00
contact
1f17d1a841 Consume ring buffer for networks added on-the-fly
git-svn-id: file:///srv/svn/repo/suika/trunk@144 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 10:28:25 +00:00
contact
d7d76f9c25 Move upstreamConn.ring to network
This handles upstream disconnection and re-connection better.

git-svn-id: file:///srv/svn/repo/suika/trunk@143 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 09:53:08 +00:00
delthas
55660bef2f Add downstream self WHO and WHOIS support
git-svn-id: file:///srv/svn/repo/suika/trunk@142 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 08:51:22 +00:00
delthas
65bb73bb52 Add user hostname to downstream user prefix
git-svn-id: file:///srv/svn/repo/suika/trunk@141 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 08:48:00 +00:00
delthas
b551c53872 Add downstream NAMES support
NAMES reply for channels currently joined will be returned from cache;
requests for channels not joined will be forwarded from upstream.

git-svn-id: file:///srv/svn/repo/suika/trunk@140 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 08:47:26 +00:00
delthas
ae9d1ebd3f Add MODE arguments support
- Add RPL_ISUPPORT support with CHANMODES, CHANTYPES, PREFIX parsing
- Add support for channel mode state with mode arguments
- Add upstream support for RPL_UMODEIS, RPL_CHANNELMODEIS
- Request channel MODE on upstream channel JOIN
- Use sane default channel mode and channel mode types

git-svn-id: file:///srv/svn/repo/suika/trunk@139 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 08:40:08 +00:00
contact
913e583b44 Add user.{add,remove}Downstream
git-svn-id: file:///srv/svn/repo/suika/trunk@137 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-23 15:05:00 +00:00
contact
b360940009 Add network.upstream helper
git-svn-id: file:///srv/svn/repo/suika/trunk@136 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-21 09:24:38 +00:00
contact
c6ee21b3c6 Fix typo
git-svn-id: file:///srv/svn/repo/suika/trunk@135 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-21 07:44:03 +00:00
contact
63d9b733a9 Fix empty SASL challenge message
We were sending an empty string. We need to send "+" instead.

git-svn-id: file:///srv/svn/repo/suika/trunk@134 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-21 07:41:14 +00:00
contact
a29ce6fc7d Avoid sending JOIN twice for the same channel
git-svn-id: file:///srv/svn/repo/suika/trunk@132 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-20 21:53:05 +00:00
contact
1577d3620c Move upstreamConn.history to network
git-svn-id: file:///srv/svn/repo/suika/trunk@131 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-20 21:48:17 +00:00
contact
4389f5de5b Fix deadlocks in single-upstream mode
git-svn-id: file:///srv/svn/repo/suika/trunk@130 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-20 09:42:17 +00:00
delthas
577365e189 Fix MODE downstream support
- Fix replies without client as first argument
- Replace wrong prefix check with a proper entity type check

git-svn-id: file:///srv/svn/repo/suika/trunk@129 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-20 09:11:27 +00:00
delthas
94d76ebfb4 Add WHOIS support
git-svn-id: file:///srv/svn/repo/suika/trunk@128 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-20 09:11:27 +00:00
delthas
522f2fe8a5 Add WHO support
git-svn-id: file:///srv/svn/repo/suika/trunk@127 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 23:29:03 +00:00
contact
b7f48f8766 Remove some IRCv3 constants
go-irc v3.1.2 adds some missing IRCv3 constants.

git-svn-id: file:///srv/svn/repo/suika/trunk@125 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 13:51:45 +00:00
contact
2030b6aefd Fix history name
dc.username contains the raw account username, not the username supplied
by the client.

git-svn-id: file:///srv/svn/repo/suika/trunk@124 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 13:44:49 +00:00
delthas
c4fc09cea0 Add create-network bouncer service command
git-svn-id: file:///srv/svn/repo/suika/trunk@120 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 00:14:44 +00:00
delthas
cbb0e4e8fa Add suffixing for multi-upstream connections
git-svn-id: file:///srv/svn/repo/suika/trunk@119 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-18 23:06:48 +00:00
contact
0504ff78cf Add basic infrastructure for bouncer service
git-svn-id: file:///srv/svn/repo/suika/trunk@117 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-18 11:23:08 +00:00
contact
57eaf243fa Fix typo
git-svn-id: file:///srv/svn/repo/suika/trunk@114 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-17 15:17:39 +00:00
contact
be09463daa Fix echo PRIVMSG messages
git-svn-id: file:///srv/svn/repo/suika/trunk@113 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-17 15:15:54 +00:00
contact
3edc848651 Add downstream SASL support
git-svn-id: file:///srv/svn/repo/suika/trunk@112 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-16 15:16:27 +00:00
contact
164a26f6b8 Allow CAP command when registered
git-svn-id: file:///srv/svn/repo/suika/trunk@111 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-16 14:12:46 +00:00
contact
6d755b782f Log downstream messages before registration
git-svn-id: file:///srv/svn/repo/suika/trunk@110 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-16 14:10:16 +00:00