Fix Ping upstream cause ctrld crash

dohTransport returns a http.RoundTripper. When pinging upstream, we do
it both for doh and doh3, and checking whether the transport is nil
before performing the check.

However, dohTransport returns a concrete *http.Transport. Thus
dohTransport will always return a non-nil http.Roundtripper, causing
invalid memory dereference when upstream is configured to use doh3.

Performing ping upstream separately will fix the issue.
This commit is contained in:
Cuong Manh Le
2023-07-06 23:42:04 +07:00
committed by Cuong Manh Le
parent ab1d7fd796
commit 3f3c1d6d78

View File

@@ -407,8 +407,12 @@ func (uc *UpstreamConfig) Ping() {
}
for _, typ := range []uint16{dns.TypeA, dns.TypeAAAA} {
ping(uc.dohTransport(typ))
ping(uc.doh3Transport(typ))
switch uc.Type {
case ResolverTypeDOH:
ping(uc.dohTransport(typ))
case ResolverTypeDOH3:
ping(uc.doh3Transport(typ))
}
}
}