diff options
author | Andreas Schneider <aksdb@gmx.de> | 2019-10-30 22:12:42 +0100 |
---|---|---|
committer | Matt Holt <mholt@users.noreply.github.com> | 2019-10-30 15:12:42 -0600 |
commit | 432b94239d6096e75b413de5a79c6707ab808bc9 (patch) | |
tree | 4c7dcef291ff40ea0fed7d6ca24f059a9c379cb8 /caddyconfig/httpcaddyfile | |
parent | 4611537f06da0fe77214e4b2c3b4a3330ace0506 (diff) |
admin listener as opt-in for initial config (#2834)
* Always cleanup admin endpoint first
* Error out if no config has been set (#2833)
* Ignore explicitly missing admin config (#2833)
* Separate config loading from admin initialization (#2833)
* Add admin option to specify admin listener address (#2833)
* Use zap for reporting admin endpoint status
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r-- | caddyconfig/httpcaddyfile/httptype.go | 5 | ||||
-rw-r--r-- | caddyconfig/httpcaddyfile/options.go | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index bc546b4..05022d1 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -74,6 +74,8 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, val, err = parseOptACMECA(disp) case "email": val, err = parseOptEmail(disp) + case "admin": + val, err = parseOptAdmin(disp) default: return nil, warnings, fmt.Errorf("unrecognized parameter name: %s", dir) } @@ -254,6 +256,9 @@ func (st ServerType) Setup(originalServerBlocks []caddyfile.ServerBlock, storageCvtr.(caddy.Module).CaddyModule().ID(), &warnings) } + if adminConfig, ok := options["admin"].(string); ok && adminConfig != "" { + cfg.Admin = &caddy.AdminConfig{Listen: adminConfig} + } return cfg, warnings, nil } diff --git a/caddyconfig/httpcaddyfile/options.go b/caddyconfig/httpcaddyfile/options.go index a60d060..74ec507 100644 --- a/caddyconfig/httpcaddyfile/options.go +++ b/caddyconfig/httpcaddyfile/options.go @@ -132,3 +132,17 @@ func parseOptEmail(d *caddyfile.Dispenser) (string, error) { } return val, nil } + +func parseOptAdmin(d *caddyfile.Dispenser) (string, error) { + if d.Next() { + var listenAddress string + d.AllArgs(&listenAddress) + + if listenAddress == "" { + listenAddress = caddy.DefaultAdminListen + } + + return listenAddress, nil + } + return "", nil +} |