mirror of
https://github.com/caddyserver/caddy.git
synced 2025-03-09 07:29:03 -04:00
caddytls: Refactor sni matcher (#6812)
This commit is contained in:
parent
066d770409
commit
d7872c3bfa
@ -56,7 +56,7 @@ func (MatchServerName) CaddyModule() caddy.ModuleInfo {
|
|||||||
|
|
||||||
// Match matches hello based on SNI.
|
// Match matches hello based on SNI.
|
||||||
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
|
func (m MatchServerName) Match(hello *tls.ClientHelloInfo) bool {
|
||||||
repl := caddy.NewReplacer()
|
var repl *caddy.Replacer
|
||||||
// caddytls.TestServerNameMatcher calls this function without any context
|
// caddytls.TestServerNameMatcher calls this function without any context
|
||||||
if ctx := hello.Context(); ctx != nil {
|
if ctx := hello.Context(); ctx != nil {
|
||||||
// In some situations the existing context may have no replacer
|
// 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 {
|
for _, name := range m {
|
||||||
rs := repl.ReplaceAll(name, "")
|
rs := repl.ReplaceAll(name, "")
|
||||||
if certmagic.MatchWildcard(hello.ServerName, rs) {
|
if certmagic.MatchWildcard(hello.ServerName, rs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user