Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Rename caddy2 -> caddy
Removes the version from the package name
Matthew Holt committed
Jun 14, 2019 at 11:58 UTC
5137859e47678aae81e178ca7d164f9e2b4e3121
48 files changed
+199
-193
admin.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"bytes"
admin_test.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"strings"
caddy.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"context"
cmd/caddy2/main.go
+15
-15
@@ -1,23 +1,23 @@
1
package main
2
3
import (
4
- caddycmd "github.com/caddyserver/caddy2/cmd"
4
+ caddycmd "github.com/caddyserver/caddy/cmd"
5
6
// this is where modules get plugged in
7
- _ "github.com/caddyserver/caddy2/modules/caddyhttp"
8
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/caddylog"
9
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/encode"
10
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/encode/brotli"
11
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/encode/gzip"
12
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/encode/zstd"
13
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/fileserver"
14
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/headers"
15
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/markdown"
16
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/requestbody"
17
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/reverseproxy"
18
- _ "github.com/caddyserver/caddy2/modules/caddyhttp/rewrite"
19
- _ "github.com/caddyserver/caddy2/modules/caddytls"
20
- _ "github.com/caddyserver/caddy2/modules/caddytls/standardstek"
7
+ _ "github.com/caddyserver/caddy/modules/caddyhttp"
8
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/caddylog"
9
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/encode"
10
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/encode/brotli"
11
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/encode/gzip"
12
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/encode/zstd"
13
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/fileserver"
14
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/headers"
15
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/markdown"
16
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/requestbody"
17
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/reverseproxy"
18
+ _ "github.com/caddyserver/caddy/modules/caddyhttp/rewrite"
19
+ _ "github.com/caddyserver/caddy/modules/caddytls"
20
+ _ "github.com/caddyserver/caddy/modules/caddytls/standardstek"
21
)
22
23
func main() {
cmd/run.go
+3
-3
@@ -4,18 +4,18 @@ import (
4
"flag"
5
"log"
6
7
- "github.com/caddyserver/caddy2"
7
+ "github.com/caddyserver/caddy"
8
)
9
10
// Main executes the main function of the caddy command.
11
func Main() {
12
flag.Parse()
13
14
- err := caddy2.StartAdmin(*listenAddr)
14
+ err := caddy.StartAdmin(*listenAddr)
15
if err != nil {
16
log.Fatal(err)
17
}
18
- defer caddy2.StopAdmin()
18
+ defer caddy.StopAdmin()
19
20
log.Println("Caddy 2 admin endpoint listening on", *listenAddr)
21
context.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"context"
go.mod
+3
-3
@@ -1,16 +1,16 @@
1
-module github.com/caddyserver/caddy2
1
+module github.com/caddyserver/caddy
2
3
go 1.12
4
5
require (
6
github.com/DataDog/zstd v1.4.0 // indirect
7
- github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb // indirect
7
+ github.com/andybalholm/brotli v0.0.0-20190430215306-5c318f9037cb
8
github.com/dustin/go-humanize v1.0.0
9
github.com/go-acme/lego v2.6.0+incompatible
10
github.com/google/go-cmp v0.3.0 // indirect
11
github.com/klauspost/compress v1.7.1-0.20190613161414-0b31f265a57b
12
github.com/klauspost/cpuid v1.2.1
13
- github.com/mholt/certmagic v0.5.2-0.20190605043235-e49d0d405641
13
+ github.com/mholt/certmagic v0.6.0
14
github.com/rs/cors v1.6.0
15
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
16
github.com/starlight-go/starlight v0.0.0-20181207205707-b06f321544f3
go.sum
+2
@@ -22,6 +22,8 @@ github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w
22
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
23
github.com/mholt/certmagic v0.5.2-0.20190605043235-e49d0d405641 h1:wNqOQ0DFxcZDNpPChhHfL8KscFMnxARN6Q2FiX4/VKI=
24
github.com/mholt/certmagic v0.5.2-0.20190605043235-e49d0d405641/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY=
25
+github.com/mholt/certmagic v0.6.0 h1:gZwuBuONw2v8/fZh2nd39kvjFNjnSF2uIR4GzKaaryw=
26
+github.com/mholt/certmagic v0.6.0/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY=
27
github.com/miekg/dns v1.1.3 h1:1g0r1IvskvgL8rR+AcHzUA+oFmGcQlaIm4IqakufeMM=
28
github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
29
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
listeners.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"fmt"
modules.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"bytes"
modules/caddyhttp/caddyhttp.go
+10
-10
@@ -12,15 +12,15 @@ import (
12
"strings"
13
"time"
14
15
- "github.com/caddyserver/caddy2"
16
- "github.com/caddyserver/caddy2/modules/caddytls"
15
+ "github.com/caddyserver/caddy"
16
+ "github.com/caddyserver/caddy/modules/caddytls"
17
"github.com/mholt/certmagic"
18
)
19
20
func init() {
21
weakrand.Seed(time.Now().UnixNano())
22
23
- err := caddy2.RegisterModule(caddy2.Module{
23
+ err := caddy.RegisterModule(caddy.Module{
24
Name: "http",
25
New: func() interface{} { return new(App) },
26
})
@@ -33,19 +33,19 @@ func init() {
33
type App struct {
34
HTTPPort int `json:"http_port,omitempty"`
35
HTTPSPort int `json:"https_port,omitempty"`
36
- GracePeriod caddy2.Duration `json:"grace_period,omitempty"`
36
+ GracePeriod caddy.Duration `json:"grace_period,omitempty"`
37
Servers map[string]*Server `json:"servers,omitempty"`
38
39
servers []*http.Server
40
41
- ctx caddy2.Context
41
+ ctx caddy.Context
42
}
43
44
// Provision sets up the app.
45
-func (app *App) Provision(ctx caddy2.Context) error {
45
+func (app *App) Provision(ctx caddy.Context) error {
46
app.ctx = ctx
47
48
- repl := caddy2.NewReplacer()
48
+ repl := caddy.NewReplacer()
49
50
for _, srv := range app.Servers {
51
// TODO: Test this function to ensure these replacements are performed
@@ -121,7 +121,7 @@ func (app *App) Start() error {
121
return fmt.Errorf("%s: parsing listen address '%s': %v", srvName, lnAddr, err)
122
}
123
for _, addr := range addrs {
124
- ln, err := caddy2.Listen(network, addr)
124
+ ln, err := caddy.Listen(network, addr)
125
if err != nil {
126
return fmt.Errorf("%s: listening on %s: %v", network, addr, err)
127
}
@@ -376,7 +376,7 @@ type MiddlewareHandler interface {
376
//
377
// If any handler encounters an error, it should be returned for proper
378
// handling. Return values should be propagated down the middleware chain
379
-// by returning it unchanged.
379
+// by returning it unchanged. Returned errors should not be re-wrapped.
380
type Handler interface {
381
ServeHTTP(http.ResponseWriter, *http.Request) error
382
}
@@ -455,4 +455,4 @@ const (
455
)
456
457
// Interface guard
458
-var _ caddy2.App = (*App)(nil)
458
+var _ caddy.App = (*App)(nil)
modules/caddyhttp/caddylog/log.go
+3
-3
@@ -5,12 +5,12 @@ import (
5
"net/http"
6
"time"
7
8
- "github.com/caddyserver/caddy2"
9
- "github.com/caddyserver/caddy2/modules/caddyhttp"
8
+ "github.com/caddyserver/caddy"
9
+ "github.com/caddyserver/caddy/modules/caddyhttp"
10
)
11
12
func init() {
13
- caddy2.RegisterModule(caddy2.Module{
13
+ caddy.RegisterModule(caddy.Module{
14
Name: "http.middleware.log",
15
New: func() interface{} { return new(Log) },
16
})
modules/caddyhttp/encode/brotli/brotli.go
+4
-4
@@ -4,12 +4,12 @@ import (
4
"fmt"
5
6
"github.com/andybalholm/brotli"
7
- "github.com/caddyserver/caddy2"
8
- "github.com/caddyserver/caddy2/modules/caddyhttp/encode"
7
+ "github.com/caddyserver/caddy"
8
+ "github.com/caddyserver/caddy/modules/caddyhttp/encode"
9
)
10
11
func init() {
12
- caddy2.RegisterModule(caddy2.Module{
12
+ caddy.RegisterModule(caddy.Module{
13
Name: "http.encoders.brotli",
14
New: func() interface{} { return new(Brotli) },
15
})
@@ -47,5 +47,5 @@ func (b Brotli) NewEncoder() encode.Encoder {
47
// Interface guards
48
var (
49
_ encode.Encoding = (*Brotli)(nil)
50
- _ caddy2.Validator = (*Brotli)(nil)
50
+ _ caddy.Validator = (*Brotli)(nil)
51
)
modules/caddyhttp/encode/encode.go
+5
-5
@@ -16,12 +16,12 @@ import (
16
"strings"
17
"sync"
18
19
- "github.com/caddyserver/caddy2"
20
- "github.com/caddyserver/caddy2/modules/caddyhttp"
19
+ "github.com/caddyserver/caddy"
20
+ "github.com/caddyserver/caddy/modules/caddyhttp"
21
)
22
23
func init() {
24
- caddy2.RegisterModule(caddy2.Module{
24
+ caddy.RegisterModule(caddy.Module{
25
Name: "http.middleware.encode",
26
New: func() interface{} { return new(Encode) },
27
})
@@ -39,7 +39,7 @@ type Encode struct {
39
}
40
41
// Provision provisions enc.
42
-func (enc *Encode) Provision(ctx caddy2.Context) error {
42
+func (enc *Encode) Provision(ctx caddy.Context) error {
43
enc.Encodings = make(map[string]Encoding)
44
enc.writerPools = make(map[string]*sync.Pool)
45
@@ -280,7 +280,7 @@ const defaultMinLength = 512
280
281
// Interface guards
282
var (
283
- _ caddy2.Provisioner = (*Encode)(nil)
283
+ _ caddy.Provisioner = (*Encode)(nil)
284
_ caddyhttp.MiddlewareHandler = (*Encode)(nil)
285
_ caddyhttp.HTTPInterfaces = (*responseWriter)(nil)
286
)
modules/caddyhttp/encode/gzip/gzip.go
+6
-6
@@ -5,12 +5,12 @@ import (
5
"compress/gzip" // TODO: consider using https://github.com/klauspost/compress/gzip
6
"fmt"
7
8
- "github.com/caddyserver/caddy2"
9
- "github.com/caddyserver/caddy2/modules/caddyhttp/encode"
8
+ "github.com/caddyserver/caddy"
9
+ "github.com/caddyserver/caddy/modules/caddyhttp/encode"
10
)
11
12
func init() {
13
- caddy2.RegisterModule(caddy2.Module{
13
+ caddy.RegisterModule(caddy.Module{
14
Name: "http.encoders.gzip",
15
New: func() interface{} { return new(Gzip) },
16
})
@@ -22,7 +22,7 @@ type Gzip struct {
22
}
23
24
// Provision provisions g's configuration.
25
-func (g *Gzip) Provision(ctx caddy2.Context) error {
25
+func (g *Gzip) Provision(ctx caddy.Context) error {
26
if g.Level == 0 {
27
g.Level = defaultGzipLevel
28
}
@@ -52,6 +52,6 @@ var defaultGzipLevel = 5
52
// Interface guards
53
var (
54
_ encode.Encoding = (*Gzip)(nil)
55
- _ caddy2.Provisioner = (*Gzip)(nil)
56
- _ caddy2.Validator = (*Gzip)(nil)
55
+ _ caddy.Provisioner = (*Gzip)(nil)
56
+ _ caddy.Validator = (*Gzip)(nil)
57
)
modules/caddyhttp/encode/zstd/zstd.go
+3
-3
@@ -1,13 +1,13 @@
1
package caddyzstd
2
3
import (
4
- "github.com/caddyserver/caddy2"
5
- "github.com/caddyserver/caddy2/modules/caddyhttp/encode"
4
+ "github.com/caddyserver/caddy"
5
+ "github.com/caddyserver/caddy/modules/caddyhttp/encode"
6
"github.com/klauspost/compress/zstd"
7
)
8
9
func init() {
10
- caddy2.RegisterModule(caddy2.Module{
10
+ caddy.RegisterModule(caddy.Module{
11
Name: "http.encoders.zstd",
12
New: func() interface{} { return new(Zstd) },
13
})
modules/caddyhttp/errors.go
+2
-2
@@ -7,7 +7,7 @@ import (
7
"runtime"
8
"strings"
9
10
- "github.com/caddyserver/caddy2"
10
+ "github.com/caddyserver/caddy"
11
)
12
13
// Error is a convenient way for a Handler to populate the
@@ -102,4 +102,4 @@ var ErrRehandle = fmt.Errorf("rehandling request")
102
103
// ErrorCtxKey is the context key to use when storing
104
// an error (for use with context.Context).
105
-const ErrorCtxKey = caddy2.CtxKey("handler_chain_error")
105
+const ErrorCtxKey = caddy.CtxKey("handler_chain_error")
modules/caddyhttp/fileserver/browse.go
+4
-4
@@ -9,8 +9,8 @@ import (
9
"path"
10
"strings"
11
12
- "github.com/caddyserver/caddy2"
13
- "github.com/caddyserver/caddy2/modules/caddyhttp"
12
+ "github.com/caddyserver/caddy"
13
+ "github.com/caddyserver/caddy/modules/caddyhttp"
14
)
15
16
// Browse configures directory browsing.
@@ -37,7 +37,7 @@ func (fsrv *FileServer) serveBrowse(dirPath string, w http.ResponseWriter, r *ht
37
}
38
defer dir.Close()
39
40
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
40
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
41
42
// calling path.Clean here prevents weird breadcrumbs when URL paths are sketchy like /%2e%2e%2f
43
listing, err := fsrv.loadDirectoryContents(dir, path.Clean(r.URL.Path), repl)
@@ -71,7 +71,7 @@ func (fsrv *FileServer) serveBrowse(dirPath string, w http.ResponseWriter, r *ht
71
return nil
72
}
73
74
-func (fsrv *FileServer) loadDirectoryContents(dir *os.File, urlPath string, repl caddy2.Replacer) (browseListing, error) {
74
+func (fsrv *FileServer) loadDirectoryContents(dir *os.File, urlPath string, repl caddy.Replacer) (browseListing, error) {
75
files, err := dir.Readdir(-1)
76
if err != nil {
77
return browseListing{}, err
modules/caddyhttp/fileserver/browselisting.go
+2
-2
@@ -9,11 +9,11 @@ import (
9
"strings"
10
"time"
11
12
- "github.com/caddyserver/caddy2"
12
+ "github.com/caddyserver/caddy"
13
"github.com/dustin/go-humanize"
14
)
15
16
-func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, urlPath string, repl caddy2.Replacer) browseListing {
16
+func (fsrv *FileServer) directoryListing(files []os.FileInfo, canGoUp bool, urlPath string, repl caddy.Replacer) browseListing {
17
filesToHide := fsrv.transformHidePaths(repl)
18
19
var (
modules/caddyhttp/fileserver/matcher.go
+3
-3
@@ -4,12 +4,12 @@ import (
4
"net/http"
5
"os"
6
7
- "github.com/caddyserver/caddy2"
8
- "github.com/caddyserver/caddy2/modules/caddyhttp"
7
+ "github.com/caddyserver/caddy"
8
+ "github.com/caddyserver/caddy/modules/caddyhttp"
9
)
10
11
func init() {
12
- caddy2.RegisterModule(caddy2.Module{
12
+ caddy.RegisterModule(caddy.Module{
13
Name: "http.matchers.file",
14
New: func() interface{} { return new(FileMatcher) },
15
})
modules/caddyhttp/fileserver/staticfiles.go
+7
-7
@@ -12,14 +12,14 @@ import (
12
"strings"
13
"time"
14
15
- "github.com/caddyserver/caddy2"
16
- "github.com/caddyserver/caddy2/modules/caddyhttp"
15
+ "github.com/caddyserver/caddy"
16
+ "github.com/caddyserver/caddy/modules/caddyhttp"
17
)
18
19
func init() {
20
weakrand.Seed(time.Now().UnixNano())
21
22
- caddy2.RegisterModule(caddy2.Module{
22
+ caddy.RegisterModule(caddy.Module{
23
Name: "http.responders.file_server",
24
New: func() interface{} { return new(FileServer) },
25
})
@@ -40,7 +40,7 @@ type FileServer struct {
40
}
41
42
// Provision sets up the static files responder.
43
-func (fsrv *FileServer) Provision(ctx caddy2.Context) error {
43
+func (fsrv *FileServer) Provision(ctx caddy.Context) error {
44
if fsrv.Fallback != nil {
45
err := fsrv.Fallback.Provision(ctx)
46
if err != nil {
@@ -94,7 +94,7 @@ func (fsrv *FileServer) Validate() error {
94
}
95
96
func (fsrv *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) error {
97
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
97
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
98
99
filesToHide := fsrv.transformHidePaths(repl)
100
@@ -251,7 +251,7 @@ func mapDirOpenError(originalErr error, name string) error {
251
252
// transformHidePaths performs replacements for all the elements of
253
// fsrv.Hide and returns a new list of the transformed values.
254
-func (fsrv *FileServer) transformHidePaths(repl caddy2.Replacer) []string {
254
+func (fsrv *FileServer) transformHidePaths(repl caddy.Replacer) []string {
255
hide := make([]string, len(fsrv.Hide))
256
for i := range fsrv.Hide {
257
hide[i] = repl.ReplaceAll(fsrv.Hide[i], "")
@@ -288,7 +288,7 @@ func sanitizedPathJoin(root, reqPath string) string {
288
// by default) to map the request r to a filename. The full path to
289
// the file is returned if one is found; otherwise, an empty string
290
// is returned.
291
-func (fsrv *FileServer) selectFile(r *http.Request, repl caddy2.Replacer, filesToHide []string) string {
291
+func (fsrv *FileServer) selectFile(r *http.Request, repl caddy.Replacer, filesToHide []string) string {
292
root := repl.ReplaceAll(fsrv.Root, "")
293
294
if fsrv.Files == nil {
modules/caddyhttp/headers/headers.go
+13
-13
@@ -4,12 +4,12 @@ import (
4
"net/http"
5
"strings"
6
7
- "github.com/caddyserver/caddy2"
8
- "github.com/caddyserver/caddy2/modules/caddyhttp"
7
+ "github.com/caddyserver/caddy"
8
+ "github.com/caddyserver/caddy/modules/caddyhttp"
9
)
10
11
func init() {
12
- caddy2.RegisterModule(caddy2.Module{
12
+ caddy.RegisterModule(caddy.Module{
13
Name: "http.middleware.headers",
14
New: func() interface{} { return new(Headers) },
15
})
@@ -38,7 +38,7 @@ type RespHeaderOps struct {
38
}
39
40
func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
41
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
41
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
42
apply(h.Request, r.Header, repl)
43
if h.Response.Deferred || h.Response.Require != nil {
44
w = &responseWriterWrapper{
@@ -53,7 +53,7 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhtt
53
return next.ServeHTTP(w, r)
54
}
55
56
-func apply(ops *HeaderOps, hdr http.Header, repl caddy2.Replacer) {
56
+func apply(ops *HeaderOps, hdr http.Header, repl caddy.Replacer) {
57
for fieldName, vals := range ops.Add {
58
fieldName = repl.ReplaceAll(fieldName, "")
59
for _, v := range vals {
@@ -76,19 +76,12 @@ func apply(ops *HeaderOps, hdr http.Header, repl caddy2.Replacer) {
76
// operations until WriteHeader is called.
77
type responseWriterWrapper struct {
78
*caddyhttp.ResponseWriterWrapper
79
- replacer caddy2.Replacer
79
+ replacer caddy.Replacer
80
require *caddyhttp.ResponseMatcher
81
headerOps *HeaderOps
82
wroteHeader bool
83
}
84
85
-func (rww *responseWriterWrapper) Write(d []byte) (int, error) {
86
- if !rww.wroteHeader {
87
- rww.WriteHeader(http.StatusOK)
88
- }
89
- return rww.ResponseWriterWrapper.Write(d)
90
-}
91
-
85
func (rww *responseWriterWrapper) WriteHeader(status int) {
86
if rww.wroteHeader {
87
return
@@ -100,6 +93,13 @@ func (rww *responseWriterWrapper) WriteHeader(status int) {
93
rww.ResponseWriterWrapper.WriteHeader(status)
94
}
95
96
+func (rww *responseWriterWrapper) Write(d []byte) (int, error) {
97
+ if !rww.wroteHeader {
98
+ rww.WriteHeader(http.StatusOK)
99
+ }
100
+ return rww.ResponseWriterWrapper.Write(d)
101
+}
102
+
103
// Interface guards
104
var (
105
_ caddyhttp.MiddlewareHandler = (*Headers)(nil)
modules/caddyhttp/markdown/markdown.go
+3
-3
@@ -6,12 +6,12 @@ import (
6
7
"gopkg.in/russross/blackfriday.v2"
8
9
- "github.com/caddyserver/caddy2"
10
- "github.com/caddyserver/caddy2/modules/caddyhttp"
9
+ "github.com/caddyserver/caddy"
10
+ "github.com/caddyserver/caddy/modules/caddyhttp"
11
)
12
13
func init() {
14
- caddy2.RegisterModule(caddy2.Module{
14
+ caddy.RegisterModule(caddy.Module{
15
Name: "http.middleware.markdown",
16
New: func() interface{} { return new(Markdown) },
17
})
modules/caddyhttp/matchers.go
+20
-20
@@ -13,8 +13,8 @@ import (
13
"regexp"
14
"strings"
15
16
- "github.com/caddyserver/caddy2"
17
- "github.com/caddyserver/caddy2/pkg/caddyscript"
16
+ "github.com/caddyserver/caddy"
17
+ "github.com/caddyserver/caddy/pkg/caddyscript"
18
"go.starlark.net/starlark"
19
)
20
@@ -65,47 +65,47 @@ type (
65
)
66
67
func init() {
68
- caddy2.RegisterModule(caddy2.Module{
68
+ caddy.RegisterModule(caddy.Module{
69
Name: "http.matchers.host",
70
New: func() interface{} { return new(MatchHost) },
71
})
72
- caddy2.RegisterModule(caddy2.Module{
72
+ caddy.RegisterModule(caddy.Module{
73
Name: "http.matchers.path",
74
New: func() interface{} { return new(MatchPath) },
75
})
76
- caddy2.RegisterModule(caddy2.Module{
76
+ caddy.RegisterModule(caddy.Module{
77
Name: "http.matchers.path_regexp",
78
New: func() interface{} { return new(MatchPathRE) },
79
})
80
- caddy2.RegisterModule(caddy2.Module{
80
+ caddy.RegisterModule(caddy.Module{
81
Name: "http.matchers.method",
82
New: func() interface{} { return new(MatchMethod) },
83
})
84
- caddy2.RegisterModule(caddy2.Module{
84
+ caddy.RegisterModule(caddy.Module{
85
Name: "http.matchers.query",
86
New: func() interface{} { return new(MatchQuery) },
87
})
88
- caddy2.RegisterModule(caddy2.Module{
88
+ caddy.RegisterModule(caddy.Module{
89
Name: "http.matchers.header",
90
New: func() interface{} { return new(MatchHeader) },
91
})
92
- caddy2.RegisterModule(caddy2.Module{
92
+ caddy.RegisterModule(caddy.Module{
93
Name: "http.matchers.header_regexp",
94
New: func() interface{} { return new(MatchHeaderRE) },
95
})
96
- caddy2.RegisterModule(caddy2.Module{
96
+ caddy.RegisterModule(caddy.Module{
97
Name: "http.matchers.protocol",
98
New: func() interface{} { return new(MatchProtocol) },
99
})
100
- caddy2.RegisterModule(caddy2.Module{
100
+ caddy.RegisterModule(caddy.Module{
101
Name: "http.matchers.remote_ip",
102
New: func() interface{} { return new(MatchRemoteIP) },
103
})
104
- caddy2.RegisterModule(caddy2.Module{
104
+ caddy.RegisterModule(caddy.Module{
105
Name: "http.matchers.not",
106
New: func() interface{} { return new(MatchNegate) },
107
})
108
- caddy2.RegisterModule(caddy2.Module{
108
+ caddy.RegisterModule(caddy.Module{
109
Name: "http.matchers.starlark_expr",
110
New: func() interface{} { return new(MatchStarlarkExpr) },
111
})
@@ -158,7 +158,7 @@ func (m MatchPath) Match(r *http.Request) bool {
158
159
// Match returns true if r matches m.
160
func (m MatchPathRE) Match(r *http.Request) bool {
161
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
161
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
162
return m.MatchRegexp.Match(r.URL.Path, repl, "path_regexp")
163
}
164
@@ -209,7 +209,7 @@ func (m MatchHeader) Match(r *http.Request) bool {
209
// Match returns true if r matches m.
210
func (m MatchHeaderRE) Match(r *http.Request) bool {
211
for field, rm := range m {
212
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
212
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
213
match := rm.Match(r.Header.Get(field), repl, "header_regexp")
214
if !match {
215
return false
@@ -262,7 +262,7 @@ func (m *MatchNegate) UnmarshalJSON(data []byte) error {
262
}
263
264
// Provision loads the matcher modules to be negated.
265
-func (m *MatchNegate) Provision(ctx caddy2.Context) error {
265
+func (m *MatchNegate) Provision(ctx caddy.Context) error {
266
for modName, rawMsg := range m.matchersRaw {
267
val, err := ctx.LoadModule("http.matchers."+modName, rawMsg)
268
if err != nil {
@@ -281,7 +281,7 @@ func (m MatchNegate) Match(r *http.Request) bool {
281
}
282
283
// Provision parses m's IP ranges, either from IP or CIDR expressions.
284
-func (m *MatchRemoteIP) Provision(ctx caddy2.Context) error {
284
+func (m *MatchRemoteIP) Provision(ctx caddy.Context) error {
285
for _, str := range m.Ranges {
286
if strings.Contains(str, "/") {
287
_, ipNet, err := net.ParseCIDR(str)
@@ -387,7 +387,7 @@ func (mre *MatchRegexp) Validate() error {
387
// (namespace). Capture groups stored to repl will take on
388
// the name "http.matchers.<scope>.<mre.Name>.<N>" where
389
// <N> is the name or number of the capture group.
390
-func (mre *MatchRegexp) Match(input string, repl caddy2.Replacer, scope string) bool {
390
+func (mre *MatchRegexp) Match(input string, repl caddy.Replacer, scope string) bool {
391
matches := mre.compiled.FindStringSubmatch(input)
392
if matches == nil {
393
return false
@@ -478,8 +478,8 @@ var (
478
_ RequestMatcher = (*MatchHeaderRE)(nil)
479
_ RequestMatcher = (*MatchProtocol)(nil)
480
_ RequestMatcher = (*MatchRemoteIP)(nil)
481
- _ caddy2.Provisioner = (*MatchRemoteIP)(nil)
481
+ _ caddy.Provisioner = (*MatchRemoteIP)(nil)
482
_ RequestMatcher = (*MatchNegate)(nil)
483
- _ caddy2.Provisioner = (*MatchNegate)(nil)
483
+ _ caddy.Provisioner = (*MatchNegate)(nil)
484
_ RequestMatcher = (*MatchStarlarkExpr)(nil)
485
)
modules/caddyhttp/matchers_test.go
+5
-5
@@ -8,7 +8,7 @@ import (
8
"net/url"
9
"testing"
10
11
- "github.com/caddyserver/caddy2"
11
+ "github.com/caddyserver/caddy"
12
)
13
14
func TestHostMatcher(t *testing.T) {
@@ -227,8 +227,8 @@ func TestPathREMatcher(t *testing.T) {
227
228
// set up the fake request and its Replacer
229
req := &http.Request{URL: &url.URL{Path: tc.input}}
230
- repl := caddy2.NewReplacer()
231
- ctx := context.WithValue(req.Context(), caddy2.ReplacerCtxKey, repl)
230
+ repl := caddy.NewReplacer()
231
+ ctx := context.WithValue(req.Context(), caddy.ReplacerCtxKey, repl)
232
req = req.WithContext(ctx)
233
addHTTPVarsToReplacer(repl, req, httptest.NewRecorder())
234
@@ -345,8 +345,8 @@ func TestHeaderREMatcher(t *testing.T) {
345
346
// set up the fake request and its Replacer
347
req := &http.Request{Header: tc.input, URL: new(url.URL)}
348
- repl := caddy2.NewReplacer()
349
- ctx := context.WithValue(req.Context(), caddy2.ReplacerCtxKey, repl)
348
+ repl := caddy.NewReplacer()
349
+ ctx := context.WithValue(req.Context(), caddy.ReplacerCtxKey, repl)
350
req = req.WithContext(ctx)
351
addHTTPVarsToReplacer(repl, req, httptest.NewRecorder())
352
modules/caddyhttp/replacer.go
+2
-2
@@ -7,13 +7,13 @@ import (
7
"path"
8
"strings"
9
10
- "github.com/caddyserver/caddy2"
10
+ "github.com/caddyserver/caddy"
11
)
12
13
// TODO: A simple way to format or escape or encode each value would be nice
14
// ... TODO: Should we just use templates? :-/ yeesh...
15
16
-func addHTTPVarsToReplacer(repl caddy2.Replacer, req *http.Request, w http.ResponseWriter) {
16
+func addHTTPVarsToReplacer(repl caddy.Replacer, req *http.Request, w http.ResponseWriter) {
17
httpVars := func() map[string]string {
18
m := make(map[string]string)
19
if req != nil {
modules/caddyhttp/requestbody/requestbody.go
+3
-3
@@ -3,12 +3,12 @@ package requestbody
3
import (
4
"net/http"
5
6
- "github.com/caddyserver/caddy2"
7
- "github.com/caddyserver/caddy2/modules/caddyhttp"
6
+ "github.com/caddyserver/caddy"
7
+ "github.com/caddyserver/caddy/modules/caddyhttp"
8
)
9
10
func init() {
11
- caddy2.RegisterModule(caddy2.Module{
11
+ caddy.RegisterModule(caddy.Module{
12
Name: "http.middleware.request_body",
13
New: func() interface{} { return new(RequestBody) },
14
})
modules/caddyhttp/responsewriter.go
+12
-8
@@ -19,31 +19,31 @@ type ResponseWriterWrapper struct {
19
}
20
21
// Hijack implements http.Hijacker. It simply calls the underlying
22
-// ResponseWriter's Hijack method if there is one, or returns an error.
22
+// ResponseWriter's Hijack method if there is one, or returns
23
+// ErrNotImplemented otherwise.
24
func (rww *ResponseWriterWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
25
if hj, ok := rww.ResponseWriter.(http.Hijacker); ok {
26
return hj.Hijack()
27
}
27
- return nil, nil, fmt.Errorf("not a hijacker")
28
+ return nil, nil, ErrNotImplemented
29
}
30
31
// Flush implements http.Flusher. It simply calls the underlying
31
-// ResponseWriter's Flush method if there is one, or panics.
32
+// ResponseWriter's Flush method if there is one.
33
func (rww *ResponseWriterWrapper) Flush() {
34
if f, ok := rww.ResponseWriter.(http.Flusher); ok {
35
f.Flush()
35
- } else {
36
- panic("not a flusher")
36
}
37
}
38
39
// Push implements http.Pusher. It simply calls the underlying
41
-// ResponseWriter's Push method if there is one, or returns an error.
40
+// ResponseWriter's Push method if there is one, or returns
41
+// ErrNotImplemented otherwise.
42
func (rww *ResponseWriterWrapper) Push(target string, opts *http.PushOptions) error {
43
- if pusher, hasPusher := rww.ResponseWriter.(http.Pusher); hasPusher {
43
+ if pusher, ok := rww.ResponseWriter.(http.Pusher); ok {
44
return pusher.Push(target, opts)
45
}
46
- return fmt.Errorf("not a pusher")
46
+ return ErrNotImplemented
47
}
48
49
// HTTPInterfaces mix all the interfaces that middleware ResponseWriters need to support.
@@ -54,5 +54,9 @@ type HTTPInterfaces interface {
54
http.Hijacker
55
}
56
57
+// ErrNotImplemented is returned when an underlying
58
+// ResponseWriter does not implement the required method.
59
+var ErrNotImplemented = fmt.Errorf("method not implemented")
60
+
61
// Interface guards
62
var _ HTTPInterfaces = (*ResponseWriterWrapper)(nil)
modules/caddyhttp/reverseproxy/module.go
+2
-2
@@ -1,12 +1,12 @@
1
package reverseproxy
2
3
import (
4
- "github.com/caddyserver/caddy2"
4
+ "github.com/caddyserver/caddy"
5
)
6
7
// Register caddy module.
8
func init() {
9
- caddy2.RegisterModule(caddy2.Module{
9
+ caddy.RegisterModule(caddy.Module{
10
Name: "http.responders.reverse_proxy",
11
New: func() interface{} { return new(LoadBalanced) },
12
})
modules/caddyhttp/reverseproxy/upstream.go
+4
-4
@@ -14,7 +14,7 @@ import (
14
"sync/atomic"
15
"time"
16
17
- "github.com/caddyserver/caddy2"
17
+ "github.com/caddyserver/caddy"
18
)
19
20
// CircuitBreaker defines the functionality of a circuit breaker module.
@@ -72,7 +72,7 @@ var (
72
)
73
74
// NewLoadBalancedReverseProxy returns a collection of Upstreams that are to be loadbalanced.
75
-func NewLoadBalancedReverseProxy(lb *LoadBalanced, ctx caddy2.Context) error {
75
+func NewLoadBalancedReverseProxy(lb *LoadBalanced, ctx caddy.Context) error {
76
// set defaults
77
if lb.NoHealthyUpstreamsMessage == "" {
78
lb.NoHealthyUpstreamsMessage = msgNoHealthyUpstreams
@@ -110,7 +110,7 @@ func NewLoadBalancedReverseProxy(lb *LoadBalanced, ctx caddy2.Context) error {
110
var cb CircuitBreaker
111
112
if uc.CircuitBreaker != nil {
113
- if _, err := caddy2.GetModule(cbModule); err == nil {
113
+ if _, err := caddy.GetModule(cbModule); err == nil {
114
val, err := ctx.LoadModule(cbModule, uc.CircuitBreaker)
115
if err == nil {
116
cbv, ok := val.(CircuitBreaker)
@@ -191,7 +191,7 @@ func (lb *LoadBalanced) Cleanup() error {
191
}
192
193
// Provision sets up a new loadbalanced reverse proxy.
194
-func (lb *LoadBalanced) Provision(ctx caddy2.Context) error {
194
+func (lb *LoadBalanced) Provision(ctx caddy.Context) error {
195
return NewLoadBalancedReverseProxy(lb, ctx)
196
}
197
modules/caddyhttp/rewrite/rewrite.go
+4
-4
@@ -5,12 +5,12 @@ import (
5
"net/url"
6
"strings"
7
8
- "github.com/caddyserver/caddy2"
9
- "github.com/caddyserver/caddy2/modules/caddyhttp"
8
+ "github.com/caddyserver/caddy"
9
+ "github.com/caddyserver/caddy/modules/caddyhttp"
10
)
11
12
func init() {
13
- caddy2.RegisterModule(caddy2.Module{
13
+ caddy.RegisterModule(caddy.Module{
14
Name: "http.middleware.rewrite",
15
New: func() interface{} { return new(Rewrite) },
16
})
@@ -24,7 +24,7 @@ type Rewrite struct {
24
}
25
26
func (rewr Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
27
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
27
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
28
var rehandleNeeded bool
29
30
if rewr.Method != "" {
modules/caddyhttp/routes.go
+2
-2
@@ -5,7 +5,7 @@ import (
5
"fmt"
6
"net/http"
7
8
- "github.com/caddyserver/caddy2"
8
+ "github.com/caddyserver/caddy"
9
)
10
11
// ServerRoute represents a set of matching rules,
@@ -56,7 +56,7 @@ func (mset MatcherSet) Match(r *http.Request) bool {
56
type RouteList []ServerRoute
57
58
// Provision sets up all the routes by loading the modules.
59
-func (routes RouteList) Provision(ctx caddy2.Context) error {
59
+func (routes RouteList) Provision(ctx caddy.Context) error {
60
for i, route := range routes {
61
// matchers
62
for _, matcherSet := range route.MatcherSets {
modules/caddyhttp/server.go
+9
-9
@@ -8,17 +8,17 @@ import (
8
"net/http"
9
"strconv"
10
11
- "github.com/caddyserver/caddy2"
12
- "github.com/caddyserver/caddy2/modules/caddytls"
11
+ "github.com/caddyserver/caddy"
12
+ "github.com/caddyserver/caddy/modules/caddytls"
13
)
14
15
// Server is an HTTP server.
16
type Server struct {
17
Listen []string `json:"listen,omitempty"`
18
- ReadTimeout caddy2.Duration `json:"read_timeout,omitempty"`
19
- ReadHeaderTimeout caddy2.Duration `json:"read_header_timeout,omitempty"`
20
- WriteTimeout caddy2.Duration `json:"write_timeout,omitempty"`
21
- IdleTimeout caddy2.Duration `json:"idle_timeout,omitempty"`
18
+ ReadTimeout caddy.Duration `json:"read_timeout,omitempty"`
19
+ ReadHeaderTimeout caddy.Duration `json:"read_header_timeout,omitempty"`
20
+ WriteTimeout caddy.Duration `json:"write_timeout,omitempty"`
21
+ IdleTimeout caddy.Duration `json:"idle_timeout,omitempty"`
22
MaxHeaderBytes int `json:"max_header_bytes,omitempty"`
23
Routes RouteList `json:"routes,omitempty"`
24
Errors *httpErrorConfig `json:"errors,omitempty"`
@@ -38,8 +38,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
38
}
39
40
// set up the context for the request
41
- repl := caddy2.NewReplacer()
42
- ctx := context.WithValue(r.Context(), caddy2.ReplacerCtxKey, repl)
41
+ repl := caddy.NewReplacer()
42
+ ctx := context.WithValue(r.Context(), caddy.ReplacerCtxKey, repl)
43
ctx = context.WithValue(ctx, TableCtxKey, make(map[string]interface{})) // TODO: Implement this
44
r = r.WithContext(ctx)
45
@@ -127,4 +127,4 @@ type httpErrorConfig struct {
127
}
128
129
// TableCtxKey is the context key for the request's variable table.
130
-const TableCtxKey caddy2.CtxKey = "table"
130
+const TableCtxKey caddy.CtxKey = "table"
modules/caddyhttp/staticresp.go
+3
-3
@@ -5,11 +5,11 @@ import (
5
"net/http"
6
"strconv"
7
8
- "github.com/caddyserver/caddy2"
8
+ "github.com/caddyserver/caddy"
9
)
10
11
func init() {
12
- caddy2.RegisterModule(caddy2.Module{
12
+ caddy.RegisterModule(caddy.Module{
13
Name: "http.responders.static",
14
New: func() interface{} { return new(Static) },
15
})
@@ -25,7 +25,7 @@ type Static struct {
25
}
26
27
func (s Static) ServeHTTP(w http.ResponseWriter, r *http.Request) error {
28
- repl := r.Context().Value(caddy2.ReplacerCtxKey).(caddy2.Replacer)
28
+ repl := r.Context().Value(caddy.ReplacerCtxKey).(caddy.Replacer)
29
30
// close the connection after responding
31
r.Close = s.Close
modules/caddyhttp/staticresp_test.go
+3
-3
@@ -7,7 +7,7 @@ import (
7
"net/http/httptest"
8
"testing"
9
10
- "github.com/caddyserver/caddy2"
10
+ "github.com/caddyserver/caddy"
11
)
12
13
func TestStaticResponseHandler(t *testing.T) {
@@ -44,8 +44,8 @@ func TestStaticResponseHandler(t *testing.T) {
44
45
func fakeRequest() *http.Request {
46
r, _ := http.NewRequest("GET", "/", nil)
47
- repl := caddy2.NewReplacer()
48
- ctx := context.WithValue(r.Context(), caddy2.ReplacerCtxKey, repl)
47
+ repl := caddy.NewReplacer()
48
+ ctx := context.WithValue(r.Context(), caddy.ReplacerCtxKey, repl)
49
r = r.WithContext(ctx)
50
return r
51
}
modules/caddyhttp/table.go
+3
-3
@@ -3,16 +3,16 @@ package caddyhttp
3
import (
4
"net/http"
5
6
- "github.com/caddyserver/caddy2"
6
+ "github.com/caddyserver/caddy"
7
)
8
9
func init() {
10
- caddy2.RegisterModule(caddy2.Module{
10
+ caddy.RegisterModule(caddy.Module{
11
Name: "http.middleware.table",
12
New: func() interface{} { return new(tableMiddleware) },
13
})
14
15
- caddy2.RegisterModule(caddy2.Module{
15
+ caddy.RegisterModule(caddy.Module{
16
Name: "http.matchers.table",
17
New: func() interface{} { return new(tableMatcher) },
18
})
modules/caddytls/acmemanager.go
+8
-8
@@ -7,13 +7,13 @@ import (
7
8
"github.com/go-acme/lego/certcrypto"
9
10
- "github.com/caddyserver/caddy2"
10
+ "github.com/caddyserver/caddy"
11
"github.com/go-acme/lego/challenge"
12
"github.com/mholt/certmagic"
13
)
14
15
func init() {
16
- caddy2.RegisterModule(caddy2.Module{
16
+ caddy.RegisterModule(caddy.Module{
17
Name: "tls.management.acme",
18
New: func() interface{} { return new(ACMEManagerMaker) },
19
})
@@ -30,9 +30,9 @@ func init() {
30
type ACMEManagerMaker struct {
31
CA string `json:"ca,omitempty"`
32
Email string `json:"email,omitempty"`
33
- RenewAhead caddy2.Duration `json:"renew_ahead,omitempty"`
33
+ RenewAhead caddy.Duration `json:"renew_ahead,omitempty"`
34
KeyType string `json:"key_type,omitempty"`
35
- ACMETimeout caddy2.Duration `json:"acme_timeout,omitempty"`
35
+ ACMETimeout caddy.Duration `json:"acme_timeout,omitempty"`
36
MustStaple bool `json:"must_staple,omitempty"`
37
Challenges ChallengesConfig `json:"challenges"`
38
OnDemand *OnDemandConfig `json:"on_demand,omitempty"`
@@ -49,7 +49,7 @@ func (m *ACMEManagerMaker) newManager(interactive bool) (certmagic.Manager, erro
49
}
50
51
// Provision sets up m.
52
-func (m *ACMEManagerMaker) Provision(ctx caddy2.Context) error {
52
+func (m *ACMEManagerMaker) Provision(ctx caddy.Context) error {
53
// DNS providers
54
if m.Challenges.DNS != nil {
55
val, err := ctx.LoadModuleInline("provider", "tls.dns", m.Challenges.DNSRaw)
@@ -66,7 +66,7 @@ func (m *ACMEManagerMaker) Provision(ctx caddy2.Context) error {
66
if err != nil {
67
return fmt.Errorf("loading TLS storage module: %s", err)
68
}
69
- cmStorage, err := val.(caddy2.StorageConverter).CertMagicStorage()
69
+ cmStorage, err := val.(caddy.StorageConverter).CertMagicStorage()
70
if err != nil {
71
return fmt.Errorf("creating TLS storage configuration: %v", err)
72
}
@@ -89,7 +89,7 @@ func (m *ACMEManagerMaker) SetDefaults() {
89
m.Email = certmagic.Default.Email
90
}
91
if m.RenewAhead == 0 {
92
- m.RenewAhead = caddy2.Duration(certmagic.Default.RenewDurationBefore)
92
+ m.RenewAhead = caddy.Duration(certmagic.Default.RenewDurationBefore)
93
}
94
if m.keyType == "" {
95
m.keyType = certmagic.Default.KeyType
@@ -102,7 +102,7 @@ func (m *ACMEManagerMaker) SetDefaults() {
102
// makeCertMagicConfig converts m into a certmagic.Config, because
103
// this is a special case where the default manager is the certmagic
104
// Config and not a separate manager.
105
-func (m *ACMEManagerMaker) makeCertMagicConfig(ctx caddy2.Context) certmagic.Config {
105
+func (m *ACMEManagerMaker) makeCertMagicConfig(ctx caddy.Context) certmagic.Config {
106
storage := m.storage
107
if storage == nil {
108
storage = ctx.Storage()
modules/caddytls/connpolicy.go
+3
-3
@@ -7,7 +7,7 @@ import (
7
"fmt"
8
"strings"
9
10
- "github.com/caddyserver/caddy2"
10
+ "github.com/caddyserver/caddy"
11
"github.com/go-acme/lego/challenge/tlsalpn01"
12
"github.com/mholt/certmagic"
13
)
@@ -20,7 +20,7 @@ type ConnectionPolicies []*ConnectionPolicy
20
// TLSConfig converts the group of policies to a standard-lib-compatible
21
// TLS configuration which selects the first matching policy based on
22
// the ClientHello.
23
-func (cp ConnectionPolicies) TLSConfig(ctx caddy2.Context) (*tls.Config, error) {
23
+func (cp ConnectionPolicies) TLSConfig(ctx caddy.Context) (*tls.Config, error) {
24
// set up each of the connection policies
25
for i, pol := range cp {
26
// matchers
@@ -110,7 +110,7 @@ type ConnectionPolicy struct {
110
stdTLSConfig *tls.Config
111
}
112
113
-func (p *ConnectionPolicy) buildStandardTLSConfig(ctx caddy2.Context) error {
113
+func (p *ConnectionPolicy) buildStandardTLSConfig(ctx caddy.Context) error {
114
tlsAppIface, err := ctx.App("tls")
115
if err != nil {
116
return fmt.Errorf("getting tls app: %v", err)
modules/caddytls/fileloader.go
+2
-2
@@ -5,11 +5,11 @@ import (
5
"fmt"
6
"io/ioutil"
7
8
- "github.com/caddyserver/caddy2"
8
+ "github.com/caddyserver/caddy"
9
)
10
11
func init() {
12
- caddy2.RegisterModule(caddy2.Module{
12
+ caddy.RegisterModule(caddy.Module{
13
Name: "tls.certificates.load_files",
14
New: func() interface{} { return fileLoader{} },
15
})
modules/caddytls/folderloader.go
+2
-2
@@ -10,11 +10,11 @@ import (
10
"path/filepath"
11
"strings"
12
13
- "github.com/caddyserver/caddy2"
13
+ "github.com/caddyserver/caddy"
14
)
15
16
func init() {
17
- caddy2.RegisterModule(caddy2.Module{
17
+ caddy.RegisterModule(caddy.Module{
18
Name: "tls.certificates.load_folders",
19
New: func() interface{} { return folderLoader{} },
20
})
modules/caddytls/matchers.go
+2
-2
@@ -3,14 +3,14 @@ package caddytls
3
import (
4
"crypto/tls"
5
6
- "github.com/caddyserver/caddy2"
6
+ "github.com/caddyserver/caddy"
7
)
8
9
// MatchServerName matches based on SNI.
10
type MatchServerName []string
11
12
func init() {
13
- caddy2.RegisterModule(caddy2.Module{
13
+ caddy.RegisterModule(caddy.Module{
14
Name: "tls.handshake_match.sni",
15
New: func() interface{} { return MatchServerName{} },
16
})
modules/caddytls/sessiontickets.go
+4
-4
@@ -9,13 +9,13 @@ import (
9
"sync"
10
"time"
11
12
- "github.com/caddyserver/caddy2"
12
+ "github.com/caddyserver/caddy"
13
)
14
15
// SessionTicketService configures and manages TLS session tickets.
16
type SessionTicketService struct {
17
KeySource json.RawMessage `json:"key_source,omitempty"`
18
- RotationInterval caddy2.Duration `json:"rotation_interval,omitempty"`
18
+ RotationInterval caddy.Duration `json:"rotation_interval,omitempty"`
19
MaxKeys int `json:"max_keys,omitempty"`
20
DisableRotation bool `json:"disable_rotation,omitempty"`
21
Disabled bool `json:"disabled,omitempty"`
@@ -27,13 +27,13 @@ type SessionTicketService struct {
27
mu *sync.Mutex
28
}
29
30
-func (s *SessionTicketService) provision(ctx caddy2.Context) error {
30
+func (s *SessionTicketService) provision(ctx caddy.Context) error {
31
s.configs = make(map[*tls.Config]struct{})
32
s.mu = new(sync.Mutex)
33
34
// establish sane defaults
35
if s.RotationInterval == 0 {
36
- s.RotationInterval = caddy2.Duration(defaultSTEKRotationInterval)
36
+ s.RotationInterval = caddy.Duration(defaultSTEKRotationInterval)
37
}
38
if s.MaxKeys <= 0 {
39
s.MaxKeys = defaultMaxSTEKs
modules/caddytls/standardstek/stek.go
+3
-3
@@ -5,12 +5,12 @@ import (
5
"sync"
6
"time"
7
8
- "github.com/caddyserver/caddy2"
9
- "github.com/caddyserver/caddy2/modules/caddytls"
8
+ "github.com/caddyserver/caddy"
9
+ "github.com/caddyserver/caddy/modules/caddytls"
10
)
11
12
func init() {
13
- caddy2.RegisterModule(caddy2.Module{
13
+ caddy.RegisterModule(caddy.Module{
14
Name: "tls.stek.standard",
15
New: func() interface{} { return new(standardSTEKProvider) },
16
})
modules/caddytls/tls.go
+5
-5
@@ -6,13 +6,13 @@ import (
6
"fmt"
7
"net/http"
8
9
- "github.com/caddyserver/caddy2"
9
+ "github.com/caddyserver/caddy"
10
"github.com/go-acme/lego/challenge"
11
"github.com/mholt/certmagic"
12
)
13
14
func init() {
15
- caddy2.RegisterModule(caddy2.Module{
15
+ caddy.RegisterModule(caddy.Module{
16
Name: "tls",
17
New: func() interface{} { return new(TLS) },
18
})
@@ -26,11 +26,11 @@ type TLS struct {
26
27
certificateLoaders []CertificateLoader
28
certCache *certmagic.Cache
29
- ctx caddy2.Context
29
+ ctx caddy.Context
30
}
31
32
// Provision sets up the configuration for the TLS app.
33
-func (t *TLS) Provision(ctx caddy2.Context) error {
33
+func (t *TLS) Provision(ctx caddy.Context) error {
34
t.ctx = ctx
35
36
// set up the certificate cache
@@ -189,7 +189,7 @@ type AutomationPolicy struct {
189
Management managerMaker `json:"-"`
190
}
191
192
-func (ap AutomationPolicy) makeCertMagicConfig(ctx caddy2.Context) certmagic.Config {
192
+func (ap AutomationPolicy) makeCertMagicConfig(ctx caddy.Context) certmagic.Config {
193
// default manager (ACME) is a special case because of how CertMagic is designed
194
// TODO: refactor certmagic so that ACME manager is not a special case by extracting
195
// its config fields out of the certmagic.Config struct, or something...
modules_test.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"reflect"
pkg/caddyscript/matcherenv.go
+1
-1
@@ -3,7 +3,7 @@ package caddyscript
3
import (
4
"net/http"
5
6
- caddyscript "github.com/caddyserver/caddy2/pkg/caddyscript/lib"
6
+ caddyscript "github.com/caddyserver/caddy/pkg/caddyscript/lib"
7
"go.starlark.net/starlark"
8
)
9
replacer.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"os"
storage.go
+1
-1
@@ -1,4 +1,4 @@
1
-package caddy2
1
+package caddy
2
3
import (
4
"os"