449 Commits

Author SHA1 Message Date
delthas
e144b62324 Add support for downstream WHOIS nick/network nick/network
Many IRC clients use the query `WHOIS nick nick` rather than
`WHOIS nick` when querying a nick. The former command means to
specifically query the WHOIS on the server to which `nick` is connected,
which is useful to get information that is sometimes not propagated
between servers, such as idle time.

In the case where a downstream sends WHOIS nick/network nick/network in
multi-server mode, we need to unmarshal both fields.

Previously, we did not unmarshal those fields, and upstreams would
receive `WHOIS nick/network nick`, which is incorrect.

This adds support for unmarshaling the target field if it is the same as
the mask field, by simply using the unmarshaled nick that is already
computed from the mask.

git-svn-id: file:///srv/svn/repo/suika/trunk@299 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:44:38 +00:00
delthas
105e3d19b4 Add support for downstream LIST to a single upstream
Sometimes, doing a LIST on a single upstream can be useful: if a user is
already connected to Rizon and freenode, sending a LIST will contain
tens of thousands of LIST replies that may not be useful if the user is
interested in another upstream.

This adds support for sending `LIST */network`, which follows the ELIST
M mask extension, that will only send LIST to that specific network. No
other masks are supported by this commit.

git-svn-id: file:///srv/svn/repo/suika/trunk@298 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:43:46 +00:00
delthas
4ca2ebb98f Add support for downstream NICK to a single upstream
Users often have different nicks on different upstreams, and we should
support changing the user nick on a single upstream.

This adds support for a new trivial extension, `NICK nick/network`,
which will change the nick on the specified network, and do nothing for
the other networks.

git-svn-id: file:///srv/svn/repo/suika/trunk@297 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:43:04 +00:00
delthas
fe27882fd8 Update downstream nicks in single-server mode and after NICK
Previously, the downstream nick was never changed, even when the
downstream sent a NICK message or was in single-server mode with a
different nick.

This adds support for updating the downstream nick in the following
cases:
- when a downstream sends NICK
- additionally, in single-server mode:
  - when a downstream connects and its single network is connected
  - when an upstream connects
  - when an upstream sends NICK

git-svn-id: file:///srv/svn/repo/suika/trunk@296 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-27 21:42:38 +00:00
delthas
5740d21ec1 Fix sending CAP END twice when SASL is not used
When SASL is not used, we should only send CAP END after we send a CAP
REQ. Previously CAP END was sent both after a CAP REQ and a CAP ACK,
resulting in two CAP END messages.

Sending a CAP END right after the CAP REQ rather than waiting for the
CAP ACK/NAK saves 1 RTT.

git-svn-id: file:///srv/svn/repo/suika/trunk@295 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-21 20:38:07 +00:00
delthas
087d9b5493 Fix a null access due to assigning nil to the member memberships map
Even though the memberships map has type map[string]*memberships
(with memberships being defined as []membership), the default value for
that map should not be `nil` but a pointer to a nil slice.

This fixes a segfault on some servers before user channel prefixes are
sent.

git-svn-id: file:///srv/svn/repo/suika/trunk@294 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-21 20:37:37 +00:00
delthas
db16c9dde3 Fix parsing MODE messages by updating channel memberships
Previously, we only considered channel modes in the modes of a MODE
messages, which means channel membership changes were ignored. This
resulted in bugs where users channel memberships would not be properly
updated and cached with wrong values. Further, mode arguments
representing entities were not properly marshaled.

This adds support for correctly parsing and updating channel memberships
when processing MODE messages. Mode arguments corresponding to channel
memberships updates are now also properly marshaled.

MODE messages can't be easily sent from history because marshaling these
messages require knowing about the upstream available channel types and
channel membership types, which is currently only possible when
connected. For now this is not an issue since we do not send MODE
messages in history.

git-svn-id: file:///srv/svn/repo/suika/trunk@293 f0ae65fe-ee39-954e-97ec-027ff2717ef4
2020-05-21 20:36:54 +00:00
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