227 Commits

Author SHA1 Message Date
contact
35c751da2b Remove per-network ring buffer goroutines
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
2020-04-06 16:05:36 +00:00
contact
7e96015851 Introduce upstreamConn.produce
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
2020-04-06 15:28:49 +00:00
contact
4531200d1b Use Network.GetName for logs path
git-svn-id: file:///srv/svn/repo/suika/trunk@225 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-05 13:24:57 +00:00
contact
60d04d512d Only print addr if necessary in network status service command
git-svn-id: file:///srv/svn/repo/suika/trunk@224 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-05 13:20:13 +00:00
contact
9eaa5ae5c0 Use Network.GetName in network status NOTICE messages
git-svn-id: file:///srv/svn/repo/suika/trunk@223 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-05 13:15:42 +00:00
contact
d18e8f4279 Add network.{createUpdate,delete}Channel
These are about to get more complicated as we move towards per-entity
ring buffers.

git-svn-id: file:///srv/svn/repo/suika/trunk@222 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-05 13:04:52 +00:00
delthas
31ed348a11 Remove unused entityLog struct
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
2020-04-04 15:34:37 +00:00
delthas
ac110eaccc 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@220 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:34:30 +00:00
delthas
4ccc12d584 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

git-svn-id: file:///srv/svn/repo/suika/trunk@219 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:34:12 +00:00
delthas
c03e14ee9e 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

git-svn-id: file:///srv/svn/repo/suika/trunk@218 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-04 15:33:09 +00:00
contact
7e7beef866 Add NOTICE messages to ring buffer
References: https://todo.sr.ht/~emersion/soju/33

git-svn-id: file:///srv/svn/repo/suika/trunk@217 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 19:00:19 +00:00
contact
f4c48f9b05 Add time tag to all messages
git-svn-id: file:///srv/svn/repo/suika/trunk@216 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 18:48:23 +00:00
contact
84c358d870 Introduce messageLogger
This centralizes formatting related to message logging in a single
place.

git-svn-id: file:///srv/svn/repo/suika/trunk@215 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 16:59:17 +00:00
contact
ca785e229d doc: document auto-away feature
git-svn-id: file:///srv/svn/repo/suika/trunk@214 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 15:25:53 +00:00
contact
58be470d17 Log self-messages too
Closes: https://todo.sr.ht/~emersion/soju/44

git-svn-id: file:///srv/svn/repo/suika/trunk@213 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 15:15:12 +00:00
contact
143c84e287 Use conn.ReadMessage instead of irc.Conn.ReadMessage
git-svn-id: file:///srv/svn/repo/suika/trunk@212 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 15:01:25 +00:00
contact
0b30f8fccd Add support for downstream echo-message extension
git-svn-id: file:///srv/svn/repo/suika/trunk@211 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 14:55:49 +00:00
contact
7e2bd554a4 Introduce conn for common connection logic
This centralizes the common upstream & downstream bits.

git-svn-id: file:///srv/svn/repo/suika/trunk@210 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 14:35:08 +00:00
contact
204f1ede17 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@209 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-03 14:15:25 +00:00
contact
0715fdae8a doc: document "network delete"
git-svn-id: file:///srv/svn/repo/suika/trunk@208 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 15:38:09 +00:00
contact
9fe572eb4f Fix SQL error logged on JOIN
Closes: https://todo.sr.ht/~emersion/soju/40

git-svn-id: file:///srv/svn/repo/suika/trunk@207 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 15:34:22 +00:00
contact
0e879e79d8 Set connect timeout
References: https://todo.sr.ht/~emersion/soju/26

git-svn-id: file:///srv/svn/repo/suika/trunk@206 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 14:41:17 +00:00
contact
db1e84ce20 Set write deadlines
References: https://todo.sr.ht/~emersion/soju/26

git-svn-id: file:///srv/svn/repo/suika/trunk@205 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 14:27:53 +00:00
contact
f4f532b00c Simplify ring consumer goroutine
Since network.history is now only accessed from the user goroutine, a
lock becomes unnecessary.

git-svn-id: file:///srv/svn/repo/suika/trunk@204 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 14:02:31 +00:00
contact
9ae7d253b3 Stop ring consumers when deleting network
git-svn-id: file:///srv/svn/repo/suika/trunk@203 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 13:48:56 +00:00
contact
d317a87876 Add "network delete" service command
And add all the infrastructure required to stop and delete networks.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@202 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 13:40:20 +00:00
contact
5f0e31c148 Make user.getNetwork handle Network.Name
git-svn-id: file:///srv/svn/repo/suika/trunk@201 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 13:04:32 +00:00
contact
0adb9a320e config: use shlex
This simplifies parsing and allows quoting words.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@200 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 12:58:14 +00:00
contact
a8b006a658 Set network.conn in user goroutine
One step closed to removing that lock.

git-svn-id: file:///srv/svn/repo/suika/trunk@199 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 10:21:31 +00:00
contact
b476131682 Auto away
Closes: https://todo.sr.ht/~emersion/soju/13

git-svn-id: file:///srv/svn/repo/suika/trunk@198 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 10:16:32 +00:00
contact
fc82577f45 Only set network.conn when registered
git-svn-id: file:///srv/svn/repo/suika/trunk@197 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 10:14:36 +00:00
contact
baadefdaef Add eventUpstreamConnected
This is used in the next commit.

git-svn-id: file:///srv/svn/repo/suika/trunk@196 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-01 10:05:25 +00:00
contact
db2e08e72e Fix log dir permission
We need the permission to list files in the dir.

git-svn-id: file:///srv/svn/repo/suika/trunk@195 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 20:21:49 +00:00
contact
dcb04da885 Add downstream support for server-time
git-svn-id: file:///srv/svn/repo/suika/trunk@194 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 17:50:31 +00:00
contact
c2083296b3 Request server-time cap
If the server didn't populate the time tag, do it ourselves.

git-svn-id: file:///srv/svn/repo/suika/trunk@193 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 17:45:04 +00:00
contact
106949d6e0 Avoid directly forwarding NOTICE messages
This would forward tags even if downstream doesn't support those.

git-svn-id: file:///srv/svn/repo/suika/trunk@192 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 17:41:12 +00:00
contact
ee53042d08 Expose message-tags capability downstream
Strip tags if the client doesn't support them.

git-svn-id: file:///srv/svn/repo/suika/trunk@191 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 17:39:06 +00:00
contact
fc6c4cf40b Make "@" and "/" indicate client name and network, respectively
This allows both kinds "<username>@<client>/<network>" and
"<username>/<network>@<client>".

git-svn-id: file:///srv/svn/repo/suika/trunk@190 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 17:02:02 +00:00
contact
3047218c00 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).

git-svn-id: file:///srv/svn/repo/suika/trunk@189 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 16:41:14 +00:00
contact
e972f4b7de Consume ring messages outside of writer goroutine
This fixes out-of-order JOIN and PRIVMSG messages.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@188 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 16:16:54 +00:00
contact
547e49964d Rename AppendLog to appendLog
This function is only safe to call from inside the user goroutine. Let's
make it private.

git-svn-id: file:///srv/svn/repo/suika/trunk@187 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-31 15:30:45 +00:00
contact
5f94f2b629 Fix missing upstreamConn.closed initialization
Fixes: b33e5f29abbe ("Fix race condition in upstreamConn.Close")

git-svn-id: file:///srv/svn/repo/suika/trunk@186 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-28 19:00:56 +00:00
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
3ac0e6bd4d Add support for bouncer logs
Add bouncer logs, in a network/channel/date.log format, in a similar
manner to ZNC log module. PRIVMSG, JOIN, PART, QUIT, MODE are logged.

Add a config directive for the logs file, including a way to disable
them entirely.

git-svn-id: file:///srv/svn/repo/suika/trunk@178 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-27 23:07:20 +00:00