Commit graph

1214 commits

Author SHA1 Message Date
Simon Ser 3a4e54bc45 Upgrade dependencies 2024-05-22 17:04:46 +02:00
Simon Ser 6d0f7330e3 Remove RLIMIT_NOFILE bump
Starting with Go 1.19 [0] the file limit is increased by default.

[0]: 8427429c59
2024-05-09 09:02:16 +02:00
jacob1 0ecc9cd042 Include prefix in CAP messages again
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
2024-05-07 16:15:54 +02:00
Simon Ser c36140fb2a Drop source prefix from most non-numeric server messages
Clients are supposed to handle these just fine without a source
prefix.
2024-04-30 14:39:19 +02:00
Simon Ser 6b13ca5f34 Drop unnecessary prefixes for numerics
Previous commit populates the source prefix automatically for all
numerics. Drop the now-unnecessary explicit source prefix.
2024-04-30 14:38:20 +02:00
Simon Ser 51a12983d8 downstream: ensure numerics always carry a source prefix
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
2024-04-30 14:23:49 +02:00
Simon Ser d5108f3994 downstream: shallow copy message in SendMessage instead of deep copy 2024-04-30 14:22:15 +02:00
jacob1 fbcda7b963 Fix missing prefix on away numerics
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
2024-04-30 14:19:15 +02:00
Simon Ser 8e0c256c47 upstream: fix panic on malformed RPL_CHANNELMODEIS 2024-04-25 20:06:13 +02:00
Simon Ser 87b75c44d2 fileupload: fix http-origin pattern matching
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.
2024-04-16 13:19:21 +02:00
Egor eb524bfea4 Add unix domain socket listeners for HTTP and WS 2024-04-15 12:04:50 +02:00
delthas f5612ead04 Automatically join a stored channel on INVITE
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.
2024-03-31 22:23:01 +02:00
Simon Ser 6e79a94172 server: print error on getOrCreateUser failure 2024-03-25 22:03:49 +01:00
Simon Ser 967bb419be auth/pam: upgrade to github.com/msteinert/pam v2 2024-03-25 11:45:23 +01:00
Simon Ser 9386f1c553 upstream: fix conditional for resolveIPAddr
Oops, committed a debug change...

Fixes: f784b42346 ("upstream: use round-robin DNS resolution when per-user IPs are set up")
2024-03-20 12:14:36 +01:00
Simon Ser b70d6f17ce Upgrade dependencies 2024-03-20 10:40:50 +01:00
Simon Ser f784b42346 upstream: use round-robin DNS resolution when per-user IPs are set up
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
2024-03-14 15:44:09 +01:00
Simon Ser 7f66926c41 fileupload: URL-escape output filename
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.
2024-03-11 11:46:26 +01:00
Simon Ser f214e5a5aa fileupload: hardcode a few primary file extensions 2024-03-11 11:41:54 +01:00
Simon Ser 185f6ae3bd fileupload: append ext to filename if missing 2024-03-11 10:46:48 +01:00
Simon Ser 349e19876c Ignore highlights in URLs 2024-03-01 11:33:01 +01:00
Simon Ser b21fd9ba5e Wire up server logger to testing package
Allows the test tool to only display logs relevant to the test
failure at hand.
2024-02-29 14:41:04 +01:00
Tomasz Hołubowicz 1257ab9a85 contrib/clients: update information on ERC for Emacs 2024-02-22 11:50:19 +01:00
Simon Ser a6ab0e8df4 Upgrade dependencies 2024-02-20 10:57:20 +01:00
dubious 50b14a4735 Upstream change for senpai 2024-02-18 10:57:51 +01:00
Alex McGrath 6b89b99784 fileupload: add CORS header fields 2024-02-13 18:54:35 +01:00
Simon Ser 2a78536eb9 config: validate http-origin patterns 2024-02-13 18:54:35 +01:00
Simon Ser 14d27ff914 doc: note that file uploads require an HTTP listener 2024-02-02 19:32:08 +01:00
Moritz Poldrack 4809bb40ea doc: add documentation for the file-upload key
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2024-01-28 11:46:43 +01:00
Moritz Poldrack 3b1cf73165 Fix crash on start when file-upload is disabled
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>
2024-01-28 11:46:40 +01:00
Simon Ser c1fc2f1e61 fileupload: serve select MIME types as inline 2024-01-25 14:23:28 +01:00
Simon Ser 741fd040bb downstream: fix FILEHOST endpoint 2024-01-25 13:09:49 +01:00
Simon Ser 796cf69cac doc/ext/filehost: fix heading level 2024-01-25 12:40:38 +01:00
Simon Ser fd4aa892b2 Add http-ingress config directive
Co-authored-by: delthas <delthas@dille.cc>
2024-01-24 23:32:24 +01:00
Simon Ser b76cb6d5e6 Add support for file uploads
Co-authored-by: delthas <delthas@dille.cc>
2024-01-24 23:32:07 +01:00
Simon Ser ae10ac1af6 doc/ext/bouncer-networks: drop work-in-progress disclaimer
This extension is now widely deployed, so we will stick to
backwards-compatible changes only.
2024-01-24 17:25:23 +01:00
Simon Ser b3a4fa43ab Upgrade dependencies 2024-01-24 11:33:53 +01:00
Simon Ser f1d4c904d9 doc/per-user-ip: fix subnet length in ip route command 2024-01-24 10:58:20 +01:00
Simon Ser 1f98b1f054 service: don't send PART if not joined in "channel delete" 2024-01-24 09:29:25 +01:00
Simon Ser 6ea4e2e1eb config: fix MaxUserNetworks default value 2024-01-24 09:29:05 +01:00
Simon Ser 866845ea95 cmd/soju: add withDefaultPort helper 2024-01-08 18:22:39 +01:00
Simon Ser 4c818d28cc Add https:// and http+insecure:// listeners
Same as wss:// and ws+insecure://, except we'll be able to add more
endpoints for future features (e.g. file uploads).
2024-01-08 17:49:02 +01:00
Simon Ser ef8a9caff4 config: use scfg unmarshaler 2024-01-08 17:30:14 +01:00
Henrique Dias c5d07658ab Upgrade to go-sqlite3 to fix musl build
go-sqlite3 does not build with musl 1.2.4+, which is packaged in some
distros (e.g. Alpine 3.19+). This update fixes it. More info:
https://github.com/mattn/go-sqlite3/pull/1177
2023-12-21 15:36:41 +01:00
Simon Ser e184c30cef upstream: consoldate TCP dial into function 2023-12-21 13:57:28 +01:00
Simon Ser d423a1ca24 Add conn.Shutdown
References: https://todo.sr.ht/~emersion/soju/156
2023-12-11 11:50:16 +01:00
Simon Ser e9678cee2f downstream: use fresh context to send timeout errors
Using an expired context will never actually send the error message
here.
2023-12-11 11:39:57 +01:00
Simon Ser 6729297159 server: fix malformed Web Push subscriber URI
The library prepends "mailto:".
2023-12-09 01:30:48 +01:00
Simon Ser 3e1efea6e5 contrib/certbot: set -eu in renewal hook
That way the script fails if the reload fails.
2023-12-08 17:04:17 +01:00
Simon Ser 2216dd91a0 database: move schema into separate file 2023-12-06 11:39:46 +01:00