Skip to content

Commit

Permalink
Return 0.0.0.0 instead of an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
RMartinOscar committed Jan 5, 2025
1 parent 233c369 commit 98d8db7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function statistics(): array
public function ipAddresses(): array
{
$ips = cache()->remember("nodes.$this->id.ips", now()->addHour(), function () {
$ips = collect(['0.0.0.0']);
$ips = collect();
if (is_ip($this->fqdn)) {
$ips = $ips->push($this->fqdn);
} elseif ($dnsRecords = gethostbynamel($this->fqdn)) {
Expand All @@ -390,9 +390,9 @@ public function ipAddresses(): array
// Only IPV4
$ips = $ips->filter(fn (string $ip) => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false);

return $ips->unique()->all();
return $ips;
});

return $ips ?? [];
return $ips->push('0.0.0.0')->unique()->all();
}
}

0 comments on commit 98d8db7

Please sign in to comment.