From e2995f3b907d3cfb868b1750f31ca69804853cba Mon Sep 17 00:00:00 2001 From: rkevin Date: Wed, 18 Sep 2024 03:26:35 -0700 Subject: [PATCH] Add wildcard hostname support for SSL passthrough --- pkg/tcpproxy/tcp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/tcpproxy/tcp.go b/pkg/tcpproxy/tcp.go index fba4d21be8..33e7a45cbf 100644 --- a/pkg/tcpproxy/tcp.go +++ b/pkg/tcpproxy/tcp.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "net" + "strings" "k8s.io/klog/v2" @@ -46,10 +47,15 @@ func (p *TCPProxy) Get(host string) *TCPServer { return p.Default } + _, parentHost, hasParentHost := strings.Cut(host, ".") + for _, s := range p.ServerList { if s.Hostname == host { return s } + if strings.HasPrefix(s.Hostname, "*.") && hasParentHost && parentHost == s.Hostname[2:] { + return s + } } return p.Default