Add validation for wildcard server names
This commit is contained in:
parent
cdd6437380
commit
d74ea25df8
3 changed files with 35 additions and 1 deletions
|
|
@ -182,6 +182,7 @@ var (
|
|||
"buildMirrorLocations": buildMirrorLocations,
|
||||
"shouldLoadAuthDigestModule": shouldLoadAuthDigestModule,
|
||||
"shouldLoadInfluxDBModule": shouldLoadInfluxDBModule,
|
||||
"buildServerName": buildServerName,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -1459,3 +1460,15 @@ func shouldLoadInfluxDBModule(s interface{}) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
// buildServerName ensures wildcard hostnames are valid
|
||||
func buildServerName(hostname string) string {
|
||||
if !strings.HasPrefix(hostname, "*") {
|
||||
return hostname
|
||||
}
|
||||
|
||||
hostname = strings.Replace(hostname, "*.", "", 1)
|
||||
parts := strings.Split(hostname, ".")
|
||||
|
||||
return `~^(?<subdomain>[\w-]+)\.` + strings.Join(parts, "\\.") + `$`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue