diff --git a/extensions/Servers/Proxmox/Livewire/Firewall.php b/extensions/Servers/Proxmox/Livewire/Firewall.php index 5f4ef593b..a2ca45e3c 100644 --- a/extensions/Servers/Proxmox/Livewire/Firewall.php +++ b/extensions/Servers/Proxmox/Livewire/Firewall.php @@ -245,22 +245,27 @@ class Firewall extends Component public function startEditRule(int $index): void { - if (isset($this->rules[$index])) { - $rule = $this->rules[$index]; - $this->editingRulePos = $rule['pos']; - $this->showRuleForm = true; - $this->ruleAction = $rule['action'] ?? 'ACCEPT'; - $this->ruleSource = $rule['source'] ?? ''; - $this->ruleDest = $rule['dest'] ?? ''; - $this->ruleProto = $rule['proto'] ?? ''; - $this->ruleDport = $rule['dport'] ?? ''; - $this->ruleSport = $rule['sport'] ?? ''; - $this->ruleComment = $rule['comment'] ?? ''; - $this->ruleEnable = !isset($rule['enable']) || $rule['enable'] == 1; - $this->ruleMacro = $rule['macro'] ?? ''; - $this->ruleIface = $rule['iface'] ?? ''; - $this->ruleLog = $rule['log'] ?? 'nolog'; + if (!isset($this->rules[$index])) { + $this->error = 'Rule not found'; + $this->showErrorModal = true; + return; } + + $rule = $this->rules[$index]; + $this->editingRulePos = $index; + $this->showRuleForm = true; + + $this->ruleAction = $rule['action'] ?? 'ACCEPT'; + $this->ruleSource = $rule['source'] ?? ''; + $this->ruleDest = $rule['dest'] ?? ''; + $this->ruleProto = $rule['proto'] ?? 'tcp'; + $this->ruleDport = $rule['dport'] ?? ''; + $this->ruleSport = $rule['sport'] ?? ''; + $this->ruleComment = $rule['comment'] ?? ''; + $this->ruleEnable = !isset($rule['enable']) || $rule['enable'] != 0; + $this->ruleMacro = $rule['macro'] ?? ''; + $this->ruleIface = $rule['iface'] ?? ''; + $this->ruleLog = $rule['log'] ?? 'nolog'; } public function resetRuleForm(): void @@ -322,10 +327,12 @@ class Firewall extends Component $payload['log'] = trim($this->ruleLog); } - if ($this->editingRulePos !== null) { + if ($this->editingRulePos !== null && isset($this->rules[$this->editingRulePos])) { // Update existing rule + $rule = $this->rules[$this->editingRulePos]; + $pos = $rule['pos']; $response = $this->firewallRequest( - '/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/firewall/rules/' . $this->editingRulePos, + '/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/firewall/rules/' . $pos, 'put', $payload ); @@ -437,10 +444,14 @@ class Firewall extends Component public function confirmDeleteRule(int $index): void { - if (isset($this->rules[$index])) { - $this->deletingRulePos = $this->rules[$index]['pos']; - $this->showDeleteModal = true; + if (!isset($this->rules[$index])) { + $this->error = 'Rule not found'; + $this->showErrorModal = true; + return; } + + $this->deletingRulePos = $index; + $this->showDeleteModal = true; } public function cancelDeleteRule(): void @@ -451,14 +462,15 @@ class Firewall extends Component public function deleteRule(): void { - if ($this->deletingRulePos === null) { + if ($this->deletingRulePos === null || !isset($this->rules[$this->deletingRulePos])) { return; } - $pos = $this->deletingRulePos; + $rule = $this->rules[$this->deletingRulePos]; + $pos = $rule['pos']; $this->loading = true; $this->showDeleteModal = false; - + try { $response = $this->firewallRequest( '/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/firewall/rules/' . $pos, diff --git a/extensions/Servers/Proxmox/views/firewall.blade.php b/extensions/Servers/Proxmox/views/firewall.blade.php index 58ab1f6cb..ef9c0d67e 100644 --- a/extensions/Servers/Proxmox/views/firewall.blade.php +++ b/extensions/Servers/Proxmox/views/firewall.blade.php @@ -506,87 +506,7 @@ @if($firewallEnabled) -
| Order | Action | Source | @@ -635,36 +554,32 @@|||||||
|---|---|---|---|---|---|---|---|---|---|
|
-
-
- |
- + @foreach($rules as $index => $rule) + | ||||||||
| {{ $rule['pos'] ?? '-' }} | - + @php + $actionClass = match($rule['action'] ?? '') { + 'ACCEPT' => 'bg-success/20 text-success', + 'REJECT' => 'bg-warning/20 text-warning', + 'DROP' => 'bg-error/20 text-error', + default => '' + }; + @endphp + + {{ $rule['action'] ?? '-' }} + |
-
-
+ {{ $rule['source'] ?? '-' }}
+ @if($rule['source'] && $rule['source'] !== '-' && window.isPublicIP($rule['source']))
|
-
-
+ {{ $rule['dest'] ?? '-' }}
+ @if($rule['dest'] && $rule['dest'] !== '-' && window.isPublicIP($rule['dest']))
|
- - | + | {{ strtoupper($rule['proto'] ?? 'any') }} | +{{ $rule['dport'] ?? $rule['sport'] ?? '-' }} | - Disabled - Enabled + @if(isset($rule['enable']) && $rule['enable'] == 0) + Disabled + @else + Enabled + @endif |
|