Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #1

Merged
merged 95 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
431adc0
templates: Fix httpInclude (fix #5698)
mholt Aug 7, 2023
b32f265
ci: Use gofumpt to format code (#5707)
faddat Aug 7, 2023
5b9c850
go.mod: Upgrade golang.org/x/net to 0.14.0 (#5718)
shyim Aug 8, 2023
fbb0ecf
ci: Add riscv64 (64-bit RISC-V) to goreleaser (#5720)
AaronDewes Aug 8, 2023
6cdcc2a
ci: Update to Go 1.21 (#5719)
mholt Aug 9, 2023
a8492c0
fileserver: Don't repeat error for invalid method inside error contex…
francislavoie Aug 9, 2023
080db93
caddytls: Update docs for on-demand config
mholt Aug 9, 2023
1116688
Fix tests
mholt Aug 9, 2023
d813550
cmd: Require config for caddy validate (fix #5612) (#5614)
pistasjis Aug 9, 2023
2d7d806
fileserver: Slightly more fitting icons
mholt Aug 12, 2023
d6f86cc
ci: use gci linter (#5708)
faddat Aug 14, 2023
936ee91
reverseproxy: Always return new upstreams (fix #5736) (#5752)
mholt Aug 17, 2023
f11c3c9
go.mod: Upgrade CertMagic and quic-go
mholt Aug 17, 2023
568fd2b
fix package typo (#5764)
testwill Aug 18, 2023
0a6d333
fileserver: docs: clarify the ability to produce JSON array with `bro…
mohammed90 Aug 18, 2023
10053f7
caddyfile: Loosen heredoc parsing (#5761)
francislavoie Aug 19, 2023
288216e
httpcaddyfile: Stricter errors for site and upstream address schemes …
singhalkarun Aug 19, 2023
84d5e1c
update quic-go to v0.37.6 (#5767)
marten-seemann Aug 19, 2023
38a7b6b
caddyfile: Adjust error formatting (#5765)
francislavoie Aug 20, 2023
4776f62
replacer: change timezone to UTC for "time.now.http" placeholders (#5…
WeidiDeng Aug 22, 2023
b377208
chore: Appease gosec linter (#5777)
mholt Aug 24, 2023
888c6d7
go.mod: Update quic-go to v0.38.0 (#5772)
WeidiDeng Aug 24, 2023
7103ea0
caddyfile: Fix case where heredoc marker is empty after newline (#5769)
francislavoie Aug 24, 2023
b7e472d
ci: ensure short-sha is exported correctly on all platforms (#5781)
mohammed90 Aug 25, 2023
ed8bb13
fileserver: Export BrowseTemplate
mholt Aug 29, 2023
c46ec3b
logging: Clone array on log filters, prevent side-effects (#5786)
francislavoie Aug 29, 2023
1b73e38
logging: query filter for array of strings (#5779)
pauljeannot Aug 29, 2023
50cea4e
ci: Run govulncheck (#5790)
hainenber Sep 5, 2023
f2ab709
cmd: Prevent overwriting existing env vars with `--envfile` (#5803)
evandam Sep 7, 2023
2cac3c5
httpcaddyfile: fix placeholder shorthands in named routes (#5791)
hainenber Sep 8, 2023
1e0dea5
reverseproxy: fix nil pointer dereference in AUpstreams.GetUpstreams …
FossoresLP Sep 10, 2023
a306c5f
fileserver: browse template SVG icons and UI tweaks (#5812)
glowinthedark Sep 16, 2023
58ab3a0
caddyhttp: Use LimitedReader for HTTPRedirectListener
mholt Sep 26, 2023
89c407a
build(deps): bump actions/checkout from 3 to 4 (#5846)
dependabot[bot] Oct 2, 2023
1405683
build(deps): bump goreleaser/goreleaser-action from 4 to 5 (#5847)
dependabot[bot] Oct 2, 2023
82c356f
fix: caddytest.AssertResponseCode error message (#5853)
dunglas Oct 2, 2023
4feac4d
reverseproxy: Allow fallthrough for response handlers without routes …
pkoenig10 Oct 6, 2023
5653c36
templates: Add dummy `RemoteAddr` to `httpInclude` request, proxy com…
ThanmayNath Oct 7, 2023
88b4fbf
go.mod: Upgrade dependencies incl. x/net/http
mholt Oct 10, 2023
fa5a579
fileserver: Add command shortcuts `-l` and `-a` (#5854)
dunglas Oct 10, 2023
e0aaefa
encode: Add `application/wasm*` to the default content types (#5869)
Christoph-D Oct 10, 2023
df99502
httpcaddyfile: Enable TLS for catch-all site if `tls` directive is sp…
hainenber Oct 10, 2023
2a6859a
reverseproxy: Fix retries on "upstreams unavailable" error (#5841)
francislavoie Oct 10, 2023
b245ecd
reverseproxy: fix parsing Caddyfile fails for unlimited request/respo…
mcfedr Oct 11, 2023
9c419f1
cmd: Fix exiting with custom status code, add `caddy -v` (#5874)
francislavoie Oct 11, 2023
33d8d2c
httpcaddyfile: Sort TLS SNI matcher for deterministic JSON output (#5…
francislavoie Oct 11, 2023
05dbe1c
reverseproxy: Replace health header placeholders (#5861)
francislavoie Oct 11, 2023
a8586b0
reverseproxy: Add logging for dynamic A upstreams (#5857)
francislavoie Oct 11, 2023
e8b8d4a
reverseproxy: Fix `least_conn` policy regression (#5862)
francislavoie Oct 11, 2023
3a3182f
reverseproxy: Add more debug logs (#5793)
mholt Oct 11, 2023
289934f
tls: Add X25519Kyber768Draft00 PQ "curve" behind build tag (#5852)
bwesterb Oct 11, 2023
130f6d1
fileserver: Set canonical URL on browse template (#5867)
Forza-tng Oct 11, 2023
fae195a
ci: Force the Go version for govulncheck (#5879)
francislavoie Oct 11, 2023
0e204b7
admin: Respond with 4xx on non-existing config path (#5870)
BattleRattle Oct 11, 2023
1f60328
caddyfile: Fix variadic placeholder false positive when token contain…
WeidiDeng Oct 13, 2023
d70608b
cmd: upgrade: resolve symlink of the executable (#5891)
mohammed90 Oct 13, 2023
7984e6f
httpcaddyfile: Fix TLS automation policy merging with get_certificate…
francislavoie Oct 14, 2023
0900844
templates: Clarify `include` args docs, add `.ClientIP` (#5898)
francislavoie Oct 16, 2023
7c82e26
core: quic listener will manage the underlying socket by itself (#5749)
WeidiDeng Oct 16, 2023
24b0ecc
cmd: Add newline character to version string in CLI output (#5895)
ThanmayNath Oct 16, 2023
c8559c4
caddyhttp: Use sync.Pool to reduce lengthReader allocations (#5848)
perhapsmaple Oct 16, 2023
174c19a
core: Apply SO_REUSEPORT to UDP sockets (#5725)
mholt Oct 17, 2023
ac1f20b
httpcaddyfile: Remove port from logger names (#5881)
francislavoie Oct 17, 2023
4e8245d
templates: Delete headers on `httpError` to reset to clean slate (#5905)
francislavoie Oct 18, 2023
9fc55a9
go.mod: CVE-2023-45142 Update opentelemetry (#5908)
ddl-ebrown Oct 20, 2023
fe2a02b
go.mod: Upgrade quic-go to v0.39.1
mholt Oct 20, 2023
4c10a05
caddyhttp: Adjust `scheme` placeholder docs (#5910)
francislavoie Oct 22, 2023
ac0ad4d
Upgrade acmeserver to github.com/go-chi/chi/v5 (#5913)
maraino Oct 24, 2023
d949caf
test: acmeserver: add smoke test for the ACME server directory (#5914)
mohammed90 Oct 24, 2023
f71d779
chore: Fix usage pool comment (#5916)
WeidiDeng Oct 26, 2023
3f55efc
update quic-go to v0.39.3 (#5918)
marten-seemann Oct 27, 2023
ee35855
go.mod: update quic-go version to v0.40.0 (#5922)
WeidiDeng Oct 31, 2023
3b3d678
Revert "caddyhttp: Use sync.Pool to reduce lengthReader allocations (…
mohammed90 Nov 1, 2023
7e52db8
fileserver: Add .m4v for browse template icon
mholt Nov 14, 2023
96f638e
httpredirectlistener: Only set read limit for when request is HTTP (#…
WeidiDeng Nov 20, 2023
878d491
chore: Bump otel to v1.21.0. (#5949)
dlorenc Nov 22, 2023
4de2c1c
panic when reading from backend failed to propagate stream error (#5952)
WeidiDeng Nov 23, 2023
22eecdb
http2 uses new round-robin scheduler (#5946)
WeidiDeng Nov 24, 2023
18f3429
templates: Offically make templates extensible (#5939)
mholt Nov 28, 2023
4173e2c
tls: accept placeholders in string values of certificate loaders (#5963)
mohammed90 Dec 4, 2023
b24ae63
caddytls: Context to DecisionFunc (#5923)
ankon Dec 7, 2023
4a09cf0
caddytls: Sync distributed storage cleaning (#5940)
mholt Dec 7, 2023
7d919af
chore: cross-build for AIX (#5971)
bmarwell Dec 11, 2023
cbbd1df
core: Always make AppDataDir for InstanceID (#5976)
armadi1809 Dec 13, 2023
56c6b3f
cmd: Preserve LastModified date when exporting storage (#5968)
jum Dec 13, 2023
dc12bd9
proxyprotocol: use github.com/pires/go-proxyproto (#5915)
mohammed90 Dec 13, 2023
3d7d60f
caddyhttp: Add `uuid` to access logs when used (#5859)
francislavoie Dec 13, 2023
362f33d
fileserver: New --precompressed flag (#5880)
ddemoss222 Dec 14, 2023
b16aba5
fileserver: Enable compression for command by default (#5855)
dunglas Dec 14, 2023
b49ec05
go.mod: Updated quic-go to v0.40.1 (#5983)
armadi1809 Dec 15, 2023
387545a
metrics: Record request metrics on HTTP errors (#5979)
tgeoghegan Dec 15, 2023
da7d8cb
httpcaddyfile: Sort skip_hosts for deterministic JSON (#5990)
francislavoie Dec 18, 2023
3248e4c
logging: Add `zap.Option` support (#5944)
francislavoie Dec 18, 2023
d54dcf1
cmd: use automaxprocs for better perf in containers (#5711)
dunglas Dec 18, 2023
1bf72db
build(deps): bump golang.org/x/crypto from 0.16.0 to 0.17.0 (#5994)
dependabot[bot] Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
- windows-latest
go:
- '1.20'
# - '1.21'
- '1.21'

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

# - go: '1.21'
# GO_SEMVER: '~1.21.0'
- go: '1.21'
GO_SEMVER: '~1.21.0'

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

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
Expand All @@ -73,6 +73,7 @@ jobs:

- name: Print Go version and environment
id: vars
shell: bash
run: |
printf "Using go at: $(which go)\n"
printf "Go version: $(go version)\n"
Expand Down Expand Up @@ -135,7 +136,7 @@ jobs:
continue-on-error: true # August 2020: s390x VM is down due to weather and power issues
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run Tests
run: |
mkdir -p ~/.ssh && echo -e "${SSH_KEY//_/\\n}" > ~/.ssh/id_ecdsa && chmod og-rwx ~/.ssh/id_ecdsa
Expand All @@ -161,9 +162,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: check
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/cross-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
fail-fast: false
matrix:
goos:
- 'aix'
- 'android'
- 'linux'
- 'solaris'
Expand All @@ -28,19 +29,19 @@ jobs:
- 'darwin'
- 'netbsd'
go:
- '1.20'
- '1.21'

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

runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
Expand All @@ -62,11 +63,12 @@ jobs:
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goos == 'aix' && 'ppc64' || 'amd64' }}
shell: bash
continue-on-error: true
working-directory: ./cmd/caddy
run: |
GOOS=$GOOS go build -trimpath -o caddy-"$GOOS"-amd64 2> /dev/null
GOOS=$GOOS GOARCH=$GOARCH go build -trimpath -o caddy-"$GOOS"-$GOARCH 2> /dev/null
if [ $? -ne 0 ]; then
echo "::warning ::$GOOS Build Failed"
exit 0
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ jobs:
# From https://github.com/golangci/golangci-lint-action
golangci:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
name: lint
strategy:
matrix:
os:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '~1.20.6'
go-version: '~1.21.0'
check-latest: true

# Workaround for https://github.com/golangci/golangci-lint-action/issues/135
Expand All @@ -40,7 +40,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54

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

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

govulncheck:
runs-on: ubuntu-latest
steps:
- name: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: '~1.21.0'
check-latest: true
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
os:
- ubuntu-latest
go:
- '1.20'
- '1.21'

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

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

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -43,7 +43,7 @@ jobs:
check-latest: true

# Force fetch upstream tags -- because 65 minutes
# tl;dr: actions/checkout@v3 runs this line:
# tl;dr: actions/checkout@v4 runs this line:
# git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +ebc278ec98bb24f2852b61fde2a9bf2e3d83818b:refs/tags/
# which makes its own local lightweight tag, losing all the annotations in the process. Our earlier script ran:
# git fetch --prune --unshallow
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
run: syft version
# GoReleaser will take care of publishing those artifacts into the release
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --timeout 60m
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Caddyfile.*
cmd/caddy/caddy
cmd/caddy/caddy.exe
cmd/caddy/tmp/*.exe
cmd/caddy/.env

# mac specific
.DS_Store
Expand Down
27 changes: 20 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ linters-settings:
errcheck:
ignore: fmt:.*,go.uber.org/zap/zapcore:^Add.*
ignoretests: true
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/caddyserver/caddy/v2/cmd) # ensure that this is always at the top and always has a line break.
- prefix(github.com/caddyserver/caddy) # Custom section: groups all imports with the specified Prefix.
# Skip generated files.
# Default: true
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- gofmt
- goimports
- gci
- gofumpt
- gosec
- gosimple
- govet
Expand Down Expand Up @@ -77,23 +90,23 @@ output:
issues:
exclude-rules:
# we aren't calling unknown URL
- text: "G107" # G107: Url provided to HTTP request as taint input
- text: 'G107' # G107: Url provided to HTTP request as taint input
linters:
- gosec
# as a web server that's expected to handle any template, this is totally in the hands of the user.
- text: "G203" # G203: Use of unescaped data in HTML templates
- text: 'G203' # G203: Use of unescaped data in HTML templates
linters:
- gosec
# we're shelling out to known commands, not relying on user-defined input.
- text: "G204" # G204: Audit use of command execution
- text: 'G204' # G204: Audit use of command execution
linters:
- gosec
# the choice of weakrand is deliberate, hence the named import "weakrand"
- path: modules/caddyhttp/reverseproxy/selectionpolicies.go
text: "G404" # G404: Insecure random number source (rand)
text: 'G404' # G404: Insecure random number source (rand)
linters:
- gosec
- path: modules/caddyhttp/reverseproxy/streaming.go
text: "G404" # G404: Insecure random number source (rand)
text: 'G404' # G404: Insecure random number source (rand)
linters:
- gosec
9 changes: 8 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ builds:
- arm64
- s390x
- ppc64le
- riscv64
goarm:
- "5"
- "6"
Expand All @@ -54,14 +55,20 @@ builds:
goarch: ppc64le
- goos: darwin
goarch: s390x
- goos: darwin
goarch: riscv64
- goos: windows
goarch: ppc64le
- goos: windows
goarch: s390x
- goos: windows
goarch: riscv64
- goos: freebsd
goarch: ppc64le
- goos: freebsd
goarch: s390x
- goos: freebsd
goarch: riscv64
- goos: freebsd
goarch: arm
goarm: "5"
Expand Down Expand Up @@ -106,7 +113,7 @@ archives:
{{- with .Mips }}_{{ . }}{{ end }}
{{- if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}

# packge the 'caddy-build' directory into a tarball,
# package the 'caddy-build' directory into a tarball,
# allowing users to build the exact same set of files as ours.
- id: source
meta: true
Expand Down
18 changes: 15 additions & 3 deletions admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,15 +1196,27 @@ traverseLoop:
}
case http.MethodPut:
if _, ok := v[part]; ok {
return fmt.Errorf("[%s] key already exists: %s", path, part)
return APIError{
HTTPStatus: http.StatusConflict,
Err: fmt.Errorf("[%s] key already exists: %s", path, part),
}
}
v[part] = val
case http.MethodPatch:
if _, ok := v[part]; !ok {
return fmt.Errorf("[%s] key does not exist: %s", path, part)
return APIError{
HTTPStatus: http.StatusNotFound,
Err: fmt.Errorf("[%s] key does not exist: %s", path, part),
}
}
v[part] = val
case http.MethodDelete:
if _, ok := v[part]; !ok {
return APIError{
HTTPStatus: http.StatusNotFound,
Err: fmt.Errorf("[%s] key does not exist: %s", path, part),
}
}
delete(v, part)
default:
return fmt.Errorf("unrecognized method %s", method)
Expand Down Expand Up @@ -1346,7 +1358,7 @@ var (
// will get deleted before the process gracefully exits.
func PIDFile(filename string) error {
pid := []byte(strconv.Itoa(os.Getpid()) + "\n")
err := os.WriteFile(filename, pid, 0600)
err := os.WriteFile(filename, pid, 0o600)
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ func TestUnsyncedConfigAccess(t *testing.T) {
path: "/bar/qq",
expect: `{"foo": "jet", "bar": {"aa": "bb"}, "list": ["a", "b", "c"]}`,
},
{
method: "DELETE",
path: "/bar/qq",
expect: `{"foo": "jet", "bar": {"aa": "bb"}, "list": ["a", "b", "c"]}`,
shouldErr: true,
},
{
method: "POST",
path: "/list",
Expand Down
Loading
Loading