Skip to content

Commit d7872c3

Browse files
authored
caddytls: Refactor sni matcher (#6812)
1 parent 066d770 commit d7872c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/caddytls/matchers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
5656

5757
// Match matches hello based on SNI.
5858
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
59-
repl := caddy.NewReplacer()
59+
var repl *caddy.Replacer
6060
// caddytls.TestServerNameMatcher calls this function without any context
6161
if ctx := hello.Context(); ctx != nil {
6262
// In some situations the existing context may have no replacer
@@ -65,6 +65,10 @@ func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
6565
}
6666
}
6767

68+
if repl == nil {
69+
repl = caddy.NewReplacer()
70+
}
71+
6872
for _, name := range m {
6973
rs := repl.ReplaceAll(name, "")
7074
if certmagic.MatchWildcard(hello.ServerName, rs) {

0 commit comments

Comments
 (0)