fix: update Proxmox firewall rule reordering logic to use original positions for persistence and enhance IP validation for IPv4-mapped IPv6 addresses

This commit is contained in:
2025-12-04 11:52:52 -05:00
parent d2805fd995
commit 9752cee800
2 changed files with 90 additions and 13 deletions

View File

@@ -548,8 +548,9 @@
return;
}
const draggedRule = this.rules[this.draggedIndex];
const targetRule = this.rules[targetIndex];
// Capture ORIGINAL positions before modifying the array
const originalDraggedPos = this.rules[this.draggedIndex].pos;
const originalTargetPos = this.rules[targetIndex].pos;
// Optimistically update UI
const movedRule = this.rules.splice(this.draggedIndex, 1)[0];
@@ -560,9 +561,9 @@
rule.pos = idx;
});
// Call Livewire to persist the change
// Call Livewire to persist the change using ORIGINAL positions
try {
await @this.reorderRules(draggedRule.pos, targetRule.pos);
await @this.reorderRules(originalDraggedPos, originalTargetPos);
} catch (error) {
console.error('Failed to reorder rules:', error);
// Reload rules on error
@@ -2172,6 +2173,13 @@
if (range.test(ip)) return false;
}
// Check for IPv4-mapped IPv6 addresses (::ffff:x.x.x.x)
const ipv4MappedMatch = ip.match(/^::ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i);
if (ipv4MappedMatch) {
// Recursively check if the embedded IPv4 address is public
return isPublicIP(ipv4MappedMatch[1]);
}
// Check for IPv6 private ranges (very simplified)
const ipv6PrivatePatterns = [
/^fe80:/i, // Link-local