As is, soju leaks goroutines on client disconnects, because the closure
started as goroutine in newConn never finishes. It gets stuck in the
for loop annotated as "draining the outgoing channel", because the
outgoing channel is in fact never closed.
This commit fixes the issue by calling conn.Close rather than
conn.conn.Close, which closes not only the underlying net.Conn (in
c.conn), but also the channel.
The *conn pointer returned by newConn is dereferenced in
newDownstreamConn and connectToUpstream (a premature optimization).
As a result, the whole struct is copied and the internal newConn
goroutine works with a different chunk of memory than
downstreamConn and upstreamConn.
stderr prints useful information when openssl fails to connect to
the server. Use -verify_quiet to reduce chatter a bit and still
retain error messages.
Channel membership prefixes in WHO replies (RPL_WHOREPLY and
RPL_WHOSPCRPL) were cached in the user's flags, which meant those same
prefixes were returned on future cache hits, even though the flags are
channel specific.
Strip the channel membership prefixes from the user's flags before
adding a user to the cache and add the prefixes back when reading from
the cache (using the membership info from the NAMES reply).
This is useful for getting information about a particular user,
especially when the server has more than the max amount of users
returned by the command.
Buggy clients like hexchat can't parse CAP otherwise, making it unable to connect at all. Prefix on CAP commands must be pretty ubiquitous if a major issue like that was never caught
From [1]:
> Distinct from a normal message, a numeric reply MUST contain a
> <source> and use a three-digit numeric as the command.
[1]: https://modern.ircdocs.horse/#numeric-replies
This fixes for example, being unable to use /back after going /away in hexchat. Hexchat is unable to parse the 305/306 numerics without the prefix, so assumes you aren't away, and doesn't let you run /back
Mirror what github.com/nhooyr/websocket does and match the host
only. Using the full URL never results in a match, because it
contains slash characters.
Some channels are typically protected with a legacy bot to which
a message is sent, causing the bot to send an INVITE to a channel,
which is invite-only.
Previously, a connect-command for sending a custom message to the
bot could be added, but there was no way to automatically accept
the invite.
This commit enables soju to automatically join a previously saved
channel when we receive an invite to it.
Examples:
- Joining #restricted, then getting disconnected from the upstream,
sending a message to the bot, receiving an invite and accepting it
- Joining #watercooler, getting kicked, then invited again after a
while
We eat the INVITE event so that we just transparently join the
channel without warning all downstreams.
Of course, of note is that we do *not* accept invites of
unknown/unsaved channels.
Thanks to eju for finding the issue and providing a first patch.
The standard library doesn't distribute connections to different
hosts. This causes issues for large deployments: the bouncer always
connects to the same IRC server, even if an IRC network has multiple
servers.
This is disabled when per-user IPs are disabled, because our resolver
implementation is very bare-bones and e.g. doesn't fallback to IPv4
when IPv6 is unavailable. Per-user IPs indicate a larger deployment
and thus a need to spread the load.
Closes: https://todo.sr.ht/~emersion/soju/221
If the source filename contains special characters like "%", we
would return them as-is in the final URL, and try to parse them as
a URL encoded escape sequence in the GET request.
When started without specifying a fileupload backend, soju crashes
because of a nil-pointer deref.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x9484bd]
goroutine 1 [running]:
main.loadConfig()
git.sr.ht/~emersion/soju/cmd/soju/main.go:94 +0x51d
main.main()
git.sr.ht/~emersion/soju/cmd/soju/main.go:127 +0x165
panic: runtime error: invalid memory address or nil pointer dereference
Add a guardclause preventing that crash.
Signed-off-by: Moritz Poldrack <git@moritz.sh>