Commit Graph

490 Commits

Author SHA1 Message Date
delthas
3b6e175365
Add upstream RPL_CREATIONTIME support 2020-03-26 22:33:44 +01:00
delthas
a018f35c42
Add downstream TOPIC support 2020-03-26 22:27:46 +01:00
delthas
bab26c7a6f
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).
2020-03-26 00:15:26 +01:00
delthas
9b7309d4c9
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.
2020-03-26 00:12:53 +01:00
delthas
6e72071716
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.
2020-03-25 23:21:14 +01:00
delthas
d0917f0fa1
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.
2020-03-25 23:17:46 +01:00
Simon Ser
33dacc4fb0
Add support for channel keys 2020-03-25 11:54:08 +01:00
Simon Ser
146906ef6b
Handle downstream JOIN/PART with multiple channel names
Closes: https://todo.sr.ht/~emersion/soju/19
2020-03-25 11:32:44 +01:00
Simon Ser
21241c2009
Consume ring buffer for networks added on-the-fly 2020-03-25 11:28:25 +01:00
Simon Ser
293a0e8e20
Move upstreamConn.ring to network
This handles upstream disconnection and re-connection better.
2020-03-25 10:53:08 +01:00
delthas
9486d657c5
Add downstream self WHO and WHOIS support 2020-03-25 09:51:22 +01:00
delthas
a958a01446
Add user hostname to downstream user prefix 2020-03-25 09:48:00 +01:00
delthas
9ff8429a53
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.
2020-03-25 09:47:26 +01:00
delthas
98a95e9955
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
2020-03-25 09:40:08 +01:00
Simon Ser
015281ed35
Add user.{add,remove}Downstream 2020-03-23 16:05:00 +01:00
Simon Ser
c511a3c895
Add network.upstream helper 2020-03-21 10:24:38 +01:00
Simon Ser
4b9168196a
Fix typo 2020-03-21 08:44:03 +01:00
Simon Ser
ec98c6f04f
Fix empty SASL challenge message
We were sending an empty string. We need to send "+" instead.
2020-03-21 08:41:14 +01:00
Simon Ser
7114c8a1e9
Avoid sending JOIN twice for the same channel 2020-03-20 22:53:05 +01:00
Simon Ser
45d118dd12
Move upstreamConn.history to network 2020-03-20 22:48:17 +01:00
Simon Ser
7714c84669
Fix deadlocks in single-upstream mode 2020-03-20 10:42:17 +01:00
delthas
aedf66c73d Fix MODE downstream support
- Fix replies without client as first argument
- Replace wrong prefix check with a proper entity type check
2020-03-20 10:11:27 +01:00
delthas
b3ad960529 Add WHOIS support 2020-03-20 10:11:27 +01:00
delthas
54275c25ac Add WHO support 2020-03-20 00:29:03 +01:00
Simon Ser
166d8b0626
Remove some IRCv3 constants
go-irc v3.1.2 adds some missing IRCv3 constants.
2020-03-19 14:51:45 +01:00
Simon Ser
7dc2d4d9b1
Fix history name
dc.username contains the raw account username, not the username supplied
by the client.
2020-03-19 14:44:49 +01:00
delthas
37eb162b75 Add create-network bouncer service command 2020-03-19 01:14:44 +01:00
delthas
37e56a01b2 Add suffixing for multi-upstream connections 2020-03-19 00:06:48 +01:00
Simon Ser
e3d97bb164
Add basic infrastructure for bouncer service 2020-03-18 12:23:08 +01:00
Simon Ser
0db032d267
Fix typo 2020-03-17 16:17:39 +01:00
Simon Ser
dc26908466
Fix echo PRIVMSG messages 2020-03-17 16:15:54 +01:00
Simon Ser
651e936913
Add downstream SASL support 2020-03-16 16:16:27 +01:00
Simon Ser
9b777922ae
Allow CAP command when registered 2020-03-16 15:12:46 +01:00
Simon Ser
bdfb8634e9
Log downstream messages before registration 2020-03-16 15:10:16 +01:00
Simon Ser
1241bf82aa
Protect upstreamConn.history with a lock 2020-03-16 15:08:56 +01:00
Simon Ser
af76c3868a
Add CAP support for downstream connections 2020-03-16 15:05:24 +01:00
Simon Ser
87684f7eab
Don't reply to PING when client is unregistered 2020-03-16 14:32:38 +01:00
Simon Ser
b1b519d4f9
Make downstreamConn.runUntilegistered exit with an error on EOF 2020-03-16 14:30:49 +01:00
Simon Ser
75e698f671
Echo downstream PRIVMSGs to other downstream connections 2020-03-16 14:28:45 +01:00
Simon Ser
d5db7c988f
Rename consumption to ringMessage 2020-03-16 14:05:48 +01:00
Simon Ser
3919ee2036
Per-user dispatcher goroutine
This allows message handlers to read upstream/downstream connection
information without causing any race condition.

References: https://todo.sr.ht/~emersion/soju/1
2020-03-16 12:44:59 +01:00
Simon Ser
cdab0dc825
Rename messages channels to outgoing 2020-03-16 11:26:54 +01:00
Simon Ser
88877f3c5a
Strip client & network name from username 2020-03-16 09:32:18 +01:00
Simon Ser
f3940117d1
Rename project to soju 2020-03-13 18:13:03 +01:00
Simon Ser
03d5600da6
Add support for SASL authentication
We now store SASL credentials in the database and automatically populate
them on NickServ REGISTER/IDENTIFY.

References: https://todo.sr.ht/~emersion/jounce/10
2020-03-13 15:12:44 +01:00
Simon Ser
fee8fc79c6
Add support for upstream PASS command 2020-03-13 12:06:02 +01:00
Simon Ser
85f28daf2d
Auto-save IRC networks 2020-03-12 21:28:09 +01:00
Simon Ser
0ef08dfbb5
Store NICK changes in the DB 2020-03-12 19:17:06 +01:00
Simon Ser
0c4e9b539c
Update DB on JOIN and PART 2020-03-12 18:33:03 +01:00
Simon Ser
461de13ecc
Fix nil dereference when network is specified in username 2020-03-12 18:21:41 +01:00
Simon Ser
f3656028f6
Add support for PASS to downstream 2020-03-11 19:09:32 +01:00
Simon Ser
84fe3ae255
Add SQLite database
Closes: https://todo.sr.ht/~emersion/jounce/9
2020-03-04 18:22:58 +01:00
Simon Ser
eacd4e6f0c
Rename network to upstreamName 2020-03-04 16:02:45 +01:00
Simon Ser
03c546e8bf
Remove unused user.getChannel, move getUpstream to user 2020-03-04 16:00:19 +01:00
Simon Ser
c22ce793a1
Allow clients to specify an upstream name in their username 2020-03-04 15:44:13 +01:00
Simon Ser
d1550a3cdb
Remove upstream prefix for outgoing MODE and PRIVMSG
We shouldn't set the prefix when sending these commands.
2020-03-03 15:33:21 +01:00
Simon Ser
70fcef297b
Add functions to translate between upstream and downstream names 2020-02-19 18:25:19 +01:00
Simon Ser
ef2d145d1f
Fix PING handlers, again 2020-02-18 20:40:32 +01:00
Simon Ser
d484e6e374
Properly handle PING messages 2020-02-18 17:07:58 +01:00
Simon Ser
286fb4b18c
Add a -debug flag 2020-02-18 16:31:18 +01:00
Simon Ser
9fea758956
Fix panic when closing downstream connection 2020-02-18 15:08:06 +01:00
Simon Ser
3c3f218b2b
Add upstreamConn.SendMessage
Allows us to change upstreamConn implementation details without updating
the whole codebase.
2020-02-17 16:17:31 +01:00
Simon Ser
70d811f5a8
Document Ring 2020-02-17 16:09:35 +01:00
Simon Ser
528c402bd0
Forward PRIVMSG coming from downstream 2020-02-17 15:56:18 +01:00
Simon Ser
9a93c56cdf
Fix issues related to Ring
- RingConsumer is now used directly in the goroutine responsible for
  writing downstream messages. This allows the ring buffer not to be
  consumed on write error.
- RingConsumer now has a channel attached. This allows PRIVMSG messages
  to always use RingConsumer, instead of also directly pushing messages
  to all downstream connections.
- Multiple clients with the same history name are now supported.
- Ring is now protected by a mutex
2020-02-17 15:46:29 +01:00
Simon Ser
2a43dbd71a
Add downstreamConn.writeMessages
This logic will become more complicated in upcoming commits.
2020-02-17 12:41:27 +01:00
Simon Ser
09dffc0f68
Abbreviate {upstream,downstream}Conn with uc and dc
This makes it clearer than just `c` when we manipulate both kinds at the
same time.
2020-02-17 12:36:42 +01:00
Simon Ser
0cf731aeab
Don't write to downstreamConn.messages directly
Use a helper function instead. This will allow us to change
downstreamConn implementation details without having to update the whole
codebase.
2020-02-17 12:27:48 +01:00
Simon Ser
7127fa325a
Add names to consumers 2020-02-07 17:35:57 +01:00
Simon Ser
fad9d820c1
Add an in-memory ring buffer
References: https://todo.sr.ht/~emersion/jounce/2
2020-02-07 16:43:54 +01:00
Simon Ser
69a35069ef
Handle downstream PART messages 2020-02-07 13:36:32 +01:00
Simon Ser
09a793ff9c
Handle downstream JOIN messages 2020-02-07 13:31:09 +01:00
Simon Ser
2e5395f20b
Send fake RPL_CREATED message 2020-02-07 13:23:09 +01:00
Simon Ser
4de405d3b2
Handle downstream MODE messages 2020-02-07 13:08:27 +01:00
Simon Ser
519cdd9e38
Close connection from writer goroutine
Connections were being closed from the reader goroutine, causing issues
when sending messages and immediately closing the connection.
2020-02-07 12:42:24 +01:00
Simon Ser
96653499dc
Add parseMessageParams helper 2020-02-07 12:36:02 +01:00
Simon Ser
6d03af8243
Allow changing nickname 2020-02-07 12:19:42 +01:00
Simon Ser
636ede13da
Add user.forEachDownstream 2020-02-07 11:56:36 +01:00
Simon Ser
059a799d16
Add user.forEachUpstream 2020-02-07 11:46:44 +01:00
Simon Ser
3586ca3d26
Add Server.getUser 2020-02-07 11:39:56 +01:00
Simon Ser
3b2bb58c60
Per-user connections 2020-02-07 11:36:42 +01:00
Simon Ser
86f66cf6c4
Remove downstreamConn.WriteMessage
It wasn't clear what this function was doing
2020-02-06 22:35:24 +01:00
Simon Ser
ec658e3d39
Send channel info to downstream on registration 2020-02-06 22:29:24 +01:00
Simon Ser
89f1944d30
De-duplicate downstream QUIT handling 2020-02-06 22:22:14 +01:00
Simon Ser
cd7556264e
Forward channel information 2020-02-06 22:19:31 +01:00
Simon Ser
4a816e1593
Write to downstream conn in dedicated goroutine 2020-02-06 21:52:04 +01:00
Simon Ser
36c404c50c
Allow Server to have access to upstreamConn 2020-02-06 21:20:22 +01:00
Simon Ser
8bbba42aef
Maintain a list of downstream connections 2020-02-06 21:11:35 +01:00
Simon Ser
cad64e1a6c
Send standard user/channel modes to downstream connections 2020-02-06 16:50:47 +01:00
Simon Ser
b5f3bad588
Split downstram and upstream code into separate files 2020-02-06 16:18:19 +01:00