plugin/reload: hash the configuration executed by each instance (#8642)

Signed-off-by: houyuwushang <180804215+houyuwushang@users.noreply.github.com>
This commit is contained in:
houyuwushang
2026-10-21 11:33:54 +08:00
committed by GitHub
parent a6fde3fe33
commit e7f823b261
5 changed files with 346 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ package dnsserver
import (
"context"
"crypto/sha512"
"crypto/tls"
"fmt"
"net/http"
@@ -211,6 +212,13 @@ func GetConfig(c *caddy.Controller) *Config {
return GetConfig(c)
}
// GetConfigHash returns the SHA512 hash of the parsed configuration for c's
// instance, including all server blocks and expanded imports. It is captured
// before server block normalization and plugin setup, without re-reading files.
func GetConfigHash(c *caddy.Controller) [sha512.Size]byte {
return c.Context().(*dnsContext).configHash
}
// AddPluginToAllServerBlocks adds m once to every server block in c's
// instance. It is intended for directives that must handle traffic on a
// listener other than the one where the directive is configured.