mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 20:15:45 +00:00
fix(backups): pin all resolved addresses in one CURLOPT_RESOLVE entry
libcurl overrides an existing host:port DNS cache entry each time a new one is added, so one entry per address left only the last pinned. That is IPv6 whenever the target has AAAA records, which broke every request on hosts without IPv6. Join them into one comma separated entry instead.
This commit is contained in:
1 parent
f06bacc8e0
commit
75d3bd8354
2 files changed
+36
-5
No files matched your search
@@ -111,11 +111,20 @@ class SafeWebhookUrl implements ValidationRule
|
||||
return $options;
|
||||
}
|
||||
|
||||
// libcurl keeps only the last CURLOPT_RESOLVE entry for a given
|
||||
// host:port pair, so every resolved address must be pinned in a single
|
||||
// comma-separated entry. Emitting one entry per address silently drops
|
||||
// all but the last, which is an IPv6 address whenever the host has AAAA
|
||||
// records -- and that fails instantly on hosts without IPv6 egress.
|
||||
$addresses = implode(',', array_map(
|
||||
fn (string $ip): string => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? '['.$ip.']' : $ip,
|
||||
$target['ips'],
|
||||
));
|
||||
|
||||
$options['curl'] = [
|
||||
CURLOPT_RESOLVE => array_map(
|
||||
fn (string $ip): string => sprintf('%s:%d:%s', $target['host'], $target['port'], filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? '['.$ip.']' : $ip),
|
||||
$target['ips'],
|
||||
),
|
||||
CURLOPT_RESOLVE => [
|
||||
sprintf('%s:%d:%s', $target['host'], $target['port'], $addresses),
|
||||
],
|
||||
];
|
||||
|
||||
return $options;
|
||||
|
||||
Reference in new issue
Block a user