mirror of
https://github.com/coredns/coredns.git
synced 2026-08-20 23:08:28 -04:00
plugin/forward: Add http(2) host/authority header and TO server resolution (#8233)
This commit is contained in:
@@ -228,6 +228,13 @@ func (p *Proxy) lookupDoH(ctx context.Context, state request.Request, _ Options)
|
||||
// DoH always runs over TCP (HTTPS), regardless of the downstream
|
||||
// client's protocol.
|
||||
const proto = "tcp"
|
||||
// records the origin Id before upstream.
|
||||
originId := state.Req.Id
|
||||
// RFC8484 has DNS ID of 0 as a SHOULD
|
||||
state.Req.Id = 0
|
||||
defer func() {
|
||||
state.Req.Id = originId
|
||||
}()
|
||||
|
||||
var localAddr net.Addr
|
||||
trace := &httptrace.ClientTrace{
|
||||
@@ -237,7 +244,7 @@ func (p *Proxy) lookupDoH(ctx context.Context, state request.Request, _ Options)
|
||||
}
|
||||
ctx = httptrace.WithClientTrace(ctx, trace)
|
||||
|
||||
req, err := doh.NewRequestWithContext(ctx, p.dohMethod, p.addr, state.Req)
|
||||
req, err := doh.NewRequestWithContext(ctx, p.dohMethod, p.addr, p.dohHost, state.Req)
|
||||
if err != nil {
|
||||
return nil, nil, proto, err
|
||||
}
|
||||
@@ -253,6 +260,10 @@ func (p *Proxy) lookupDoH(ctx context.Context, state request.Request, _ Options)
|
||||
return nil, localAddr, proto, err
|
||||
}
|
||||
|
||||
// recovery the origin Id after upstream.
|
||||
if ret != nil {
|
||||
ret.Id = originId
|
||||
}
|
||||
return ret, localAddr, proto, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user