825 Commits

Author SHA1 Message Date
contact
21656bbbc9 Fix race condition in upstreamConn.Close
upstreamConn.closed was a bool accessed from different goroutines. Use
the same pattern as downstreamConn instead.

git-svn-id: file:///srv/svn/repo/suika/trunk@175 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 22:08:35 +00:00
delthas
559a13f249 Fix parsing wrong empty element in RPL_WHOISCHANNELS channel list
Some servers add a trailing space to the channel list in
RPL_WHOISCHANNELS. This commit works around this issue by removing any
empty trailing element after splitting.

Since RPL_WHOISCHANNELS could send an empty channel parameter, we can't
just use strings.TrimRight(s, " "), because splitting on an empty string
would still return an empty element.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@174 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 21:53:21 +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
ff41376348 Get rid of Server.downstreamConns
This is unused right now. Let's remove it, we'll add it back if we
really need it.

git-svn-id: file:///srv/svn/repo/suika/trunk@172 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 21:24:12 +00:00
delthas
f81ecd67cf Marshal NOTICE user prefixes and channels
NOTICE messages can be both special messages from the server (with no
prefix nick), or regular PRIVMSG-like messages from users. This commit
adds support for marshaling channel and user prefixes in the latter
case.

git-svn-id: file:///srv/svn/repo/suika/trunk@171 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 20:12:16 +00:00
contact
f61efcbe80 doc: add basic architecture document
git-svn-id: file:///srv/svn/repo/suika/trunk@170 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 18:49:55 +00:00
contact
2e6e091858 Move man page to doc/
git-svn-id: file:///srv/svn/repo/suika/trunk@169 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 18:23:41 +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
781dafad76 Fix capitalization of 'id'
Following the Go project source code guidelines, id is an abbreviation
and must typically be written as id or ID, not Id.

git-svn-id: file:///srv/svn/repo/suika/trunk@161 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-26 21:28:13 +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
5229a8d800 Fix wrong handling of members parameter of RPL_NAMREPLY
Some servers (namely UnrealIRCd) wrongly add a trailing space to the
members parameters of the RPL_NAMREPLY command, which was not handled
correctly.

Adding a trailing space is not legal wrt the IRC specs, but since
UnrealIRCd does it and is in wide use today, we have to work around it.

git-svn-id: file:///srv/svn/repo/suika/trunk@157 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:21:26 +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
bbfb4636b2 Add upstream labeled-response capability support
git-svn-id: file:///srv/svn/repo/suika/trunk@155 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:20:56 +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
delthas
ad61922268 Add upstream batch capability support
git-svn-id: file:///srv/svn/repo/suika/trunk@153 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:16:53 +00:00
delthas
e6667d0b42 Add upstream message-tags capability support
git-svn-id: file:///srv/svn/repo/suika/trunk@152 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 22:15:48 +00:00
contact
23af40ce3d Add a "network status" command
git-svn-id: file:///srv/svn/repo/suika/trunk@151 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 21:57:48 +00:00
contact
d64a0f318a Make BouncerServ commands a tree
For instance, replace "create-network" with "network create".

git-svn-id: file:///srv/svn/repo/suika/trunk@150 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 20:03:13 +00:00
contact
9ffd959ce7 Correctly set Channel.ID in DB.StoreChannel
git-svn-id: file:///srv/svn/repo/suika/trunk@149 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 13:23:41 +00:00
contact
d4e5d3dfb4 Error out when storing unsupported SASL mechanism in DB
git-svn-id: file:///srv/svn/repo/suika/trunk@148 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 13:15:25 +00:00
contact
04123f6a5b gitignore: add soju.db and soju.1
git-svn-id: file:///srv/svn/repo/suika/trunk@147 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-25 12:44:32 +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
0b2b5420c9 Add more details to ring buffer panics
git-svn-id: file:///srv/svn/repo/suika/trunk@138 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-24 08:22:40 +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
9779857f91 Drop messages on closed connections
This prevents this panic:

    panic: send on closed channel
    goroutine 9 [running]:
    git.sr.ht/~emersion/soju.(*upstreamConn).SendMessage(...)
            /home/simon/src/soju/upstream.go:866
    git.sr.ht/~emersion/soju.(*upstreamConn).handleMessage(0xc000084b40, 0xc000144680, 0x2, 0x0)
            /home/simon/src/soju/upstream.go:152 +0x62b
    git.sr.ht/~emersion/soju.(*user).run(0xc0000b8070)
            /home/simon/src/soju/user.go:144 +0x53d
    created by git.sr.ht/~emersion/soju.(*Server).Run
            /home/simon/src/soju/server.go:88 +0x286

git-svn-id: file:///srv/svn/repo/suika/trunk@133 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-21 07:29:44 +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
af3a4050ee Add basic Makefile
git-svn-id: file:///srv/svn/repo/suika/trunk@126 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-19 14:11:43 +00:00