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, 09:30 UTC
matchers: fix a regression in #6480 (#6510)
The context may have no replacer
vnxme committed
Aug 12, 2024 at 10:01 UTC
7cf8376e638948490be3e9eb5c7d58ce2a4b93b3
1 file changed
+5
-4
modules/caddytls/matchers.go
+5
-4
@@ -50,12 +50,13 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
50
51
// Match matches hello based on SNI.
52
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
53
+ repl := caddy.NewReplacer()
54
// caddytls.TestServerNameMatcher calls this function without any context
54
- var repl *caddy.Replacer
55
if ctx := hello.Context(); ctx != nil {
56
- repl = ctx.Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
57
- } else {
58
- repl = caddy.NewReplacer()
56
+ // In some situations the existing context may have no replacer
57
+ if replAny := ctx.Value(caddy.ReplacerCtxKey); replAny != nil {
58
+ repl = replAny.(*caddy.Replacer)
59
+ }
60
}
61
62
for _, name := range m {