Merge pull request #27758 from nullspoon/fix-dns-pinning

This commit is contained in:
John Molakvoæ 2021-07-05 17:37:51 +02:00 committed by GitHub
commit b396aee333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,15 +112,22 @@ class DnsPinMiddleware {
$targetIps = $this->dnsResolve($hostName, 0);
foreach ($targetIps as $ip) {
$this->localAddressChecker->ThrowIfLocalIp($ip);
$curlResolves = [];
foreach ($ports as $port) {
$curlEntry = $hostName . ':' . $port . ':' . $ip;
$options['curl'][CURLOPT_RESOLVE][] = $curlEntry;
foreach ($ports as $port) {
$curlResolves["$hostName:$port"] = [];
foreach ($targetIps as $ip) {
$this->localAddressChecker->ThrowIfLocalIp($ip);
$curlResolves["$hostName:$port"][] = $ip;
}
}
// Coalesce the per-host:port ips back into a comma separated list
foreach ($curlResolves as $hostport => $ips) {
$options['curl'][CURLOPT_RESOLVE][] = "$hostport:" . implode(',', $ips);
}
return $handler($request, $options);
};
};