1
0
Fork 0

Adds the support for IPv6 in the TCP HostSNI matcher

This commit is contained in:
Romain 2023-02-14 15:04:05 +01:00 committed by GitHub
parent e053eb6f17
commit 1a6dfe1f6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 4 deletions

View file

@ -315,7 +315,7 @@ func alpn(tree *matchersTree, protos ...string) error {
return nil
}
var almostFQDN = regexp.MustCompile(`^[[:alnum:]\.-]+$`)
var hostOrIP = regexp.MustCompile(`^[[:alnum:]\.\-\:]+$`)
// hostSNI checks if the SNI Host of the connection match the matcher host.
func hostSNI(tree *matchersTree, hosts ...string) error {
@ -329,8 +329,8 @@ func hostSNI(tree *matchersTree, hosts ...string) error {
continue
}
if !almostFQDN.MatchString(host) {
return fmt.Errorf("invalid value for \"HostSNI\" matcher, %q is not a valid hostname", host)
if !hostOrIP.MatchString(host) {
return fmt.Errorf("invalid value for \"HostSNI\" matcher, %q is not a valid hostname or IP", host)
}
hosts[i] = strings.ToLower(host)