diff --git a/pkg/muxer/tcp/mux.go b/pkg/muxer/tcp/mux.go index 5bf4fbc08..8302ab340 100644 --- a/pkg/muxer/tcp/mux.go +++ b/pkg/muxer/tcp/mux.go @@ -310,7 +310,7 @@ func alpn(tree *matchersTree, protos ...string) error { return nil } -var hostOrIP = regexp.MustCompile(`^[[:alnum:]\.\-\:]+$`) +var hostOrIP = regexp.MustCompile(`^[[:word:]\.\-\:]+$`) // hostSNI checks if the SNI Host of the connection match the matcher host. func hostSNI(tree *matchersTree, hosts ...string) error { diff --git a/pkg/muxer/tcp/mux_test.go b/pkg/muxer/tcp/mux_test.go index 45820acdb..aa3c6b1e6 100644 --- a/pkg/muxer/tcp/mux_test.go +++ b/pkg/muxer/tcp/mux_test.go @@ -743,6 +743,11 @@ func Test_HostSNI(t *testing.T) { ruleHosts: []string{"foo.bar"}, serverName: "foo.bar", }, + { + desc: "Matching hosts with subdomains with _", + ruleHosts: []string{"foo_bar.example.com"}, + serverName: "foo_bar.example.com", + }, { desc: "Matching IPv4", ruleHosts: []string{"127.0.0.1"},