summaryrefslogtreecommitdiffhomepage
path: root/admin.go
diff options
context:
space:
mode:
authorCory Cooper <[email protected]>2022-09-29 10:24:52 -0700
committerGitHub <[email protected]>2022-09-29 11:24:52 -0600
commit037dc23cad3848050dc1e6f4dfdabeb6ea190fa7 (patch)
treedbf43ea76181e2a98245e90c1269434a178e1833 /admin.go
parentab720fb768a2602f940cb7296c34021b5bb6c7e6 (diff)
downloadcaddy-037dc23cad3848050dc1e6f4dfdabeb6ea190fa7.tar.gz
caddy-037dc23cad3848050dc1e6f4dfdabeb6ea190fa7.zip
admin: Use replacer on listen addresses (#5071)
* admin: use replacer on listen address * admin: consolidate replacer logic
Diffstat (limited to 'admin.go')
-rw-r--r--admin.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/admin.go b/admin.go
index a23a1ac7d..db46e713c 100644
--- a/admin.go
+++ b/admin.go
@@ -57,7 +57,7 @@ type AdminConfig struct {
// The address to which the admin endpoint's listener should
// bind itself. Can be any single network address that can be
- // parsed by Caddy. Default: localhost:2019
+ // parsed by Caddy. Accepts placeholders. Default: localhost:2019
Listen string `json:"listen,omitempty"`
// If true, CORS headers will be emitted, and requests to the
@@ -156,7 +156,7 @@ type IdentityConfig struct {
//
// EXPERIMENTAL: Subject to change.
type RemoteAdmin struct {
- // The address on which to start the secure listener.
+ // The address on which to start the secure listener. Accepts placeholders.
// Default: :2021
Listen string `json:"listen,omitempty"`
@@ -1247,7 +1247,10 @@ func (e APIError) Error() string {
// parseAdminListenAddr extracts a singular listen address from either addr
// or defaultAddr, returning the network and the address of the listener.
func parseAdminListenAddr(addr string, defaultAddr string) (NetworkAddress, error) {
- input := addr
+ input, err := NewReplacer().ReplaceOrErr(addr, true, true)
+ if err != nil {
+ return NetworkAddress{}, fmt.Errorf("replacing listen address: %v", err)
+ }
if input == "" {
input = defaultAddr
}