caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
56.47k stars 3.96k forks source link

distributedstek.go:144:16: not enough arguments in call to s.storage.Lock #3464

Closed htfy96 closed 4 years ago

htfy96 commented 4 years ago

Hi,

I'm trying to develop a plugin for Caddy 2 based on v2.0.0 tag, but all xcaddy command returned error when I tried to build caddy:

➜  caddy2-filter xcaddy --help
2020/05/31 16:04:14 [INFO] Temporary folder: /tmp/buildenv_2020-05-31-1604.286380283
2020/05/31 16:04:14 [INFO] Writing main module: /tmp/buildenv_2020-05-31-1604.286380283/main.go
2020/05/31 16:04:14 [INFO] Initializing Go module
2020/05/31 16:04:14 [INFO] exec (timeout=10s): /usr/bin/go mod init caddy 
go: creating new go.mod: module caddy
2020/05/31 16:04:14 [INFO] Replace github.com/sjtug/caddy2-filter => /home/lz/code/git/caddy2-filter
2020/05/31 16:04:14 [INFO] exec (timeout=10s): /usr/bin/go mod edit -replace github.com/sjtug/caddy2-filter=/home/lz/code/git/caddy2-filter 
2020/05/31 16:04:15 [INFO] Pinning versions
2020/05/31 16:04:15 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddyserver/caddy/v2 
go: github.com/caddyserver/caddy/v2 upgrade => v2.0.0
2020/05/31 16:04:15 [INFO] Build environment ready
2020/05/31 16:04:15 [INFO] Building Caddy
2020/05/31 16:04:15 [INFO] exec (timeout=0s): /usr/bin/go build -o /home/lz/code/git/caddy2-filter/caddy -ldflags -w -s -trimpath 
go: found github.com/sjtug/caddy2-filter in github.com/sjtug/caddy2-filter v0.0.0-00010101000000-000000000000
# github.com/caddyserver/caddy/v2/modules/caddytls/distributedstek
/home/lz/code/gopath/pkg/mod/github.com/caddyserver/caddy/v2@v2.0.0/modules/caddytls/distributedstek/distributedstek.go:144:16: not enough arguments in call to s.storage.Lock
    have (string)
    want (context.Context, string)
2020/05/31 16:04:16 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-05-31-1604.286380283
2020/05/31 16:04:16 [ERROR] exit status 2
mholt commented 4 years ago

Hmm, what is your Go module's go.mod file?

htfy96 commented 4 years ago

go.mod can be found here

mholt commented 4 years ago

@htfy96 Thanks, so that's the problem:

github.com/caddyserver/certmagic v0.11.0 // indirect

Caddy is not yet compatible with v0.11.0 (but probably will be this week, once I have a little time.)

Run go mod tidy and that might even fix the problem for you; if not, just use v0.10.13 in your go.mod instead.

mholt commented 4 years ago

PS. I'm excited to see the finished plugin! A lot of people will find filtering features useful.

Bonus points if it can someday work with a stream (i.e. without having to buffer the entire response body) -- that is left as an academic exercise, however. :wink:

htfy96 commented 4 years ago

Thanks for your help! Currently it works with a bounded-cap buffer, which only buffers first 2MB and once the body exceeds that, it abandons buffering and filtering.