refactor: update firewall log display in Proxmox component to show raw log entries and improve error messaging for better clarity
This commit is contained in:
@@ -851,17 +851,19 @@ class Firewall extends Component
|
|||||||
|
|
||||||
$this->firewallLogs = [];
|
$this->firewallLogs = [];
|
||||||
|
|
||||||
|
// Store raw log entries without parsing
|
||||||
foreach ($rawLogs as $logEntry) {
|
foreach ($rawLogs as $logEntry) {
|
||||||
$logText = null;
|
|
||||||
|
|
||||||
if (is_string($logEntry)) {
|
if (is_string($logEntry)) {
|
||||||
$logText = trim($logEntry);
|
$logText = trim($logEntry);
|
||||||
|
if (!empty($logText)) {
|
||||||
|
$this->firewallLogs[] = ['raw' => $logText];
|
||||||
|
}
|
||||||
} elseif (is_array($logEntry)) {
|
} elseif (is_array($logEntry)) {
|
||||||
// Try common field names
|
// If it's an array, try to get the log text
|
||||||
$logText = $logEntry['n'] ?? $logEntry['t'] ?? $logEntry['text'] ?? $logEntry['log'] ?? $logEntry['message'] ?? $logEntry['line'] ?? '';
|
$logText = $logEntry['n'] ?? $logEntry['t'] ?? $logEntry['text'] ?? $logEntry['log'] ?? $logEntry['message'] ?? $logEntry['line'] ?? '';
|
||||||
|
|
||||||
// If still empty, try to get the first string value
|
|
||||||
if (empty($logText)) {
|
if (empty($logText)) {
|
||||||
|
// Try to get the first string value
|
||||||
foreach ($logEntry as $key => $value) {
|
foreach ($logEntry as $key => $value) {
|
||||||
if (is_string($value) && !empty(trim($value))) {
|
if (is_string($value) && !empty(trim($value))) {
|
||||||
$logText = trim($value);
|
$logText = trim($value);
|
||||||
@@ -869,20 +871,15 @@ class Firewall extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (!empty($logText)) {
|
||||||
if (empty($logText)) {
|
$this->firewallLogs[] = ['raw' => $logText];
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$parsed = $this->parseFirewallLog($logText);
|
|
||||||
if ($parsed) {
|
|
||||||
$this->firewallLogs[] = $parsed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->firewallLogs) && !empty($rawLogs)) {
|
if (empty($this->firewallLogs) && !empty($rawLogs)) {
|
||||||
$this->logError = 'Logs received but could not be parsed. Please check that firewall logging is enabled in Proxmox.';
|
$this->logError = 'Logs received but could not be processed.';
|
||||||
} elseif (empty($this->firewallLogs)) {
|
} elseif (empty($this->firewallLogs)) {
|
||||||
$this->logError = 'No firewall logs available. Ensure firewall logging is enabled in Proxmox (Datacenter > Firewall > Options).';
|
$this->logError = 'No firewall logs available. Ensure firewall logging is enabled in Proxmox (Datacenter > Firewall > Options).';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -320,43 +320,13 @@
|
|||||||
|
|
||||||
@if(count($firewallLogs) > 0)
|
@if(count($firewallLogs) > 0)
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="w-full border-collapse">
|
<div class="space-y-2">
|
||||||
<thead>
|
@foreach($firewallLogs as $log)
|
||||||
<tr class="border-b border-neutral">
|
<div class="bg-background-secondary border border-neutral/20 rounded-lg p-3">
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Timestamp</th>
|
<code class="text-xs text-base/90 whitespace-pre-wrap break-all font-mono">{{ $log['raw'] ?? '' }}</code>
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Action</th>
|
</div>
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Source</th>
|
@endforeach
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Destination</th>
|
</div>
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Protocol</th>
|
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Source Port</th>
|
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">Dest Port</th>
|
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">TTL</th>
|
|
||||||
<th class="text-left py-3 px-4 font-semibold text-sm">ACK</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($firewallLogs as $log)
|
|
||||||
<tr class="border-b border-neutral/20 hover:bg-background-secondary/50">
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['timestamp'] ?? '-' }}</td>
|
|
||||||
<td class="py-3 px-4 text-sm">
|
|
||||||
<span class="px-2 py-1 rounded text-xs font-medium
|
|
||||||
{{ ($log['action'] ?? '') === 'ACCEPT' ? 'bg-success/20 text-success' : '' }}
|
|
||||||
{{ ($log['action'] ?? '') === 'REJECT' ? 'bg-warning/20 text-warning' : '' }}
|
|
||||||
{{ ($log['action'] ?? '') === 'DROP' ? 'bg-error/20 text-error' : '' }}">
|
|
||||||
{{ $log['action'] ?? '-' }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="py-3 px-4 text-sm"><code class="text-xs">{{ $log['source'] ?? '-' }}</code></td>
|
|
||||||
<td class="py-3 px-4 text-sm"><code class="text-xs">{{ $log['destination'] ?? '-' }}</code></td>
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['proto'] ?? '-' }}</td>
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['spt'] ?? '-' }}</td>
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['dpt'] ?? '-' }}</td>
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['ttl'] ?? '-' }}</td>
|
|
||||||
<td class="py-3 px-4 text-sm">{{ $log['ack'] ?? '-' }}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
@elseif(empty($logError))
|
@elseif(empty($logError))
|
||||||
<div class="text-center py-8 text-base/60">
|
<div class="text-center py-8 text-base/60">
|
||||||
|
|||||||
Reference in New Issue
Block a user