From 2aa65911b7bebeb98730b79280bec1b4310311e4 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Thu, 4 Dec 2025 22:42:39 -0500 Subject: [PATCH] feat: refine firewall log matching logic for improved accuracy and add detailed logging for connection data retrieval --- .../Servers/Proxmox/Livewire/Firewall.php | 24 ++++++------------- .../Servers/Proxmox/views/firewall.blade.php | 10 +++++++- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/extensions/Servers/Proxmox/Livewire/Firewall.php b/extensions/Servers/Proxmox/Livewire/Firewall.php index ed703f9f2..5411cba73 100644 --- a/extensions/Servers/Proxmox/Livewire/Firewall.php +++ b/extensions/Servers/Proxmox/Livewire/Firewall.php @@ -1678,27 +1678,17 @@ class Firewall extends Component $normalizedStateDestIP = strtolower(trim($stateDestIP)); $normalizedProtocol = strtoupper(trim($protocol)); - // Very flexible matching logic + // Matching logic - check if both IPs from the log are present in the state + // Either in the same direction or swapped (for return traffic) $ipMatch = false; - // Check if IPs match in either direction - if (($normalizedStateSourceIP === $normalizedSourceIP && $normalizedStateDestIP === $normalizedDestIP) || - ($normalizedStateSourceIP === $normalizedDestIP && $normalizedStateDestIP === $normalizedSourceIP)) { + // Direction 1: Log source → Log dest matches State source → State dest + if ($normalizedStateSourceIP === $normalizedSourceIP && $normalizedStateDestIP === $normalizedDestIP) { $ipMatch = true; } - - // Also try if one of the IPs matches (useful for single-sided matching) - if (!$ipMatch && ( - $normalizedStateSourceIP === $normalizedSourceIP || - $normalizedStateSourceIP === $normalizedDestIP || - $normalizedStateDestIP === $normalizedSourceIP || - $normalizedStateDestIP === $normalizedDestIP)) { - // At least one IP matches, check if the other makes sense - if ($normalizedStateSourceIP === $normalizedSourceIP || $normalizedStateDestIP === $normalizedSourceIP) { - if ($normalizedStateSourceIP === $normalizedDestIP || $normalizedStateDestIP === $normalizedDestIP) { - $ipMatch = true; - } - } + // Direction 2: Swapped (return traffic) + elseif ($normalizedStateSourceIP === $normalizedDestIP && $normalizedStateDestIP === $normalizedSourceIP) { + $ipMatch = true; } // Protocol match diff --git a/extensions/Servers/Proxmox/views/firewall.blade.php b/extensions/Servers/Proxmox/views/firewall.blade.php index 95f3aa3a2..e6676460d 100644 --- a/extensions/Servers/Proxmox/views/firewall.blade.php +++ b/extensions/Servers/Proxmox/views/firewall.blade.php @@ -1079,15 +1079,23 @@ loading: false, connectionData: null, error: null, + sourceIP: '{{ addslashes($sourceIP) }}', + destIP: '{{ addslashes($destIP) }}', + sourcePort: '{{ addslashes($sourcePort) }}', + destPort: '{{ addslashes($destPort) }}', + protocol: '{{ addslashes($protocol) }}', loadConnectionData() { this.loading = true; this.error = null; - $wire.getNetworkAnalysisForLog('{{ $sourceIP }}', '{{ $destIP }}', '{{ $sourcePort }}', '{{ $destPort }}', '{{ $protocol }}') + console.log('Loading connection data for:', this.sourceIP, '->', this.destIP, 'Port:', this.destPort, 'Protocol:', this.protocol); + $wire.getNetworkAnalysisForLog(this.sourceIP, this.destIP, this.sourcePort, this.destPort, this.protocol) .then(data => { + console.log('Received connection data:', data); this.connectionData = data; this.loading = false; }) .catch(err => { + console.error('Failed to load connection data:', err); this.error = 'Failed to load connection data'; this.loading = false; });