Commit graph

1206 commits

Author SHA1 Message Date
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
Simon Ser ec3f0bfd96 contrib/tlstunnel: new document 2023-12-01 11:10:38 +01:00
Simon Ser a52cd5aa43 contrib/certbot: new document 2023-12-01 10:35:01 +01:00
Simon Ser 5ac4978456 Add .b4-config 2023-11-28 14:53:07 +01:00
Simon Ser 06fd7a460a doc/man: add note that memory message store is basic 2023-11-28 00:26:21 +01:00
Simon Ser 67f7d9aa3f Add support for draft/no-implicit-names
Same as the soju extension.
2023-11-27 13:49:40 +01:00
Simon Ser 47346b0f10 conn: drop ErrClosed workaround for WebSocket
The fix has been merged upstream.
2023-11-25 08:14:45 +01:00
Antonio Mika c859d2134a Update user.go to not broadcast a push notification when generated from us 2023-11-17 15:30:54 +01:00
Simon Ser d354a30b43 upstream: use unspecified AWAY reason if possible 2023-11-12 16:37:46 +01:00