58 Commits

Author SHA1 Message Date
contact
3367f4ebd8 Accept "irc" WebSocket subprotocol
git-svn-id: file:///srv/svn/repo/suika/trunk@348 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-02 09:05:49 +00:00
contact
51df0c157e Add RemoteAddr to ircConn interface
git-svn-id: file:///srv/svn/repo/suika/trunk@347 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-07-01 15:02:37 +00:00
contact
e9f9453cba Only read X-Forwarded-* if remote address is loopback
git-svn-id: file:///srv/svn/repo/suika/trunk@345 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:33:23 +00:00
contact
d97de5552f Extract X-Forwarded-* headers for WebSocket connections
git-svn-id: file:///srv/svn/repo/suika/trunk@344 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-29 16:27:43 +00:00
delthas
6a71f953cb Add support for the user create admin service command
This adds support for user create, a new service command only accessible
to admin users. This lets users create other users on the fly and makes
soju start the user routine immediately; unlike sojuctl which currently
requires closing soju, creating the user, and starting soju again.

git-svn-id: file:///srv/svn/repo/suika/trunk@329 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-08 20:30:09 +00:00
contact
f38af41317 Add support for WebSocket connections
WebSocket connections allow web-based clients to connect to IRC. This
commit implements the WebSocket sub-protocol as specified by the pending
IRCv3 proposal [1].

WebSocket listeners can now be set up via a "wss" protocol in the
`listen` directive. The new `http-origin` directive allows the CORS
allowed origins to be configured.

[1]: https://github.com/ircv3/ircv3-specifications/pull/342

git-svn-id: file:///srv/svn/repo/suika/trunk@323 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-07 12:13:46 +00:00
delthas
a079662c1b Add support for downstream CHATHISTORY
This adds support for the WIP (at the time of this commit)
draft/chathistory extension, based on the draft at [1] and the
additional comments at [2].

This gets the history by parsing the chat logs, and is therefore only
enabled when the logs are enabled and the log path is configured.

Getting the history only from the logs adds some restrictions:
- we cannot get history by msgid (those are not logged)
- we cannot get the users masks (maybe they could be inferred from the
  JOIN etc, but it is not worth the effort and would not work every
  time)

The regular soju network history is not sent to clients that support
draft/chathistory, so that they can fetch what they need by manually
calling CHATHISTORY.

The only supported command is BEFORE for now, because that is the only
required command for an app that offers an "infinite history scrollback"
feature.

Regarding implementation, rather than reading the file from the end in
reverse, we simply start from the beginning of each log file, store each
PRIVMSG into a ring, then add the last lines of that ring into the
history we'll return later. The message parsing implementation must be
kept somewhat fast because an app could potentially request thousands of
messages in several files. Here we are using simple sscanf and indexOf
rather than regexps.

In case some log files do not contain any message (for example because
the user had not joined a channel at that time), we try up to a 100 days
of empty log files before giving up.

[1]: https://github.com/prawnsalad/ircv3-specifications/pull/3/files
[2]: https://github.com/ircv3/ircv3-specifications/pull/393/files#r350210018

git-svn-id: file:///srv/svn/repo/suika/trunk@319 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-05 21:50:31 +00:00
contact
17b8361e8b Remove keepAlivePeriod
This is a remnant of setKeepAlive.

Fixes: 77faf72fa33a ("Remove setKeepAlive")

git-svn-id: file:///srv/svn/repo/suika/trunk@316 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-06-04 16:38:04 +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
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
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
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
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
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
55f987eb29 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

git-svn-id: file:///srv/svn/repo/suika/trunk@103 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-16 11:44:59 +00:00
contact
f169a0a35a Split user logic into its own file
git-svn-id: file:///srv/svn/repo/suika/trunk@101 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-16 10:18:41 +00:00
contact
1a9d6a58a0 Rename project to soju
git-svn-id: file:///srv/svn/repo/suika/trunk@98 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-13 17:13:03 +00:00
contact
ad42226219 Auto-save IRC networks
git-svn-id: file:///srv/svn/repo/suika/trunk@91 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-12 20:28:09 +00:00
contact
9eb7349674 Store NICK changes in the DB
git-svn-id: file:///srv/svn/repo/suika/trunk@90 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-12 18:17:06 +00:00
contact
c75d825938 go fmt
git-svn-id: file:///srv/svn/repo/suika/trunk@79 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 18:23:24 +00:00
contact
18c962e5c0 Add SQLite database
Closes: https://todo.sr.ht/~emersion/jounce/9

git-svn-id: file:///srv/svn/repo/suika/trunk@77 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 17:22:58 +00:00
contact
1d0f4c3577 Remove unused user.getChannel, move getUpstream to user
git-svn-id: file:///srv/svn/repo/suika/trunk@75 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 15:00:19 +00:00
contact
47ec2ff976 Allow clients to specify an upstream name in their username
git-svn-id: file:///srv/svn/repo/suika/trunk@73 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-04 14:44:13 +00:00
contact
0b985cd81c Retry connecting to upstream servers
Rate-limit retries in case connecting immediately fails.

git-svn-id: file:///srv/svn/repo/suika/trunk@71 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-03-03 14:26:19 +00:00
contact
9edf0cde7e Enable TCP keep-alive on all connections
git-svn-id: file:///srv/svn/repo/suika/trunk@67 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-18 16:26:17 +00:00
contact
5c79834aeb Don't leave connections half-opened
git-svn-id: file:///srv/svn/repo/suika/trunk@65 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-18 15:54:06 +00:00
contact
d9e356a580 Add a -debug flag
git-svn-id: file:///srv/svn/repo/suika/trunk@64 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-18 15:31:18 +00:00
contact
c326b2708f 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

git-svn-id: file:///srv/svn/repo/suika/trunk@57 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-17 14:46:29 +00:00
contact
64dcb3b383 Add an in-memory ring buffer
References: https://todo.sr.ht/~emersion/jounce/2

git-svn-id: file:///srv/svn/repo/suika/trunk@50 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 15:43:54 +00:00
contact
4c94bee6f5 Handle downstream PART messages
git-svn-id: file:///srv/svn/repo/suika/trunk@49 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 12:36:32 +00:00
contact
41b2a11935 Handle downstream MODE messages
git-svn-id: file:///srv/svn/repo/suika/trunk@46 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 12:08:27 +00:00
contact
6f89a1e0f5 Add upstreamConn.register
git-svn-id: file:///srv/svn/repo/suika/trunk@44 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 11:37:44 +00:00
contact
d119170106 Skip unregistered and closed upstream connections
git-svn-id: file:///srv/svn/repo/suika/trunk@41 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 11:02:19 +00:00
contact
17d85a3a9e Add user.forEachDownstream
git-svn-id: file:///srv/svn/repo/suika/trunk@40 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 10:56:36 +00:00
contact
b5b0ce6144 Add user.forEachUpstream
git-svn-id: file:///srv/svn/repo/suika/trunk@39 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 10:46:44 +00:00
contact
7afd236470 Add Server.getUser
git-svn-id: file:///srv/svn/repo/suika/trunk@38 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 10:39:56 +00:00
contact
08c05383eb Per-user connections
git-svn-id: file:///srv/svn/repo/suika/trunk@37 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-07 10:36:42 +00:00
contact
a5e5e7e39a Keep track of upstream connections in a list
git-svn-id: file:///srv/svn/repo/suika/trunk@29 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 21:25:32 +00:00
contact
de823814a6 Remove downstream conn from list on disconnect
git-svn-id: file:///srv/svn/repo/suika/trunk@24 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 20:30:44 +00:00
contact
fb1c5c5d02 Allow Server to have access to upstreamConn
git-svn-id: file:///srv/svn/repo/suika/trunk@23 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 20:20:22 +00:00
contact
a272efe44d Maintain a list of downstream connections
git-svn-id: file:///srv/svn/repo/suika/trunk@22 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 20:11:35 +00:00
contact
762ec87595 Add per-upstream logger
git-svn-id: file:///srv/svn/repo/suika/trunk@21 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 19:26:03 +00:00
contact
1ce61f3942 Join channels on upstream servers
git-svn-id: file:///srv/svn/repo/suika/trunk@19 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 18:22:04 +00:00
contact
d1ab250d9d Split downstram and upstream code into separate files
git-svn-id: file:///srv/svn/repo/suika/trunk@13 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 15:18:19 +00:00
contact
7a039a8df3 Log upstream server errors
git-svn-id: file:///srv/svn/repo/suika/trunk@12 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 15:13:29 +00:00
contact
bfc082992f Add basic upstream message handler
git-svn-id: file:///srv/svn/repo/suika/trunk@11 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 15:11:28 +00:00
contact
2ff6caa14d Connect to upstream servers
git-svn-id: file:///srv/svn/repo/suika/trunk@10 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-02-06 15:03:07 +00:00