Skip to content

Commit

Permalink
Fix tls alpn matcher (#260)
Browse files Browse the repository at this point in the history
The context may have no replacer
  • Loading branch information
vnxme authored Nov 11, 2024
1 parent ec8fae2 commit 3c6cc2c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/l4tls/alpn_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ func (*MatchALPN) CaddyModule() caddy.ModuleInfo {
}

func (m *MatchALPN) Match(hello *tls.ClientHelloInfo) bool {
repl := hello.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
repl := caddy.NewReplacer()
if ctx := hello.Context(); ctx != nil {
// In some situations the existing context may have no replacer
if replAny := ctx.Value(caddy.ReplacerCtxKey); replAny != nil {
repl = replAny.(*caddy.Replacer)
}
}

clientProtocols := hello.SupportedProtos
for _, alpn := range *m {
alpn = repl.ReplaceAll(alpn, "")
Expand Down

0 comments on commit 3c6cc2c

Please sign in to comment.