292 Commits

Author SHA1 Message Date
delthas
e26684df0e Add support for multiple user channel memberships
User channel memberships are actually a set of memberships, not a single
value. This introduces memberships, a type representing a set of
memberships, stored as an array of memberships ordered by descending
rank.

This also adds multi-prefix to the permanent downstream and upstream
capabilities, so that we try to get all possible channel memberships.

git-svn-id: file:///srv/svn/repo/suika/trunk@292 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-11 10:25:49 +00:00
contact
b8fccc5356 Add time tag to echo messages
Closes: https://todo.sr.ht/~emersion/soju/59

git-svn-id: file:///srv/svn/repo/suika/trunk@291 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-05 14:52:50 +00:00
contact
39348fb8bc readme: add CI badge
git-svn-id: file:///srv/svn/repo/suika/trunk@290 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 19:58:29 +00:00
delthas
c376666015 Fix not properly marshaling self in single-server mode
In single-server mode, we don't need to add a /network suffix when
marshaling, but we still need to replace our nick with the downstream
nick.

git-svn-id: file:///srv/svn/repo/suika/trunk@289 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 19:56:40 +00:00
contact
21f8ed867d Improve highlight matching
Detect word boundaries instead of just doing a sub-string check.

git-svn-id: file:///srv/svn/repo/suika/trunk@288 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 17:51:22 +00:00
contact
87317b6890 Send service NOTICE on highlight in detached channel
git-svn-id: file:///srv/svn/repo/suika/trunk@287 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 17:05:20 +00:00
contact
dd03f558ae Unify upstream NOTICE and PRIVMSG handling
git-svn-id: file:///srv/svn/repo/suika/trunk@286 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 16:12:47 +00:00
contact
2773535389 Don't clear channel key on JOIN
Closes: https://todo.sr.ht/~emersion/soju/50

git-svn-id: file:///srv/svn/repo/suika/trunk@285 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 15:39:53 +00:00
contact
9f84047153 Add support for detached channels
Channels can now be detached by leaving them with the reason "detach",
and re-attached by joining them again. Upon detaching the channel is
no longer forwarded to downstream connections. Upon re-attaching the
history buffer is sent.

git-svn-id: file:///srv/svn/repo/suika/trunk@284 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 13:18:14 +00:00
delthas
2ed4415430 Fix joining only one saved channel per network
This fixes a serious bug added in 276ce12e, where in newNetwork all
channels point to the same channel, which causes soju to only join a
single channel when connecting to an upstream network.

This also adds the same kind of reassignment of a for loop variable in
user.run(), even though that function currently works correctly, as a
sanity improvement in case this function is changed in the future.

git-svn-id: file:///srv/svn/repo/suika/trunk@283 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-01 08:49:58 +00:00
contact
13cdcb19d9 Introduce permanentUpstreamCaps
git-svn-id: file:///srv/svn/repo/suika/trunk@282 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-30 14:10:39 +00:00
contact
f0544a8932 Add upstream cap-notify support
git-svn-id: file:///srv/svn/repo/suika/trunk@281 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-30 13:27:41 +00:00
contact
443eeb2b5a Use a lock to protect conn.{closed,outgoing}
Unfortunately, I don't think there's a good way to implement net.Conn
semantics on top of channels. The Close and SendMessage methods should
gracefully fail without panicking if the connection is already closed.
Using only channels leads to race conditions.

We could remove the lock if Close and SendMessage are only called from a
single goroutine. However that's not the case right now.

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

git-svn-id: file:///srv/svn/repo/suika/trunk@280 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-30 08:35:02 +00:00
contact
e74291b093 Remove network.upstream
This is an artifact from when we used locks. No need for this anymore.

git-svn-id: file:///srv/svn/repo/suika/trunk@279 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-30 08:25:16 +00:00
contact
7358bf75fd Add upstreamConn.caps
Instead of adding one field per capability, let's just have a map, just
like downstreamConn.

git-svn-id: file:///srv/svn/repo/suika/trunk@278 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 17:45:37 +00:00
contact
9f64fc5a93 Rename upstreamConn.caps to supportedCaps
For consistency with downstreamConn.

git-svn-id: file:///srv/svn/repo/suika/trunk@277 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 17:40:31 +00:00
contact
f83ec30f22 Add support for away-notify
This makes use of cap-notify to dynamically advertise support for
away-notify. away-notify is advertised to downstream connections if all
upstreams support it.

git-svn-id: file:///srv/svn/repo/suika/trunk@276 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 17:34:44 +00:00
contact
a8f599627e Add downstream support for cap-notify
git-svn-id: file:///srv/svn/repo/suika/trunk@275 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 17:34:38 +00:00
contact
baccde5a95 Don't use forEachDownstreamByID when forwarding RPL_AWAY
We should broadcast the message, not send it to a specific downstream
connection.

git-svn-id: file:///srv/svn/repo/suika/trunk@274 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 13:32:22 +00:00
contact
ec0e6f5f34 Check upstream NOTICE prefix is non-nil
git-svn-id: file:///srv/svn/repo/suika/trunk@273 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 13:00:17 +00:00
contact
9c54b44ca1 Forward RPL_AWAY messages
git-svn-id: file:///srv/svn/repo/suika/trunk@272 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-29 12:53:48 +00:00
contact
eef5879a61 Abbreviate net status service reply
Don't print the nickname if it's the same as the downstream
connection's.

git-svn-id: file:///srv/svn/repo/suika/trunk@271 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 14:27:53 +00:00
delthas
67237abdea 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@270 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 09:41:13 +00:00
delthas
d94fe63d8a 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@269 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-28 09:41:13 +00:00
delthas
4e989436f1 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@268 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-24 16:26:44 +00:00
contact
a448e04600 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@267 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-23 14:36:20 +00:00
contact
eb0b828944 doc/architecture: ring buffers are now per-channel
git-svn-id: file:///srv/svn/repo/suika/trunk@266 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-17 16:29:49 +00:00
contact
afc55bf108 readme: fix ref to manpage
git-svn-id: file:///srv/svn/repo/suika/trunk@265 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 16:55:21 +00:00
contact
723fe0b92a doc: describe more default settings
git-svn-id: file:///srv/svn/repo/suika/trunk@264 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 16:54:47 +00:00
delthas
218af4327e 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).

git-svn-id: file:///srv/svn/repo/suika/trunk@263 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:38:47 +00:00
contact
c65eaa7d61 Fix typo
git-svn-id: file:///srv/svn/repo/suika/trunk@262 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:25:39 +00:00
contact
68bf575c9e Support sending history when upstream is disconnected
Previously, we were dropping the history.

git-svn-id: file:///srv/svn/repo/suika/trunk@261 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:23:35 +00:00
contact
e7cc0a7f2e Make downstreamConn.marshal{Entity,UserPrefix} take a network
This will be used when sending history while upstream is disconnected.

git-svn-id: file:///srv/svn/repo/suika/trunk@260 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 15:19:00 +00:00
contact
7c7a1d3326 Kill downstreamConn.marshal{Nick,Channel}
We can just use downstreamConn.marshalEntity instead.

git-svn-id: file:///srv/svn/repo/suika/trunk@259 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 14:57:33 +00:00
contact
0266f8711f Disallow marshalling for anotehr network
git-svn-id: file:///srv/svn/repo/suika/trunk@258 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 14:54:13 +00:00
contact
3bf8f6617c Unify downstreamConn.marshal{Entity,Nick,Channel}
We don't actually need to check if the entity is a channel.

git-svn-id: file:///srv/svn/repo/suika/trunk@257 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-16 14:33:56 +00:00
contact
fa4001be19 Add support for downstream batch & chathistory
git-svn-id: file:///srv/svn/repo/suika/trunk@256 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-15 09:29:15 +00:00
contact
c82c640bd9 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@255 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 20:45:02 +00:00
contact
f3a8a13b2b doc: fix SQL driver name in manpage
git-svn-id: file:///srv/svn/repo/suika/trunk@254 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 20:37:14 +00:00
contact
52fb2bc261 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@253 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 17:22:47 +00:00
admin
017d8be225 Allow users to change password in client
Added a BouncerServ command for that.

git-svn-id: file:///srv/svn/repo/suika/trunk@252 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 08:16:25 +00:00
admin
88284aa7de Add ability to change password
git-svn-id: file:///srv/svn/repo/suika/trunk@251 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-10 08:09:02 +00:00
contact
d562150702 Parse timestamp from message tags in messageLogger.Append
git-svn-id: file:///srv/svn/repo/suika/trunk@250 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-08 08:19:33 +00:00
contact
1f25d77be5 Document downstreamConn.{,un}marshalEntity
git-svn-id: file:///srv/svn/repo/suika/trunk@249 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 20:30:54 +00:00
contact
cec36bb0e1 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.

git-svn-id: file:///srv/svn/repo/suika/trunk@248 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 19:54:24 +00:00
contact
2381bdc3aa Extract logic to build log filepath into a function
This will get re-used when parsing logs.

git-svn-id: file:///srv/svn/repo/suika/trunk@247 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 19:50:12 +00:00
contact
019e760145 Remove outdated comment
Locks are gone for good.

git-svn-id: file:///srv/svn/repo/suika/trunk@246 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 17:57:36 +00:00
contact
6743b24d74 Centralize logged messages marshaling
This allows messages added to logs to be handled just like messages
added to the ring buffer.

git-svn-id: file:///srv/svn/repo/suika/trunk@245 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 17:45:29 +00:00
contact
3857f41e57 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

git-svn-id: file:///srv/svn/repo/suika/trunk@244 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 13:02:44 +00:00
contact
bea333aec8 Remove Ring.consumers
We don't need to keep track of consumers anymore.

git-svn-id: file:///srv/svn/repo/suika/trunk@243 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-04-07 12:46:31 +00:00