Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 03:15 UTC
caddytls: Refactor sni matcher (#6812)
vnxme committed
Jan 27, 2025 at 21:42 UTC
d7872c3bfa673ce9584d00f01a725b93fa7bedf1
1 file changed
+5
-1
modules/caddytls/matchers.go
+5
-1
@@ -56,7 +56,7 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
56
57
// Match matches hello based on SNI.
58
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
59
- repl := caddy.NewReplacer()
59
+ var repl *caddy.Replacer
60
// caddytls.TestServerNameMatcher calls this function without any context
61
if ctx := hello.Context(); ctx != nil {
62
// In some situations the existing context may have no replacer
@@ -65,6 +65,10 @@ func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
65
}
66
}
67
68
+ if repl == nil {
69
+ repl = caddy.NewReplacer()
70
+ }
71
+
72
for _, name := range m {
73
rs := repl.ReplaceAll(name, "")
74
if certmagic.MatchWildcard(hello.ServerName, rs) {