diff options
author | vnxme <[email protected]> | 2024-08-12 10:01:09 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-12 10:01:09 +0300 |
commit | 7cf8376e638948490be3e9eb5c7d58ce2a4b93b3 (patch) | |
tree | 4f106175677ca0a443d515a70dd7a622e6a407b5 /modules | |
parent | 21af88fefc9a8239a024f635f1c6fdd9defd7eb7 (diff) | |
download | caddy-7cf8376e638948490be3e9eb5c7d58ce2a4b93b3.tar.gz caddy-7cf8376e638948490be3e9eb5c7d58ce2a4b93b3.zip |
matchers: fix a regression in #6480 (#6510)
The context may have no replacer
Diffstat (limited to 'modules')
-rw-r--r-- | modules/caddytls/matchers.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/caddytls/matchers.go b/modules/caddytls/matchers.go index 83a464713..f94622374 100644 --- a/modules/caddytls/matchers.go +++ b/modules/caddytls/matchers.go @@ -50,12 +50,13 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo { // Match matches hello based on SNI. func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool { + repl := caddy.NewReplacer() // caddytls.TestServerNameMatcher calls this function without any context - var repl *caddy.Replacer if ctx := hello.Context(); ctx != nil { - repl = ctx.Value(caddy.ReplacerCtxKey).(*caddy.Replacer) - } else { - repl = caddy.NewReplacer() + // In some situations the existing context may have no replacer + if replAny := ctx.Value(caddy.ReplacerCtxKey); replAny != nil { + repl = replAny.(*caddy.Replacer) + } } for _, name := range m { |