Make sure $ip is defined

This commit is contained in:
William Edwards 2024-04-29 19:07:17 +02:00
parent 6249c099a9
commit 78afb914da

View file

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