Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Refactor and improve listener logic (#5089)
* core: Refactor, improve listener logic Deprecate: - caddy.Listen - caddy.ListenTimeout - caddy.ListenPacket Prefer caddy.NetworkAddress.Listen() instead. Change: - caddy.ListenQUIC (hopefully to remove later) - caddy.ListenerFunc signature (add context and ListenConfig) - Don't emit Alt-Svc header advertising h3 over HTTP/3 - Use quic.ListenEarly instead of quic.ListenEarlyAddr; this gives us more flexibility (e.g. possibility of HTTP/3 over UDS) but also introduces a new issue: quic-go/quic-go#3560 (comment) - Unlink unix socket before and after use * Appease the linter * Keep ListenAll
- Loading branch information
Showing
7 changed files
with
562 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in this update, local loopback listen conflicts with enabling HTTP/3, and the two cannot coexist.
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lxhao61 Can you elaborate?
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example configuration:
This configuration worked fine before, but after compiling the file with this updated source code, an error occurred, as shown below:
root@yisu-6310a6cff2a61:
# journalctl -u caddy --no-pager#-- Logs begin at Thu 2022-09-29 07:59:41 CST, end at Thu 2022-09-29 08:00:29 CST. --
Sep 29 07:59:43 yisu-6310a6cff2a61 systemd[1]: Starting Caddy...
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: caddy.HomeDir=/nonexistent
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: caddy.AppDataDir=/nonexistent/.local/share/caddy
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: caddy.AppConfigDir=/nonexistent/.config/caddy
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: caddy.ConfigAutosavePath=/nonexistent/.config/caddy/autosave.json
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: caddy.Version=v2.6.2-0.20220928212245-897a38958cb7 h1:unYePvmZmnnvfzT/KRNbJz4djx6N4w67vCxLtSvl5vM=
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.GOOS=linux
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.GOARCH=amd64
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.Compiler=gc
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.NumCPU=1
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.GOMAXPROCS=1
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: runtime.Version=go1.19.1
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: os.Getwd=/
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: LANG=en_US.UTF-8
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: LANGUAGE=en_US:en
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: NOTIFY_SOCKET=/run/systemd/notify
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: HOME=/nonexistent
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: LOGNAME=nobody
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: USER=nobody
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: INVOCATION_ID=6bfdcd3f5af84f598d1f724d06d6cac3
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: JOURNAL_STREAM=8:15590
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: {"level":"info","ts":1664409583.9663053,"msg":"using provided configuration","config_file":"/usr/local/etc/caddy/Caddyfile","config_adapter":""}
Sep 29 07:59:43 yisu-6310a6cff2a61 caddy[696]: {"level":"info","ts":1664409583.9736228,"msg":"redirected default logger","from":"stderr","to":"/var/log/caddy/access.log"}
Sep 29 07:59:44 yisu-6310a6cff2a61 systemd[1]: Started Caddy.
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: panic: interface conversion: interface {} is *caddy.sharedPacketConn, not *caddy.sharedQuicListener
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: goroutine 1 [running]:
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.ListenQUIC({0x7f8e9095a6e8, 0xc0005d5e80}, 0xc000345980, 0xc00015ec80)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/listeners.go:474 +0x2ae
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).serveHTTP3(0xc00015ec80, {{0x1b2a9f9, 0x3}, {0xc000653b00, 0x9}, 0x20fb, 0x20fb}, 0xc000345980)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/modules/caddyhttp/server.go:519 +0x1ca
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Start(0xc000162500)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/modules/caddyhttp/app.go:432 +0xfc5
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.run.func4(0xc00003ea50)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/caddy.go:502 +0x122
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.run(0xc0006538b0?, 0x1)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/caddy.go:518 +0x5e5
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.unsyncedDecodeAndRun({0xc000661000, 0xdd2, 0x1000}, 0x1)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/caddy.go:337 +0x145
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.changeConfig({0x1b2c7e3, 0x4}, {0x1b39886, 0x7}, {0xc000660000, 0xdd2, 0x1000}, {0x0, 0x0}, 0x1)
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2@v2.6.2-0.20220928212245-897a38958cb7/caddy.go:228 +0x79a
Sep 29 07:59:44 yisu-6310a6cff2a61 caddy[696]: github.com/caddyserver/caddy/v2.Load({0xc000660000, 0xdd2, 0x1000}, 0x0?)
Sep 29 07:59:44 yisu-6310a6cff2a61 systemd[1]: caddy.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Sep 29 07:59:44 yisu-6310a6cff2a61 systemd[1]: caddy.service: Unit entered failed state.
Sep 29 07:59:44 yisu-6310a6cff2a61 systemd[1]: caddy.service: Failed with result 'exit-code'.
root@yisu-6310a6cff2a61:
It works fine after turning off HTTP/3 or canceling the local listen.
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the full config though?
Also you don't need to specify
protocols h1 h2 h3
-- that's the default.PS. Thank you for testing it ❤️ (professional heart)
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full config:
You're welcome, and thank you for your dedication.
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm able to reproduce it, thanks. Working on a fix.
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lxhao61 Should be fixed with ab720fb -- please give it another try!
e3e8aab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, problem solved. Thanks!