aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-07-05 17:37:51 +0200
committerGitHub <noreply@github.com>2021-07-05 17:37:51 +0200
commitb396aee33399ef414e316189eeb90cc8051a60bb (patch)
tree8747832098dbc0e61f6e33cccde5980d41797b59
parent931a871533e5871c14c3f86b29a2486f68aaaef9 (diff)
parent484913dc31314398d504472860b0e4b593241ab4 (diff)
downloadnextcloud-server-b396aee33399ef414e316189eeb90cc8051a60bb.tar.gz
nextcloud-server-b396aee33399ef414e316189eeb90cc8051a60bb.zip
Merge pull request #27758 from nullspoon/fix-dns-pinning
-rw-r--r--lib/private/Http/Client/DnsPinMiddleware.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/private/Http/Client/DnsPinMiddleware.php b/lib/private/Http/Client/DnsPinMiddleware.php
index 019fde23723..900173bb506 100644
--- a/lib/private/Http/Client/DnsPinMiddleware.php
+++ b/lib/private/Http/Client/DnsPinMiddleware.php
@@ -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);
};
};