Skip to content

Commit

Permalink
Add wildcard hostname support for SSL passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
rkevin-arch committed Sep 18, 2024
1 parent 9e6c406 commit e2995f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/tcpproxy/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"net"
"strings"

"k8s.io/klog/v2"

Expand All @@ -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
Expand Down

0 comments on commit e2995f3

Please sign in to comment.