plugin/forward ensure forward sets the DOH host (#8470)

* ensure forward sets the DOH host

Signed-off-by: ccie57654 <ccie57654@proton.me>

* added DoHHost value test

Signed-off-by: ccie57654 <ccie57654@proton.me>

---------

Signed-off-by: ccie57654 <ccie57654@proton.me>
This commit is contained in:
llucas
2026-09-28 05:40:16 -07:00
committed by GitHub
parent 72160e6e20
commit 0e9d7f4d05
2 changed files with 13 additions and 3 deletions

View File

@@ -242,7 +242,8 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
} }
// Only set this for proxies that need it. // Only set this for proxies that need it.
if transports[i] == transport.TLS || transports[i] == transport.QUIC { if transports[i] == transport.TLS || transports[i] == transport.HTTPS || transports[i] == transport.QUIC {
f.proxies[i].SetDOHHost(f.tlsConfig.ServerName)
if tlsConfig, ok := perServerNameTlsConfig[tlsServerNames[i]]; ok { if tlsConfig, ok := perServerNameTlsConfig[tlsServerNames[i]]; ok {
f.proxies[i].SetTLSConfig(tlsConfig) f.proxies[i].SetTLSConfig(tlsConfig)
} else { } else {

View File

@@ -960,8 +960,17 @@ func TestSetupDOHHealthcheckTLSConfig(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
got := fs[0]. p := fs[0].proxies[0]
proxies[0].
if gothost := p.DoHHost(); gothost != "dns.example" {
t.Fatalf(
"Expected dohHost %q, got %q",
"dns.example",
gothost,
)
}
got := p.
GetHealthchecker(). GetHealthchecker().
GetTLSConfig() GetTLSConfig()