Commit Graph

948 Commits

Author SHA1 Message Date
Simon Ser
22b235602b Add soju.im/account-required
References: https://github.com/ircv3/ircv3-specifications/pull/492
2022-06-04 10:52:28 +02:00
Simon Ser
3c5e603192 Remove bridge.go
All of its functions belong to downstream.go.
2022-05-30 09:51:36 +02:00
Simon Ser
289a4e118a Move batch struct to upstream.go 2022-05-30 09:45:40 +02:00
Simon Ser
da8f626e51 xirc: add GenerateSASL 2022-05-30 09:41:47 +02:00
Simon Ser
f9c4ba636f xirc: move over Membership 2022-05-30 09:12:28 +02:00
Simon Ser
f3b06f4236 xirc: move over WHOX helpers 2022-05-29 18:33:29 +02:00
Simon Ser
9b37bd2eaa xirc: move over CapRegistry 2022-05-29 18:33:22 +02:00
Simon Ser
fa6f52ed08 xirc: encode tokens in GenerateIsupport 2022-05-29 18:24:10 +02:00
Simon Ser
c10d382a7d xirfc: move over message generation functions 2022-05-29 17:57:21 +02:00
Simon Ser
997fe723f0 xirc: move ChannelStatus over 2022-05-29 17:28:25 +02:00
Simon Ser
4af7a1b8e5 Rename join to generateJoin
For consistency with other functions.
2022-05-09 17:20:17 +02:00
Simon Ser
c50fb4a26d xirc: move command constants over 2022-05-09 17:18:51 +02:00
Simon Ser
e2e232fa9c config: add message-store memory
The old way to do this was `message-store fs ""`, which is
misleading.
2022-05-09 16:59:27 +02:00
Simon Ser
80ed0d2a6c Rename "log" config directive to "message-store"
This is more explicit and removes the ambiguity with error logging.
2022-05-09 16:41:41 +02:00
Simon Ser
95db42e645 Move identd to separate package 2022-05-09 16:36:54 +02:00
Simon Ser
620a8789b0 Add msgstore package 2022-05-09 16:25:57 +02:00
Simon Ser
b92afa7cca Introduce an xirc package 2022-05-09 16:15:00 +02:00
Simon Ser
89412187d4 msgstore: rename searchMessageOptions, export fields
Preparation for splitting msgstore into a separate package.
2022-05-09 15:44:41 +02:00
Simon Ser
f508d36c38 msgstore: add loadMessageOptions
A struct containing common parameters for all messageStore.Load*
functions returning messages.
2022-05-09 15:36:39 +02:00
Simon Ser
3a7dee8128 Introduce a database package 2022-05-09 15:08:04 +02:00
Simon Ser
27f21eab94 upstream: fix panic in isChannel
Fixes the following:

    goroutine 4380762 [running]:
    runtime/debug.Stack()
    	runtime/debug/stack.go:24 +0x65
    git.sr.ht/~emersion/soju.(*Server)addUserLocked.func1.1()
    	git.sr.ht/~emersion/soju/server.go:318 +0x66
    panic({0x563f090c4460, 0xc002bff998})
    	runtime/panic.go:1038 +0x215
    git.sr.ht/~emersion/soju.(*upstreamConn).isChannel(...)
    	git.sr.ht/~emersion/soju/upstream.go:288
    git.sr.ht/~emersion/soju.(*downstreamConn).handleMessageRegistered(0xc00c23a000, {0x563f0910eb20, 0xc0027539e0}, 0xc01b8d6240)
    	git.sr.ht/~emersion/soju/downstream.go:1836 +0xd4ec
    git.s.ht/~emersion/soju.(*downstreamConn).handleMessage(0xc00c3a000, {0x563f0910eae8, 0xc000026058}, 0xc01b8d6240)
    	git.sr.ht/~emersion/soju/downstream.go:697 +0xde
    git.sr.ht/~emersion/soju.(*user).run(0xc00be4a0b0)
    	git.sr.ht/~emersion/soju/user.go:675 +0xbe5
    git.sr.ht/~emersion/soju.(*Server).addUserLocked.func1()
    	git.sr.ht/~emersion/soju/server.go:328 +0x70
2022-05-07 09:28:53 +02:00
Brett Cornwall
9d188a7cb6 doc/getting-started: Fix simple misspelling. 2022-05-05 18:53:15 +02:00
Simon Ser
09d581dba4 db_sqlite: drop mutex
See [1] for details.

[1]: https://github.com/mattn/go-sqlite3/issues/209
2022-05-03 23:17:56 +02:00
Simon Ser
d37f946e83 downstream: fix setting tls=0 in bouncer-networks
The old code resulted in URLs like "irc+insecure://0".
2022-05-03 10:43:02 +02:00
Simon Ser
23f94a5c6e doc/ext/bouncer-networks: remove BOUNCER BIND auth restriction
We now stash the network ID until connection registration completes.
2022-05-03 09:32:21 +02:00
Simon Ser
d321fcd9f0 upstream: fix missing WHOIS in abortPendingCommands
Fixes the following panic:

    2022/05/03 08:05:32 panic serving user "asdf": Unsupported pending command "WHOIS"
    goroutine 15 [running]:
    runtime/debug.Stack()
            /opt/go/src/runtime/debug/stack.go:24 +0x65
    git.sr.ht/~emersion/soju.(*Server).addUserLocked.func1.1()
            ~/soju/server.go:317 +0x5d
    panic({0xa18da0, 0x6815bf10})
            /opt/go/src/runtime/panic.go:838 +0x207
    git.sr.ht/~emersion/soju.(*upstreamConn).abortPendingCommands(0x6811c9c0)
            ~/soju/upstream.go:338 +0x953
    git.sr.ht/~emersion/soju.(*user).handleUpstreamDisconnected(0x680b7080, 0x6811c9c0)
            ~/soju/user.go:744 +0x6d
    git.sr.ht/~emersion/soju.(*user).updateNetwork(0x680b7080, {0xb99a00, 0x684690e0}, 0x681343c0)
            ~/soju/user.go:936 +0x387
    git.sr.ht/~emersion/soju.handleServiceNetworkUpdate({0xb99a00, 0x684690e0}, 0x68116000, {0x681b8a20?, 0x40429108?, 0x10?})
            ~/soju/service.go:590 +0x14f
    git.sr.ht/~emersion/soju.handleServicePRIVMSG({0xb99a00, 0x684690e0}, 0x68116000, {0x680af5d5?, 0x1?})
            ~/soju/service.go:146 +0x7df
    git.sr.ht/~emersion/soju.(*downstreamConn).handleMessageRegistered(0x68116000, {0xb99a00, 0x684690e0}, 0x681b8940)
            ~/soju/downstream.go:2503 +0x9e9e
    git.sr.ht/~emersion/soju.(*downstreamConn).handleMessage(0x68116000, {0xb999c8?, 0x680240a0?}, 0x681b8940)
            ~/soju/downstream.go:727 +0xde
    git.sr.ht/~emersion/soju.(*user).run(0x680b7080)
            ~/soju/user.go:690 +0xe05
    git.sr.ht/~emersion/soju.(*Server).addUserLocked.func1()
            ~/soju/server.go:327 +0x70
    created by git.sr.ht/~emersion/soju.(*Server).addUserLocked
            ~/soju/server.go:314 +0x178
2022-05-03 08:33:20 +02:00
Simon Ser
48ec515120 doc/ext/bouncer-networks: specify how attributes are cleared in notifications
We send an "error" attribute without a value to clear it, for instance.
2022-05-01 19:37:36 +02:00
Simon Ser
2b9e23c278 readme: restrict CI badge to master branch 2022-04-28 14:13:13 +02:00
Simon Ser
2e5474d05a downstream: improve error message on unrecognized message 2022-04-27 19:05:01 +02:00
delthas
5ae1ec5381 Fix network.forEachDownstream exiting on first non-match
This fixes a serious bug where we stop executing forEachDownstream on
the first downstream that does not match the network. Instead we want to
simply continue; it's a basic filter.
2022-04-24 18:52:36 +02:00
Frank Steinborn
2a0cc57e3a contrib/clients: Add information about irssi
Adds information about how to connect irssi to a soju instance,
single-upsteam mode is assumed.
2022-04-16 08:06:20 +02:00
Simon Ser
42b8dac44e Add user.notifyBouncerNetworkState
DRY.
2022-04-15 10:41:38 +02:00
Simon Ser
f3932ab500 Drop user.forEachDownstream
It's just a for loop.
2022-04-15 10:32:28 +02:00
Simon Ser
a6636a9b0d Add TODO for upstreamConn.register race 2022-04-15 09:53:30 +02:00
Simon Ser
9fb789ee26 Add timeout for upstream connection registration 2022-04-15 09:49:19 +02:00
Simon Ser
77460dfb97 Split upstream connection handling to separate function
Just a refactoring, no functional change.
2022-04-15 09:37:43 +02:00
Simon Ser
2ba13fdefc upstream: use context to set connectToUpstream timeout
This allows the timeout to apply to the whole sequence of
operations, as opposed to just Dial.
2022-04-14 19:42:02 +02:00
delthas
b790db1423 Keep batch tag for downstreams with batch cap
On upstreams without message-tags support, we do not advertise
message-tags anymore. Still, we want to send the batch tag when the
client explicitly requested it.

This fixes a critical issue where we drop the batch tag on chathistory
messages for upstreams that do not support message-tags.
2022-04-12 17:58:36 +02:00
delthas
683cfe0615 Add support for the SEARCH extension 2022-04-12 17:58:16 +02:00
delthas
b67b9b3cd2 Enable message-tags only when all upstreams support it
Previously, we would always advertise mesasge-tags. This made
downstreams believe they could send TAGMSG to the upstream, even though
the upstream did not support it.
2022-04-12 12:41:50 +02:00
delthas
abe5291b62 Add support for the upstream echo-message capability
This adds support for upstream echo-message. This capability is
enabled when the upstream supports labeled-response.

When it is enabled, we don't echo downstream messages in the downstream
handler, but rather wait for the upstream to echo it, to produce it to
downstreams.

When it is disabled, we keep the same behaviour as before: produce the
message to all downstreams as soon as it is received from the
downstream.

In other words, the main functional difference is that when the upstream
supports labeled-response, the client will now receive an echo for its
messages when the server acknowledges them, rather than when soju acks
them.

Additionally, uc.produce was refactored to take an ID rather than a
downstream.
2022-04-11 17:27:47 +02:00
delthas
12577c10bb upstream: handle CAP ACK -name
We'll need this for echo-message.
2022-04-11 17:27:47 +02:00
delthas
f7a468194d bouncer-networks: Add a read-only error attribute
This is useful for clients to display additional info abotu why a
network is disconnected.
2022-04-11 08:38:31 +02:00
delthas
d8ca6d2222 Enable resetting a BOUNCER NETWORK port
When a client sends BOUNCER CHANGENETWORK with no value (or an empty
port value), this means it wants to reset the port value to its default
value.

Previously we considered an empty port as an actual valid, empty port
value, which would then be used to connect to the server (dial
'example.com:' (ie 'example.com:0'), which failed.
2022-04-10 18:12:12 +02:00
Simon Ser
17374f2094 doc/getting-started: ask to install soju
This might seem obvious but… let's add a short sentence just in
case.
2022-04-06 15:58:16 +02:00
Simon Ser
793ac29571 downstream: use upstream user/host for echo message 2022-04-05 10:09:49 +02:00
Simon Ser
9513c28208 downstream: unify PRIVMSG/NOTICE and TAGMSG codepaths
They are nearly identical, the only difference is that TAGMSG has
no text parameter.

Inspired from a patch from delthas:
https://lists.sr.ht/~emersion/soju-dev/patches/30651
2022-04-05 10:09:29 +02:00
Simon Ser
fb20cff45b upstream: pass context to upstreamConn.requestCaps 2022-04-04 13:43:00 +02:00
Simon Ser
5de2a7ec12 Remove unnecessary lastDownstreamID initialization 2022-04-04 09:59:16 +02:00
Simon Ser
846c99dedc Queue WHOIS commands
This avoids having more than one in flight at a time (avoids
hitting rate limits a bit) and routes back replies to the correct
downstream connection (even if labeled-response isn't supported).

Closes: https://todo.sr.ht/~emersion/soju/193
2022-04-04 09:58:26 +02:00