mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-02 06:07:21 +01:00
caddytls: Refactor sni matcher (#6812)
This commit is contained in:
parent
066d770409
commit
d7872c3bfa
1 changed files with 5 additions and 1 deletions
|
@ -56,7 +56,7 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
|
|||
|
||||
// Match matches hello based on SNI.
|
||||
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
|
||||
repl := caddy.NewReplacer()
|
||||
var repl *caddy.Replacer
|
||||
// caddytls.TestServerNameMatcher calls this function without any context
|
||||
if ctx := hello.Context(); ctx != nil {
|
||||
// In some situations the existing context may have no replacer
|
||||
|
@ -65,6 +65,10 @@ func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
|
|||
}
|
||||
}
|
||||
|
||||
if repl == nil {
|
||||
repl = caddy.NewReplacer()
|
||||
}
|
||||
|
||||
for _, name := range m {
|
||||
rs := repl.ReplaceAll(name, "")
|
||||
if certmagic.MatchWildcard(hello.ServerName, rs) {
|
||||
|
|
Loading…
Reference in a new issue