@marcel91200 / caddy Mirror · read-only / commits / d0c1756f
Fork 0

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

httpcaddyfile: Fix tls certificate loader module names (#2748)

Matthew Holt committed Sep 13, 2019 at 09:45 UTC d0c1756fc56dd43cee73ef7ccabb2276a5b26caf
2 files changed +12 -1
caddyconfig/httpcaddyfile/httptype.go
+1 -1
@@ -183,7 +183,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock,
183 if clVals, ok := sblock.pile["tls.certificate_loader"]; ok {
184 for _, clVal := range clVals {
185 loader := clVal.Value.(caddytls.CertificateLoader)
186 - loaderName := caddy.GetModuleName(loader)
186 + loaderName := caddy.GetModuleID(loader)
187 tlsApp.Certificates[loaderName] = caddyconfig.JSON(loader, &warnings)
188 }
189 }
modules.go
+11
@@ -126,6 +126,17 @@ func GetModuleName(instance interface{}) string {
126 return name
127 }
128
129 +// GetModuleID returns a module's ID (the last element of its name)
130 +// from an instance of its value. If the value is not a module,
131 +// an empty string will be returned.
132 +func GetModuleID(instance interface{}) string {
133 + var name string
134 + if mod, ok := instance.(Module); ok {
135 + name = mod.CaddyModule().ID()
136 + }
137 + return name
138 +}
139 +
140 // GetModules returns all modules in the given scope/namespace.
141 // For example, a scope of "foo" returns modules named "foo.bar",
142 // "foo.loo", but not "bar", "foo.bar.loo", etc. An empty scope