Only add brackets for IPv6

This commit is contained in:
William Edwards 2024-04-29 19:01:43 +02:00
parent ff2a224d4f
commit 6249c099a9

View file

@ -60,7 +60,13 @@ class ApiHandler {
} }
private function baseurl() { private function baseurl() {
return $this->proto.'://['.$this->hostname.']:'.$this->port.$this->apiurl; if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$ip = sprintf('[%s]', $this->hostname); // curl needs brackets for IPv6
} else {
$ip = $this->hostname;
}
return $this->proto.'://'.$ip.':'.$this->port.$this->apiurl;
} }
private function go() { private function go() {