mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-22 12:28:45 +08:00
httpcaddyfile: Fix tls certificate loader module names (#2748)
This commit is contained in:
parent
ed40a5dcab
commit
d0c1756fc5
|
@ -183,7 +183,7 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock,
|
||||||
if clVals, ok := sblock.pile["tls.certificate_loader"]; ok {
|
if clVals, ok := sblock.pile["tls.certificate_loader"]; ok {
|
||||||
for _, clVal := range clVals {
|
for _, clVal := range clVals {
|
||||||
loader := clVal.Value.(caddytls.CertificateLoader)
|
loader := clVal.Value.(caddytls.CertificateLoader)
|
||||||
loaderName := caddy.GetModuleName(loader)
|
loaderName := caddy.GetModuleID(loader)
|
||||||
tlsApp.Certificates[loaderName] = caddyconfig.JSON(loader, &warnings)
|
tlsApp.Certificates[loaderName] = caddyconfig.JSON(loader, &warnings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
modules.go
11
modules.go
|
@ -126,6 +126,17 @@ func GetModuleName(instance interface{}) string {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetModuleID returns a module's ID (the last element of its name)
|
||||||
|
// from an instance of its value. If the value is not a module,
|
||||||
|
// an empty string will be returned.
|
||||||
|
func GetModuleID(instance interface{}) string {
|
||||||
|
var name string
|
||||||
|
if mod, ok := instance.(Module); ok {
|
||||||
|
name = mod.CaddyModule().ID()
|
||||||
|
}
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
// GetModules returns all modules in the given scope/namespace.
|
// GetModules returns all modules in the given scope/namespace.
|
||||||
// For example, a scope of "foo" returns modules named "foo.bar",
|
// For example, a scope of "foo" returns modules named "foo.bar",
|
||||||
// "foo.loo", but not "bar", "foo.bar.loo", etc. An empty scope
|
// "foo.loo", but not "bar", "foo.bar.loo", etc. An empty scope
|
||||||
|
|
Loading…
Reference in New Issue
Block a user