Private
Public Access
1
0

feat: enhance Proxmox Firewall log view with detailed IP and port information, including modals for geolocation and protocol descriptions, improving user interaction and data accessibility

This commit is contained in:
2025-12-03 04:29:56 -05:00
parent ec5675e108
commit 83c7315ece
2 changed files with 574 additions and 5 deletions

View File

@@ -1152,6 +1152,49 @@ class Firewall extends Component
return $result;
}
/**
* Fetch IP location data from ip-api.com
*/
public function fetchIPLocation(string $ip): array
{
try {
// Validate IP address
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
return [
'status' => 'fail',
'message' => 'Invalid or private IP address'
];
}
// Fetch location data from ip-api.com (HTTP endpoint)
$response = Http::timeout(5)->get("http://ip-api.com/json/{$ip}");
if ($response->successful()) {
$data = $response->json();
// Check if the API returned success
if (isset($data['status']) && $data['status'] === 'success') {
return $data;
} else {
return [
'status' => 'fail',
'message' => $data['message'] ?? 'Unable to fetch location data'
];
}
}
return [
'status' => 'fail',
'message' => 'Failed to fetch location data (HTTP ' . $response->status() . ')'
];
} catch (\Exception $e) {
return [
'status' => 'fail',
'message' => 'Error: ' . $e->getMessage()
];
}
}
public function render()
{
return view('proxmox::firewall')->layoutData([