Commit Graph

330 Commits

Author SHA1 Message Date
Simon Ser
40ff14ec6c
Remove downstreamConn.lock
Everything is now accessed from the user goroutine now that the
per-network ring buffer goroutine is gone.
2020-04-06 18:23:39 +02:00
Simon Ser
3bece53335
Remove locks from ring buffer
Everything is now accessed from the user goroutine.
2020-04-06 18:18:50 +02:00
Simon Ser
d541587701
Remove channel from ring buffer consumers
This is unused.
2020-04-06 18:13:46 +02:00
Simon Ser
ad2c142c36
Remove per-network ring buffer goroutines
Just dispatch from the user goroutine. This allows removes a lot of complexity.
2020-04-06 18:05:36 +02:00
Simon Ser
0c06142ae9
Introduce upstreamConn.produce
The logic in this function is about to get more complicated. It'll soon
also dispatch messages in connected downstreams.
2020-04-06 17:28:49 +02:00
Simon Ser
3680facb1d
Use Network.GetName for logs path 2020-04-05 15:24:57 +02:00
Simon Ser
70f54f685a
Only print addr if necessary in network status service command 2020-04-05 15:20:13 +02:00
Simon Ser
88ef6ee0af
Use Network.GetName in network status NOTICE messages 2020-04-05 15:15:42 +02:00
Simon Ser
e70bf9c42a
Add network.{createUpdate,delete}Channel
These are about to get more complicated as we move towards per-entity
ring buffers.
2020-04-05 15:04:52 +02:00
delthas
93c96d6c21
Remove unused entityLog struct
Since the logging refactoring in 27e090, entityLog is not used anymore
and can be removed.
2020-04-04 17:34:37 +02:00
delthas
4bcfeae5a6
Fill all fields of the service user prefix
On some IRC clients, NOTICE messages from a user which does not have a
user or host in its prefix (and therefore only have a Name, and look
like prefixes of servers), are treated as server notices rather than
user notices, and are treated differently. (For that matter, soju also
considers NOTICE messages from users with only a Name in their prefix as
special server messages). On most of these clients, NOTICE messages from
a user are formatted differently and stand out from the large flow of
incoming misceallenous server messages.

This fills the service user with fake User and Host values so that
NOTICE messages from it correctly appear as coming from a user. This
is particularly useful in the context of connection and disconnect
errors NOTICE messages that are broadcast from the service user to all
relevant downstreams.
2020-04-04 17:34:30 +02:00
delthas
8c11205ee6
Send the last error for disconnected networks in network status
This adds support for sending the exact error message of a network when
it is disconnected, in the reply to the service command `network
status`. This lets users easily examine why a network is currently
disconnected.

No lock is needed because all reads and writes of network.lastError are
made in the user goroutine.

Closes: https://todo.sr.ht/~emersion/soju/28
2020-04-04 17:34:12 +02:00
delthas
eb941d2d2b
Send one NOTICE on new upstream disconnect/connect errors
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
2020-04-04 17:33:09 +02:00
Simon Ser
ee8aae7a96
Add NOTICE messages to ring buffer
References: https://todo.sr.ht/~emersion/soju/33
2020-04-03 21:00:19 +02:00
Simon Ser
3d142cae9f
Add time tag to all messages 2020-04-03 20:48:23 +02:00
Simon Ser
27e0906450
Introduce messageLogger
This centralizes formatting related to message logging in a single
place.
2020-04-03 18:59:17 +02:00
Simon Ser
655e4052f1
doc: document auto-away feature 2020-04-03 17:25:53 +02:00
Simon Ser
3a89152346
Log self-messages too
Closes: https://todo.sr.ht/~emersion/soju/44
2020-04-03 17:15:12 +02:00
Simon Ser
e1931649e4
Use conn.ReadMessage instead of irc.Conn.ReadMessage 2020-04-03 17:01:25 +02:00
Simon Ser
0dc007cd45
Add support for downstream echo-message extension 2020-04-03 16:55:49 +02:00
Simon Ser
2a0696b6bb
Introduce conn for common connection logic
This centralizes the common upstream & downstream bits.
2020-04-03 16:35:08 +02:00
Simon Ser
8c6328207b
Fix writer goroutine races
Any SendMessage call after Close could potentially block forever if the
outgoing channel was filled up. Now the channel is drained before the
writer goroutine exits.
2020-04-03 16:15:25 +02:00
Simon Ser
5b03760be7
doc: document "network delete" 2020-04-01 17:38:09 +02:00
Simon Ser
7c10535bfd
Fix SQL error logged on JOIN
Closes: https://todo.sr.ht/~emersion/soju/40
2020-04-01 17:34:22 +02:00
Simon Ser
bca0b2ad76
Set connect timeout
References: https://todo.sr.ht/~emersion/soju/26
2020-04-01 16:41:17 +02:00
Simon Ser
29f2e93ab7
Set write deadlines
References: https://todo.sr.ht/~emersion/soju/26
2020-04-01 16:27:53 +02:00
Simon Ser
d4de60a869
Simplify ring consumer goroutine
Since network.history is now only accessed from the user goroutine, a
lock becomes unnecessary.
2020-04-01 16:02:31 +02:00
Simon Ser
10da094259
Stop ring consumers when deleting network 2020-04-01 15:48:56 +02:00
Simon Ser
96039320b6
Add "network delete" service command
And add all the infrastructure required to stop and delete networks.

References: https://todo.sr.ht/~emersion/soju/17
2020-04-01 15:40:20 +02:00
Simon Ser
1f11976e7a
Make user.getNetwork handle Network.Name 2020-04-01 15:04:32 +02:00
Simon Ser
886e2d3cf2
config: use shlex
This simplifies parsing and allows quoting words.

Closes: https://todo.sr.ht/~emersion/soju/43
2020-04-01 14:58:14 +02:00
Simon Ser
f2a0775208
Set network.conn in user goroutine
One step closed to removing that lock.
2020-04-01 12:21:31 +02:00
Simon Ser
434e722f92
Auto away
Closes: https://todo.sr.ht/~emersion/soju/13
2020-04-01 12:16:32 +02:00
Simon Ser
190f0d3fd0
Only set network.conn when registered 2020-04-01 12:14:36 +02:00
Simon Ser
dd13e1cb62
Add eventUpstreamConnected
This is used in the next commit.
2020-04-01 12:05:25 +02:00
Simon Ser
977a1b294f
Fix log dir permission
We need the permission to list files in the dir.
2020-03-31 22:21:49 +02:00
Simon Ser
743540665b
Add downstream support for server-time 2020-03-31 19:50:31 +02:00
Simon Ser
2053e62162
Request server-time cap
If the server didn't populate the time tag, do it ourselves.
2020-03-31 19:45:04 +02:00
Simon Ser
29a42203b6
Avoid directly forwarding NOTICE messages
This would forward tags even if downstream doesn't support those.
2020-03-31 19:41:12 +02:00
Simon Ser
cbadb64748
Expose message-tags capability downstream
Strip tags if the client doesn't support them.
2020-03-31 19:39:06 +02:00
Simon Ser
73ee7d237f
Make "@" and "/" indicate client name and network, respectively
This allows both kinds "<username>@<client>/<network>" and
"<username>/<network>@<client>".
2020-03-31 19:02:02 +02:00
Simon Ser
8e6eb18d09
readme: advise connecting with "<username>/<network>"
This matches znc's behavior and is more consistent with the
multiple-upstream mode (where channels and nicks are suffixed with
"/<network>" as well).
2020-03-31 18:41:14 +02:00
Simon Ser
d748ff269c
Consume ring messages outside of writer goroutine
This fixes out-of-order JOIN and PRIVMSG messages.

Closes: https://todo.sr.ht/~emersion/soju/36
2020-03-31 18:16:54 +02:00
Simon Ser
1023c2ebfc
Rename AppendLog to appendLog
This function is only safe to call from inside the user goroutine. Let's
make it private.
2020-03-31 17:30:45 +02:00
Simon Ser
aadeb327d3
Fix missing upstreamConn.closed initialization
Fixes: b33e5f29ab ("Fix race condition in upstreamConn.Close")
2020-03-28 20:00:56 +01:00
Simon Ser
b1fd943ad6
Use clientName to decide whether or not history should be sent
Closes: https://todo.sr.ht/~emersion/soju/31
2020-03-28 17:36:09 +01:00
Simon Ser
6ff26e6640
Remove downstreamConn.username
Replace it with downstreamConn.user.Username
2020-03-28 17:28:28 +01:00
Simon Ser
b7e442670d
Add downstreamConn.clientName 2020-03-28 17:25:48 +01:00
Simon Ser
5a8adc93fe
Update password on NickServ SET PASSWORD message 2020-03-28 10:40:33 +01:00
Simon Ser
53d4f9f71b
s/List/LIST/ when referring to the command 2020-03-28 01:03:00 +01:00