mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-07 06:25:24 -04:00
Add ServerBlockIndex and ServerBlockHosts to Controller
This way, Setup functions have access to the list of hosts that share the server block, and also, if needed for some reason, the index of the server block in the input
This commit is contained in:
@@ -312,3 +312,15 @@ type (
|
||||
Host, Port string
|
||||
}
|
||||
)
|
||||
|
||||
// HostList converts the list of addresses (hosts)
|
||||
// that are associated with this server block into
|
||||
// a slice of strings. Each string is a host:port
|
||||
// combination.
|
||||
func (sb serverBlock) HostList() []string {
|
||||
sbHosts := make([]string, len(sb.Addresses))
|
||||
for j, addr := range sb.Addresses {
|
||||
sbHosts[j] = net.JoinHostPort(addr.Host, addr.Port)
|
||||
}
|
||||
return sbHosts
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user