Commit Graph

570 Commits

Author SHA1 Message Date
delthas
7b35757bac Add support for the irc+insecure address scheme
Some servers do not support TLS, or have invalid, expired or self-signed
TLS certificates. While the right fix would be toi contact each server
owner to add support for valid TLS, supporting plaintext upstream
connections is sometimes necessary.

This adds support for the irc+insecure address scheme, which connects to
a network in plain-text over TCP.
2020-04-28 11:41:13 +02:00
delthas
19795a2321 Add support for IRC address schemes
This is preparatory work for adding other connection types to upstream
servers. The service command `network create` now accepts a scheme in
the address flag, which specifies how to connect to the upstream server.

The only supported scheme for now is ircs, which is also the default if
no scheme is specified. ircs connects to a network over a TLS TCP
connection.
2020-04-28 11:41:13 +02:00
delthas
19854b7ec7 Unmarshal nicks in texts of PRIVMSG and NOTICE from downstreams
When writing a PRIVMSG or NOTICE on a channel, it is very common to use
autocompletion to mention other users on that channel. When using soju
in multi-network mode, all users will have their nicked suffixed by
`/network`. This suffix should be removed before sending it upstream.

This adds support for removing all `/network` suffixes in messages sent
to a channel of that network.
2020-04-24 18:26:44 +02:00
Simon Ser
276ce12e7c
Add network.channels, remove DB.GetChannel
Store the list of configured channels in the network data structure.
This removes the need for a database lookup and will be useful for
detached channels.
2020-04-23 16:36:20 +02:00
Simon Ser
dbd6cd689e
doc/architecture: ring buffers are now per-channel 2020-04-17 18:29:49 +02:00
Simon Ser
d74fa2d222
readme: fix ref to manpage 2020-04-16 18:55:21 +02:00
Simon Ser
9436b89723
doc: describe more default settings 2020-04-16 18:54:47 +02:00
delthas
7f74055380 Add support for custom network on-connect commands
Some servers use custom IRC bots with custom commands for registering to
specific services after connection.

This adds support for setting custom raw IRC messages, that will be
sent after registering to a network.

It also adds support for a custom flag.Value type for string
slice flags (flags taking several string values).
2020-04-16 17:38:47 +02:00
Simon Ser
9c463b61ec
Fix typo 2020-04-16 17:25:39 +02:00
Simon Ser
3e80573765
Support sending history when upstream is disconnected
Previously, we were dropping the history.
2020-04-16 17:23:35 +02:00
Simon Ser
45e897c1c1
Make downstreamConn.marshal{Entity,UserPrefix} take a network
This will be used when sending history while upstream is disconnected.
2020-04-16 17:19:00 +02:00
Simon Ser
5cf876cb89
Kill downstreamConn.marshal{Nick,Channel}
We can just use downstreamConn.marshalEntity instead.
2020-04-16 16:57:33 +02:00
Simon Ser
96be0b5945
Disallow marshalling for anotehr network 2020-04-16 16:54:13 +02:00
Simon Ser
e508f2ca81
Unify downstreamConn.marshal{Entity,Nick,Channel}
We don't actually need to check if the entity is a channel.
2020-04-16 16:33:56 +02:00
Simon Ser
8e852cc7e4
Add support for downstream batch & chathistory 2020-04-15 11:29:15 +02:00
Simon Ser
2194259124
Set up DB migration infrastructure
The database is now initialized automatically on first run. The schema
version is stored in SQLite's user_version special field. Migrations are
stored in an array and applied based on the schema version.
2020-04-10 22:45:02 +02:00
Simon Ser
da4b91793e
doc: fix SQL driver name in manpage 2020-04-10 22:37:14 +02:00
Simon Ser
db198335aa
Per-entity ring buffers
Instead of having one ring buffer per network, each network has one ring
buffer per entity (channel or nick). This allows history to be more
fair: if there's a lot of activity in a channel, it won't prune activity
in other channels.

We now track history sequence numbers per client and per network in
networkHistory. The overall list of offline clients is still tracked in
network.offlineClients.

When all clients have received history, the ring buffer can be released.

In the future, we should get rid of too-old offline clients to avoid
having to maintain history for them forever. We should also add a
per-user limit on the number of ring buffers.
2020-04-10 19:22:47 +02:00
Thorben Günther
20a58b1fa3
Allow users to change password in client
Added a BouncerServ command for that.
2020-04-10 10:16:25 +02:00
Thorben Günther
148bbc8102
Add ability to change password 2020-04-10 10:09:02 +02:00
Simon Ser
155f35bd84
Parse timestamp from message tags in messageLogger.Append 2020-04-08 10:19:33 +02:00
Simon Ser
9f6e59195c
Document downstreamConn.{,un}marshalEntity 2020-04-07 22:30:54 +02:00
Simon Ser
f2037c5d52
Make newMessageLogger take a *network instead of an *upstreamConn
There's no reason why messgeLogger needs access to the whole connection,
the network is enough.
2020-04-07 21:54:24 +02:00
Simon Ser
64b537d799
Extract logic to build log filepath into a function
This will get re-used when parsing logs.
2020-04-07 21:50:12 +02:00
Simon Ser
0a895b591e
Remove outdated comment
Locks are gone for good.
2020-04-07 19:57:36 +02:00
Simon Ser
3195809c30
Centralize logged messages marshaling
This allows messages added to logs to be handled just like messages
added to the ring buffer.
2020-04-07 19:45:29 +02:00
Simon Ser
37cd9e4d89
Fix upstream NICK handling
- uc.nicl was compared to msg.Prefix.Name after being updated to the new
  nick
- The new nick wasn't marshaled
2020-04-07 15:02:44 +02:00
Simon Ser
f4aa05af66
Remove Ring.consumers
We don't need to keep track of consumers anymore.
2020-04-07 14:46:31 +02:00
Simon Ser
dd08acc3ea
Make Ring.NewConsumer seq argument mandatory
There's no point in supporting a nil argument anymore.
2020-04-07 14:45:08 +02:00
Simon Ser
7ce369958e
Remove Ring.Close
This is unused.
2020-04-07 14:42:13 +02:00
Simon Ser
13635747c4
Fix server-time tags timezone
We need to use UTC time.
2020-04-06 22:05:49 +02:00
Simon Ser
9692114f37
Make upstreamConn.produce log messages 2020-04-06 21:42:55 +02:00
Simon Ser
baadb964bc
Add origin argument to upstreamConn.produce 2020-04-06 21:34:45 +02:00
Simon Ser
b1494e1065
Remove network.lock
network.conn is now only accessed from the user goroutine.
2020-04-06 19:11:26 +02:00
Simon Ser
1c17d25731
Remove downstreamConn.ourMessages
We can just do the filtering when dispatching the message.
2020-04-06 19:08:43 +02:00
Simon Ser
78b123be72
Log TOPIC messages
See [1].

[1]: 82c4ad8362/modules/log.cpp (L486)
2020-04-06 18:49:39 +02:00
Simon Ser
c985b88559
Fix NOTICE log formatting
ZNC uses hyphens instead of angle brackets [1].

[1]: 82c4ad8362/modules/log.cpp (L495)
2020-04-06 18:45:30 +02:00
Simon Ser
e1ea0d4fb5
Simplify ring consumer loop
No need to use Peek here.
2020-04-06 18:34:33 +02:00
Simon Ser
7961fbc137
Remove RingConsumer.Close
This is now unused.
2020-04-06 18:33:26 +02:00
Simon Ser
f0bc919885
Remove downstreamConn.ringConsumers
We no longer need long-lived ring buffer consumers now that
upstreamConn.produce dispatches messages to downstream connections.
2020-04-06 18:31:48 +02:00
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