Add wildcard hostname support for SSL passthrough

This commit is contained in:
rkevin 2024-09-18 03:26:35 -07:00
parent 9e6c40664f
commit e2995f3b90

View file

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"strings"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@ -46,10 +47,15 @@ func (p *TCPProxy) Get(host string) *TCPServer {
return p.Default return p.Default
} }
_, parentHost, hasParentHost := strings.Cut(host, ".")
for _, s := range p.ServerList { for _, s := range p.ServerList {
if s.Hostname == host { if s.Hostname == host {
return s return s
} }
if strings.HasPrefix(s.Hostname, "*.") && hasParentHost && parentHost == s.Hostname[2:] {
return s
}
} }
return p.Default return p.Default