@marcel91200 / caddy Mirror · read-only / commits / f7f6e371
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

tls: Slight adjustment to how DNS provider modules are loaded

We don't load the provider directly, because the lego provider types aren't designed for JSON configuration and they are not implemented as Caddy modules (there are some setup steps which a Provision call would need to do, but they do not have Provision methods, they have their own constructor functions that we have to wrap). Instead of loading the challenge providers directly, the modules are simple wrappers over the challenge providers, to facilitate the JSON config structure and to provide a consistent experience. This also lets us swap out the underlying challenge providers transparently if needed; it acts as a layer of abstraction.

Matthew Holt committed Feb 7, 2020 at 21:59 UTC f7f6e371efcc6ddbbef56cd02c9e02fbcede033f
1 file changed +11 -1
modules/caddytls/acmemanager.go
+11 -1
@@ -111,7 +111,11 @@ func (m *ACMEManagerMaker) Provision(ctx caddy.Context) error {
111 if err != nil {
112 return fmt.Errorf("loading DNS provider module: %v", err)
113 }
114 - m.Challenges.DNS = val.(challenge.Provider)
114 + prov, err := val.(DNSProviderMaker).NewDNSProvider()
115 + if err != nil {
116 + return fmt.Errorf("making DNS provider: %v", err)
117 + }
118 + m.Challenges.DNS = prov
119 }
120
121 // policy-specific storage implementation
@@ -238,5 +242,11 @@ func onDemandAskRequest(ask string, name string) error {
242 return nil
243 }
244
245 +// DNSProviderMaker is a type that can create a new DNS provider.
246 +// Modules in the tls.dns namespace should implement this interface.
247 +type DNSProviderMaker interface {
248 + NewDNSProvider() (challenge.Provider, error)
249 +}
250 +
251 // Interface guard
252 var _ ManagerMaker = (*ACMEManagerMaker)(nil)