Skip to content

Commit b750efd

Browse files
tianze0926mholtfaddatshyimAaronDewes
authored
update (#1)
* templates: Fix httpInclude (fix caddyserver#5698) Allowable during feature freeze because this is a simple, non-invasive bug fix only. * ci: Use gofumpt to format code (caddyserver#5707) * go.mod: Upgrade golang.org/x/net to 0.14.0 (caddyserver#5718) * ci: Add riscv64 (64-bit RISC-V) to goreleaser (caddyserver#5720) This will add 64-bit RISC-V Linux prebuilts for Caddy. * ci: Update to Go 1.21 (caddyserver#5719) * ci: Update to Go 1.21 * Bump quic-go to v0.37.4 * Check EnableFullDuplex err * Linter bug suppression See timakin/bodyclose#52 --------- Co-authored-by: Francis Lavoie <[email protected]> * fileserver: Don't repeat error for invalid method inside error context (caddyserver#5705) * caddytls: Update docs for on-demand config * Fix tests I thought Go ordered JSON objects when marshaling, but I guess not. * cmd: Require config for caddy validate (fix caddyserver#5612) (caddyserver#5614) * Require config for caddy validate - fixes caddyserver#5612 Signed-off-by: Pistasj <[email protected]> * Try making adjacent Caddyfile check its own function Signed-off-by: Pistasj <[email protected]> * add Francis' suggestion Co-authored-by: Francis Lavoie <[email protected]> * Refactor * Fix borked commit, sigh --------- Signed-off-by: Pistasj <[email protected]> Co-authored-by: Francis Lavoie <[email protected]> Co-authored-by: Matthew Holt <[email protected]> * fileserver: Slightly more fitting icons * ci: use gci linter (caddyserver#5708) * use gofmput to format code * use gci to format imports * reconfigure gci * linter autofixes * rearrange imports a little * export GOOS=windows golangci-lint run ./... --fix * reverseproxy: Always return new upstreams (fix caddyserver#5736) (caddyserver#5752) * reverseproxy: Always return new upstreams (fix caddyserver#5736) * Fix healthcheck logger race * go.mod: Upgrade CertMagic and quic-go * fix package typo (caddyserver#5764) Signed-off-by: guoguangwu <[email protected]> * fileserver: docs: clarify the ability to produce JSON array with `browse` (caddyserver#5751) * caddyfile: Loosen heredoc parsing (caddyserver#5761) * httpcaddyfile: Stricter errors for site and upstream address schemes (caddyserver#5757) Co-authored-by: Mohammed Al Sahaf <[email protected]> Co-authored-by: Francis Lavoie <[email protected]> * update quic-go to v0.37.6 (caddyserver#5767) * caddyfile: Adjust error formatting (caddyserver#5765) * replacer: change timezone to UTC for "time.now.http" placeholders (caddyserver#5774) * chore: Appease gosec linter (caddyserver#5777) These happen to be harmless memory aliasing but I guess the linter can't know that and we can't really prove it in general. * go.mod: Update quic-go to v0.38.0 (caddyserver#5772) * go.mod: Update quic-go to v0.38.0 * run "go mod tidy" --------- Co-authored-by: Matt Holt <[email protected]> * caddyfile: Fix case where heredoc marker is empty after newline (caddyserver#5769) Fixes `panic: runtime error: slice bounds out of range [:3] with capacity 2` Co-authored-by: Matt Holt <[email protected]> * ci: ensure short-sha is exported correctly on all platforms (caddyserver#5781) * fileserver: Export BrowseTemplate This allows programs embedding Caddy to customize the browse template. * logging: Clone array on log filters, prevent side-effects (caddyserver#5786) Fixes https://caddy.community/t/is-caddy-mutating-header-content-from-logging-settings/20947 * logging: query filter for array of strings (caddyserver#5779) Co-authored-by: Matt Holt <[email protected]> Co-authored-by: Francis Lavoie <[email protected]> * ci: Run govulncheck (caddyserver#5790) * feat(ci): check vuln Go mods in CI * fix(ci): correct directive for govulncheck * refactor(ci): move govulncheck to lint.yml * refactor(lint): move govulncheck to different job * cmd: Prevent overwriting existing env vars with `--envfile` (caddyserver#5803) Co-authored-by: Francis Lavoie <[email protected]> * httpcaddyfile: fix placeholder shorthands in named routes (caddyserver#5791) Co-authored-by: Francis Lavoie <[email protected]> * reverseproxy: fix nil pointer dereference in AUpstreams.GetUpstreams (caddyserver#5811) fix a nil pointer dereference in AUpstreams.GetUpstreams when AUpstreams.Versions is not set (fixes caddyserver#5809) Signed-off-by: Pascal Vorwerk <[email protected]> * fileserver: browse template SVG icons and UI tweaks (caddyserver#5812) * fileserver browse.html UI tweaks: folder-symlink icon, search fileserver browse.html UI tweaks: folder-symlink icon, search - ui - add folder-symlink SVG icon - search: use `<input type="search">` instead of `text` - fix npe with `sizebar.style.width` = null in grid mode * tabify whitespace Co-authored-by: Francis Lavoie <[email protected]> --------- Co-authored-by: Francis Lavoie <[email protected]> * caddyhttp: Use LimitedReader for HTTPRedirectListener * build(deps): bump actions/checkout from 3 to 4 (caddyserver#5846) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump goreleaser/goreleaser-action from 4 to 5 (caddyserver#5847) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: caddytest.AssertResponseCode error message (caddyserver#5853) * reverseproxy: Allow fallthrough for response handlers without routes (caddyserver#5780) * templates: Add dummy `RemoteAddr` to `httpInclude` request, proxy compatibility (caddyserver#5845) * Enhancement: Allow X-Forwarded-For Header in httpInclude Virtual Requests The goal of this enhancement is to modify the funcHTTPInclude function in the Caddy codebase to include the X-Forwarded-For header in the virtual request. This change will enable reverse proxies to set the X-Forwarded-For header, ensuring that the client's IP address is correctly provided to the target endpoint. This modification is essential for applications that depend on the X-Forwarded-For header for various functionalities, such as authentication, logging, or content customization. * Updated tplcontext.go - set `virtReq.RemoteAddr = "127.0.0.1"` i have made the suggested changes * Apply suggestions from code review * Update modules/caddyhttp/templates/tplcontext.go --------- Co-authored-by: Francis Lavoie <[email protected]> * go.mod: Upgrade dependencies incl. x/net/http Possibly important for the HTTP/2 Rapid Reset issue. * fileserver: Add command shortcuts `-l` and `-a` (caddyserver#5854) * encode: Add `application/wasm*` to the default content types (caddyserver#5869) * httpcaddyfile: Enable TLS for catch-all site if `tls` directive is specified (caddyserver#5808) * reverseproxy: Fix retries on "upstreams unavailable" error (caddyserver#5841) * reverseproxy: fix parsing Caddyfile fails for unlimited request/response buffers (caddyserver#5828) * cmd: Fix exiting with custom status code, add `caddy -v` (caddyserver#5874) * Simplify variables for commands * Add --envfile support for adapt command * Carry custom status code for commands to os.Exit() * cmd: add `-v` and `--version` to root caddy command * Add `--envfile` to `caddy environ`, extract flag parsing to func --------- Co-authored-by: Mohammed Al Sahaf <[email protected]> * httpcaddyfile: Sort TLS SNI matcher for deterministic JSON output (caddyserver#5860) * httpcaddyfile: Sort TLS SNI matcher, for deterministic adapt output * Update caddyconfig/httpcaddyfile/httptype.go --------- Co-authored-by: Matt Holt <[email protected]> * reverseproxy: Replace health header placeholders (caddyserver#5861) * reverseproxy: Add logging for dynamic A upstreams (caddyserver#5857) * reverseproxy: Fix `least_conn` policy regression (caddyserver#5862) * reverseproxy: Add more debug logs (caddyserver#5793) * reverseproxy: Add more debug logs This makes debug logging very noisy when reverse proxying, but I guess that's the point. This has shown to be useful in troubleshooting infrastructure issues. * Update modules/caddyhttp/reverseproxy/streaming.go Co-authored-by: Francis Lavoie <[email protected]> * Update modules/caddyhttp/reverseproxy/streaming.go Co-authored-by: Francis Lavoie <[email protected]> * Add opt-in `trace_logs` option * Rename to VerboseLogs --------- Co-authored-by: Francis Lavoie <[email protected]> * tls: Add X25519Kyber768Draft00 PQ "curve" behind build tag (caddyserver#5852) … when compiled with cfgo (https://github.com/cloudflare/go). * fileserver: Set canonical URL on browse template (caddyserver#5867) * Browse.html: Add canonical URL and home-link When contents are equal, but maybe just a sort order is different, it is good to add `<link rel="canonical" href="base-path/" />`. This helps search engines propeely index the page. I also added a link to the home page with the name of `{{.Host}}` just above the bread crumbs to make the page clearer. https://paste.tnonline.net/files/28Wun5CQZiqA_Screenshot_20231007_134435_Opera.png * Update browse.html * ci: Force the Go version for govulncheck (caddyserver#5879) * admin: Respond with 4xx on non-existing config path (caddyserver#5870) Co-authored-by: Matt Holt <[email protected]> * caddyfile: Fix variadic placeholder false positive when token contains `:` (caddyserver#5883) * cmd: upgrade: resolve symlink of the executable (caddyserver#5891) * httpcaddyfile: Fix TLS automation policy merging with get_certificate (caddyserver#5896) * templates: Clarify `include` args docs, add `.ClientIP` (caddyserver#5898) * core: quic listener will manage the underlying socket by itself (caddyserver#5749) * core: quic listener will manage the underlying socket by itself. * format code * rename sharedQUICTLSConfig to sharedQUICState, and it will now manage the number of active requests * add comment * strict unwrap type * fix unwrap * remove comment * cmd: Add newline character to version string in CLI output (caddyserver#5895) * caddyhttp: Use sync.Pool to reduce lengthReader allocations (caddyserver#5848) * Use sync.Pool to reduce lengthReader allocations Signed-off-by: Harish Shan <[email protected]> * Add defer putLengthReader to prevent leak Signed-off-by: Harish Shan <[email protected]> * Cleanup in putLengthReader Co-authored-by: Francis Lavoie <[email protected]> --------- Signed-off-by: Harish Shan <[email protected]> Co-authored-by: Francis Lavoie <[email protected]> * core: Apply SO_REUSEPORT to UDP sockets (caddyserver#5725) * core: Apply SO_REUSEPORT to UDP sockets For some reason, 10 months ago when I implemented SO_REUSEPORT for TCP, I didn't realize, or forgot, that it can be used for UDP too. It is a much better solution than using deadline hacks to reuse a socket, at least for TCP. Then mholt/caddy-l4#132 was posted, in which we see that UDP servers never actually stopped when the L4 app was stopped. I verified this using this command: $ nc -u 127.0.0.1 55353 combined with POSTing configs to the /load admin endpoint (which alternated between an echo server and a proxy server so I could tell which config was being used). I refactored the code to use SO_REUSEPORT for UDP, but of course we still need graceful reloads on all platforms, not just Unix, so I also implemented a deadline hack similar to what we used for TCP before. That implementation for TCP was not perfect, possibly having a logical (not data) race condition; but for UDP so far it seems to be working. Verified the same way I verified that SO_REUSEPORT works. I think this code is slightly cleaner and I'm fairly confident this code is effective. * Check error * Fix return * Fix var name * implement Unwrap interface and clean up * move unix packet conn to platform specific file * implement Unwrap for unix packet conn * Move sharedPacketConn into proper file * Fix Windows * move sharedPacketConn and fakeClosePacketConn to proper file --------- Co-authored-by: Weidi Deng <[email protected]> * httpcaddyfile: Remove port from logger names (caddyserver#5881) Co-authored-by: Matt Holt <[email protected]> * templates: Delete headers on `httpError` to reset to clean slate (caddyserver#5905) * go.mod: CVE-2023-45142 Update opentelemetry (caddyserver#5908) * go.mod: Upgrade quic-go to v0.39.1 * caddyhttp: Adjust `scheme` placeholder docs (caddyserver#5910) * Upgrade acmeserver to github.com/go-chi/chi/v5 (caddyserver#5913) This commit upgrades the router used in the acmeserver to github.com/go-chi/chi/v5. In the latest release of step-ca, the router used by certificates was upgraded to that version. Fixes caddyserver#5911 Signed-off-by: Mariano Cano <[email protected]> * test: acmeserver: add smoke test for the ACME server directory (caddyserver#5914) * chore: Fix usage pool comment (caddyserver#5916) * update quic-go to v0.39.3 (caddyserver#5918) * go.mod: update quic-go version to v0.40.0 (caddyserver#5922) * Revert "caddyhttp: Use sync.Pool to reduce lengthReader allocations (caddyserver#5848)" (caddyserver#5924) * fileserver: Add .m4v for browse template icon * httpredirectlistener: Only set read limit for when request is HTTP (caddyserver#5917) * chore: Bump otel to v1.21.0. (caddyserver#5949) Signed-off-by: Dan Lorenc <[email protected]> * panic when reading from backend failed to propagate stream error (caddyserver#5952) * http2 uses new round-robin scheduler (caddyserver#5946) * templates: Offically make templates extensible (caddyserver#5939) * templates: Offically make templates extensible This supercedes caddyserver#4757 (and caddyserver#4568) by making template extensions configurable. The previous implementation was never documented AFAIK and had only 1 consumer, which I'll notify as a courtesy. * templates: Add 'maybe' function for optional components * Try to fix lint error * tls: accept placeholders in string values of certificate loaders (caddyserver#5963) * tls: loader: accept placeholders in string values * appease the linter * caddytls: Context to DecisionFunc (caddyserver#5923) See caddyserver/certmagic#255 * caddytls: Sync distributed storage cleaning (caddyserver#5940) * caddytls: Log out remote addr to detect abuse * caddytls: Sync distributed storage cleaning * Handle errors * Update certmagic to fix tiny bug * Split off port when logging remote IP * Upgrade CertMagic * chore: cross-build for AIX (caddyserver#5971) * core: Always make AppDataDir for InstanceID (caddyserver#5976) * cmd: Preserve LastModified date when exporting storage (caddyserver#5968) * proxyprotocol: use github.com/pires/go-proxyproto (caddyserver#5915) * proxyprotocol: use github.com/pires/go-proxyproto * Fix typo: r/generelly/generally Co-authored-by: Francis Lavoie <[email protected]> * add config options for `Deny` CIDR and fallback policy * use `netip` package & trust unix sockets --------- Co-authored-by: Francis Lavoie <[email protected]> * caddyhttp: Add `uuid` to access logs when used (caddyserver#5859) * fileserver: New --precompressed flag (caddyserver#5880) exposes the file_server precompressed functionality to be used with the file-server command Co-authored-by: Matt Holt <[email protected]> * fileserver: Enable compression for command by default (caddyserver#5855) * feat: enable compression for file-server * refactor * const * Update help text * Update modules/caddyhttp/fileserver/command.go --------- Co-authored-by: Francis Lavoie <[email protected]> Co-authored-by: Matt Holt <[email protected]> * go.mod: Updated quic-go to v0.40.1 (caddyserver#5983) * metrics: Record request metrics on HTTP errors (caddyserver#5979) * httpcaddyfile: Sort skip_hosts for deterministic JSON (caddyserver#5990) * httpcaddyfile: Sort skip_hosts for deterministic JSON * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Mohammed Al Sahaf <[email protected]> * Fix test * Bah --------- Co-authored-by: Mohammed Al Sahaf <[email protected]> * logging: Add `zap.Option` support (caddyserver#5944) * cmd: use automaxprocs for better perf in containers (caddyserver#5711) * feat: use automaxprocs for better perf in containers * better logs * cs * build(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0 (caddyserver#5994) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0. - [Commits](golang/crypto@v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: Pistasj <[email protected]> Signed-off-by: guoguangwu <[email protected]> Signed-off-by: Pascal Vorwerk <[email protected]> Signed-off-by: Harish Shan <[email protected]> Signed-off-by: Mariano Cano <[email protected]> Signed-off-by: Dan Lorenc <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Matthew Holt <[email protected]> Co-authored-by: Jacob Gadikian <[email protected]> Co-authored-by: Shyim <[email protected]> Co-authored-by: Aaron Dewes <[email protected]> Co-authored-by: Francis Lavoie <[email protected]> Co-authored-by: pistasjis <[email protected]> Co-authored-by: guangwu <[email protected]> Co-authored-by: Mohammed Al Sahaf <[email protected]> Co-authored-by: Karun Agarwal <[email protected]> Co-authored-by: Marten Seemann <[email protected]> Co-authored-by: WeidiDeng <[email protected]> Co-authored-by: Paul Jeannot <[email protected]> Co-authored-by: Đỗ Trọng Hải <[email protected]> Co-authored-by: Evan Van Dam <[email protected]> Co-authored-by: Pascal Vorwerk <[email protected]> Co-authored-by: glowinthedark <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kévin Dunglas <[email protected]> Co-authored-by: Patrick Koenig <[email protected]> Co-authored-by: Thanmay Nath <[email protected]> Co-authored-by: Christoph <[email protected]> Co-authored-by: Fred Cox <[email protected]> Co-authored-by: Bas Westerbaan <[email protected]> Co-authored-by: Forza <[email protected]> Co-authored-by: Norman Soetbeer <[email protected]> Co-authored-by: Harish Shan <[email protected]> Co-authored-by: Ethan Brown (Domino) <[email protected]> Co-authored-by: Mariano Cano <[email protected]> Co-authored-by: dlorenc <[email protected]> Co-authored-by: Andreas Kohn <[email protected]> Co-authored-by: Benjamin Marwell <[email protected]> Co-authored-by: Aziz Rmadi <[email protected]> Co-authored-by: Jens-Uwe Mager <[email protected]> Co-authored-by: David DeMoss <[email protected]> Co-authored-by: Tim Geoghegan <[email protected]>
1 parent 0477a35 commit b750efd

File tree

140 files changed

+3401
-2202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+3401
-2202
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ jobs:
2424
- windows-latest
2525
go:
2626
- '1.20'
27-
# - '1.21'
27+
- '1.21'
2828

2929
include:
3030
# Set the minimum Go patch version for the given Go minor
3131
# Usable via ${{ matrix.GO_SEMVER }}
3232
- go: '1.20'
3333
GO_SEMVER: '~1.20.6'
3434

35-
# - go: '1.21'
36-
# GO_SEMVER: '~1.21.0'
35+
- go: '1.21'
36+
GO_SEMVER: '~1.21.0'
3737

3838
# Set some variables per OS, usable via ${{ matrix.VAR }}
3939
# CADDY_BIN_PATH: the path to the compiled Caddy binary, for artifact publishing
@@ -54,7 +54,7 @@ jobs:
5454

5555
steps:
5656
- name: Checkout code
57-
uses: actions/checkout@v3
57+
uses: actions/checkout@v4
5858

5959
- name: Install Go
6060
uses: actions/setup-go@v4
@@ -73,6 +73,7 @@ jobs:
7373

7474
- name: Print Go version and environment
7575
id: vars
76+
shell: bash
7677
run: |
7778
printf "Using go at: $(which go)\n"
7879
printf "Go version: $(go version)\n"
@@ -135,7 +136,7 @@ jobs:
135136
continue-on-error: true # August 2020: s390x VM is down due to weather and power issues
136137
steps:
137138
- name: Checkout code
138-
uses: actions/checkout@v3
139+
uses: actions/checkout@v4
139140
- name: Run Tests
140141
run: |
141142
mkdir -p ~/.ssh && echo -e "${SSH_KEY//_/\\n}" > ~/.ssh/id_ecdsa && chmod og-rwx ~/.ssh/id_ecdsa
@@ -161,9 +162,9 @@ jobs:
161162
runs-on: ubuntu-latest
162163
steps:
163164
- name: Checkout code
164-
uses: actions/checkout@v3
165+
uses: actions/checkout@v4
165166

166-
- uses: goreleaser/goreleaser-action@v4
167+
- uses: goreleaser/goreleaser-action@v5
167168
with:
168169
version: latest
169170
args: check

.github/workflows/cross-build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
goos:
19+
- 'aix'
1920
- 'android'
2021
- 'linux'
2122
- 'solaris'
@@ -28,19 +29,19 @@ jobs:
2829
- 'darwin'
2930
- 'netbsd'
3031
go:
31-
- '1.20'
32+
- '1.21'
3233

3334
include:
3435
# Set the minimum Go patch version for the given Go minor
3536
# Usable via ${{ matrix.GO_SEMVER }}
36-
- go: '1.20'
37-
GO_SEMVER: '~1.20.6'
37+
- go: '1.21'
38+
GO_SEMVER: '~1.21.0'
3839

3940
runs-on: ubuntu-latest
4041
continue-on-error: true
4142
steps:
4243
- name: Checkout code
43-
uses: actions/checkout@v3
44+
uses: actions/checkout@v4
4445

4546
- name: Install Go
4647
uses: actions/setup-go@v4
@@ -62,11 +63,12 @@ jobs:
6263
env:
6364
CGO_ENABLED: 0
6465
GOOS: ${{ matrix.goos }}
66+
GOARCH: ${{ matrix.goos == 'aix' && 'ppc64' || 'amd64' }}
6567
shell: bash
6668
continue-on-error: true
6769
working-directory: ./cmd/caddy
6870
run: |
69-
GOOS=$GOOS go build -trimpath -o caddy-"$GOOS"-amd64 2> /dev/null
71+
GOOS=$GOOS GOARCH=$GOARCH go build -trimpath -o caddy-"$GOOS"-$GOARCH 2> /dev/null
7072
if [ $? -ne 0 ]; then
7173
echo "::warning ::$GOOS Build Failed"
7274
exit 0

.github/workflows/lint.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ jobs:
1717
# From https://github.com/golangci/golangci-lint-action
1818
golangci:
1919
permissions:
20-
contents: read # for actions/checkout to fetch code
21-
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
20+
contents: read # for actions/checkout to fetch code
21+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
2222
name: lint
2323
strategy:
2424
matrix:
25-
os:
25+
os:
2626
- ubuntu-latest
2727
- macos-latest
2828
- windows-latest
2929
runs-on: ${{ matrix.os }}
3030
steps:
31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@v4
3232
- uses: actions/setup-go@v4
3333
with:
34-
go-version: '~1.20.6'
34+
go-version: '~1.21.0'
3535
check-latest: true
3636

3737
# Workaround for https://github.com/golangci/golangci-lint-action/issues/135
@@ -40,7 +40,7 @@ jobs:
4040
- name: golangci-lint
4141
uses: golangci/golangci-lint-action@v3
4242
with:
43-
version: v1.53
43+
version: v1.54
4444

4545
# Workaround for https://github.com/golangci/golangci-lint-action/issues/135
4646
skip-pkg-cache: true
@@ -50,3 +50,12 @@ jobs:
5050

5151
# Optional: show only new issues if it's a pull request. The default value is `false`.
5252
# only-new-issues: true
53+
54+
govulncheck:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: govulncheck
58+
uses: golang/govulncheck-action@v1
59+
with:
60+
go-version-input: '~1.21.0'
61+
check-latest: true

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
os:
1414
- ubuntu-latest
1515
go:
16-
- '1.20'
16+
- '1.21'
1717

1818
include:
1919
# Set the minimum Go patch version for the given Go minor
2020
# Usable via ${{ matrix.GO_SEMVER }}
21-
- go: '1.20'
22-
GO_SEMVER: '~1.20.6'
21+
- go: '1.21'
22+
GO_SEMVER: '~1.21.0'
2323

2424
runs-on: ${{ matrix.os }}
2525
# https://github.com/sigstore/cosign/issues/1258#issuecomment-1002251233
@@ -32,7 +32,7 @@ jobs:
3232

3333
steps:
3434
- name: Checkout code
35-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3636
with:
3737
fetch-depth: 0
3838

@@ -43,7 +43,7 @@ jobs:
4343
check-latest: true
4444

4545
# Force fetch upstream tags -- because 65 minutes
46-
# tl;dr: actions/checkout@v3 runs this line:
46+
# tl;dr: actions/checkout@v4 runs this line:
4747
# git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +ebc278ec98bb24f2852b61fde2a9bf2e3d83818b:refs/tags/
4848
# which makes its own local lightweight tag, losing all the annotations in the process. Our earlier script ran:
4949
# git fetch --prune --unshallow
@@ -106,7 +106,7 @@ jobs:
106106
run: syft version
107107
# GoReleaser will take care of publishing those artifacts into the release
108108
- name: Run GoReleaser
109-
uses: goreleaser/goreleaser-action@v4
109+
uses: goreleaser/goreleaser-action@v5
110110
with:
111111
version: latest
112112
args: release --clean --timeout 60m

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Caddyfile.*
1212
cmd/caddy/caddy
1313
cmd/caddy/caddy.exe
1414
cmd/caddy/tmp/*.exe
15+
cmd/caddy/.env
1516

1617
# mac specific
1718
.DS_Store

.golangci.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@ linters-settings:
22
errcheck:
33
ignore: fmt:.*,go.uber.org/zap/zapcore:^Add.*
44
ignoretests: true
5+
gci:
6+
sections:
7+
- standard # Standard section: captures all standard packages.
8+
- default # Default section: contains all imports that could not be matched to another section type.
9+
- prefix(github.com/caddyserver/caddy/v2/cmd) # ensure that this is always at the top and always has a line break.
10+
- prefix(github.com/caddyserver/caddy) # Custom section: groups all imports with the specified Prefix.
11+
# Skip generated files.
12+
# Default: true
13+
skip-generated: true
14+
# Enable custom order of sections.
15+
# If `true`, make the section order the same as the order of `sections`.
16+
# Default: false
17+
custom-order: true
518

619
linters:
720
disable-all: true
821
enable:
922
- bodyclose
1023
- errcheck
11-
- gofmt
12-
- goimports
24+
- gci
25+
- gofumpt
1326
- gosec
1427
- gosimple
1528
- govet
@@ -77,23 +90,23 @@ output:
7790
issues:
7891
exclude-rules:
7992
# we aren't calling unknown URL
80-
- text: "G107" # G107: Url provided to HTTP request as taint input
93+
- text: 'G107' # G107: Url provided to HTTP request as taint input
8194
linters:
8295
- gosec
8396
# as a web server that's expected to handle any template, this is totally in the hands of the user.
84-
- text: "G203" # G203: Use of unescaped data in HTML templates
97+
- text: 'G203' # G203: Use of unescaped data in HTML templates
8598
linters:
8699
- gosec
87100
# we're shelling out to known commands, not relying on user-defined input.
88-
- text: "G204" # G204: Audit use of command execution
101+
- text: 'G204' # G204: Audit use of command execution
89102
linters:
90103
- gosec
91104
# the choice of weakrand is deliberate, hence the named import "weakrand"
92105
- path: modules/caddyhttp/reverseproxy/selectionpolicies.go
93-
text: "G404" # G404: Insecure random number source (rand)
106+
text: 'G404' # G404: Insecure random number source (rand)
94107
linters:
95108
- gosec
96109
- path: modules/caddyhttp/reverseproxy/streaming.go
97-
text: "G404" # G404: Insecure random number source (rand)
110+
text: 'G404' # G404: Insecure random number source (rand)
98111
linters:
99112
- gosec

.goreleaser.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ builds:
4343
- arm64
4444
- s390x
4545
- ppc64le
46+
- riscv64
4647
goarm:
4748
- "5"
4849
- "6"
@@ -54,14 +55,20 @@ builds:
5455
goarch: ppc64le
5556
- goos: darwin
5657
goarch: s390x
58+
- goos: darwin
59+
goarch: riscv64
5760
- goos: windows
5861
goarch: ppc64le
5962
- goos: windows
6063
goarch: s390x
64+
- goos: windows
65+
goarch: riscv64
6166
- goos: freebsd
6267
goarch: ppc64le
6368
- goos: freebsd
6469
goarch: s390x
70+
- goos: freebsd
71+
goarch: riscv64
6572
- goos: freebsd
6673
goarch: arm
6774
goarm: "5"
@@ -106,7 +113,7 @@ archives:
106113
{{- with .Mips }}_{{ . }}{{ end }}
107114
{{- if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}
108115
109-
# packge the 'caddy-build' directory into a tarball,
116+
# package the 'caddy-build' directory into a tarball,
110117
# allowing users to build the exact same set of files as ours.
111118
- id: source
112119
meta: true

admin.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,15 +1196,27 @@ traverseLoop:
11961196
}
11971197
case http.MethodPut:
11981198
if _, ok := v[part]; ok {
1199-
return fmt.Errorf("[%s] key already exists: %s", path, part)
1199+
return APIError{
1200+
HTTPStatus: http.StatusConflict,
1201+
Err: fmt.Errorf("[%s] key already exists: %s", path, part),
1202+
}
12001203
}
12011204
v[part] = val
12021205
case http.MethodPatch:
12031206
if _, ok := v[part]; !ok {
1204-
return fmt.Errorf("[%s] key does not exist: %s", path, part)
1207+
return APIError{
1208+
HTTPStatus: http.StatusNotFound,
1209+
Err: fmt.Errorf("[%s] key does not exist: %s", path, part),
1210+
}
12051211
}
12061212
v[part] = val
12071213
case http.MethodDelete:
1214+
if _, ok := v[part]; !ok {
1215+
return APIError{
1216+
HTTPStatus: http.StatusNotFound,
1217+
Err: fmt.Errorf("[%s] key does not exist: %s", path, part),
1218+
}
1219+
}
12081220
delete(v, part)
12091221
default:
12101222
return fmt.Errorf("unrecognized method %s", method)
@@ -1346,7 +1358,7 @@ var (
13461358
// will get deleted before the process gracefully exits.
13471359
func PIDFile(filename string) error {
13481360
pid := []byte(strconv.Itoa(os.Getpid()) + "\n")
1349-
err := os.WriteFile(filename, pid, 0600)
1361+
err := os.WriteFile(filename, pid, 0o600)
13501362
if err != nil {
13511363
return err
13521364
}

admin_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func TestUnsyncedConfigAccess(t *testing.T) {
7575
path: "/bar/qq",
7676
expect: `{"foo": "jet", "bar": {"aa": "bb"}, "list": ["a", "b", "c"]}`,
7777
},
78+
{
79+
method: "DELETE",
80+
path: "/bar/qq",
81+
expect: `{"foo": "jet", "bar": {"aa": "bb"}, "list": ["a", "b", "c"]}`,
82+
shouldErr: true,
83+
},
7884
{
7985
method: "POST",
8086
path: "/list",

0 commit comments

Comments
 (0)