mirror of
https://gitlab.com/ArkHost/WHMCS-ArkHost-HetznerVPS.git
synced 2026-07-24 07:45:53 +02:00
v1.1.1
Fixed - Firewall rules now accept source 0.0.0.0/0 for all IPs - "ANY" protocol creates both TCP and UDP rules automatically - Outbound firewall rules now use correct destination_ips field Added - Incoming/Outgoing direction support for firewall rules - Proper CIDR notation validation (supports /0, /4, /8, /16, etc.) Improved - Removed description/note field from firewall interface - Changed "Source/Destination" column to "IP/CIDR" for clarity - Translated all firewall column headers to all supported languages - Cleaned up unused language strings
This commit is contained in:
@@ -676,6 +676,13 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<label class="small text-muted">{$ADDONLANG.Settings.Firewall.Direction}</label>
|
||||
<select class="form-control" id="firewallDirection">
|
||||
<option value="in" selected>{$ADDONLANG.Firewall.Incoming}</option>
|
||||
<option value="out">{$ADDONLANG.Firewall.Outgoing}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<label class="small text-muted">{$ADDONLANG.Settings.Firewall.Action}</label>
|
||||
<select class="form-control" id="firewallAction">
|
||||
@@ -692,18 +699,14 @@
|
||||
<option value="ANY">{$ADDONLANG.Firewall.Any}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-3">
|
||||
<label class="small text-muted">{$ADDONLANG.Settings.Firewall.Port}</label>
|
||||
<input class="form-control" id="firewallPort" type="number" min="1" max="65535" placeholder="{$ADDONLANG.Firewall.PortPlaceholder}">
|
||||
<input class="form-control" id="firewallPort" type="text" placeholder="{$ADDONLANG.Firewall.PortPlaceholder}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="small text-muted">{$ADDONLANG.Settings.Firewall.Source}</label>
|
||||
<label class="small text-muted">IP/CIDR</label>
|
||||
<input class="form-control" id="firewallSource" type="text" placeholder="{$ADDONLANG.Firewall.SourcePlaceholder}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="small text-muted">{$ADDONLANG.Settings.Firewall.Note}</label>
|
||||
<input class="form-control" id="firewallNote" type="text" maxlength="64" placeholder="{$ADDONLANG.Firewall.DescriptionPlaceholder}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right mt-3">
|
||||
<button class="btn btn-success" onclick="addFirewallRule();return false;">
|
||||
@@ -723,12 +726,12 @@
|
||||
<table id="firewallTable" class="table table-hover mb-0">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="100">Action</th>
|
||||
<th width="100">Protocol</th>
|
||||
<th width="100">Port</th>
|
||||
<th>Source</th>
|
||||
<th>Description</th>
|
||||
<th width="80" class="text-center">Remove</th>
|
||||
<th width="80">{$ADDONLANG.Firewall.Direction}</th>
|
||||
<th width="100">{$ADDONLANG.Firewall.Action}</th>
|
||||
<th width="100">{$ADDONLANG.Firewall.Protocol}</th>
|
||||
<th width="100">{$ADDONLANG.Firewall.Port}</th>
|
||||
<th>{$ADDONLANG.Firewall.IPCIDR}</th>
|
||||
<th width="80" class="text-center">{$ADDONLANG.Firewall.Remove}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
@@ -426,11 +426,11 @@ function ArkHostHetznerVPS_API(action, showAlert, params, callback, errorCallbac
|
||||
}
|
||||
if (action === 'Add Firewall rules') {
|
||||
// Clear the form
|
||||
document.getElementById('firewallDirection').value = 'in';
|
||||
document.getElementById('firewallAction').value = 'ACCEPT';
|
||||
document.getElementById('firewallPort').value = '';
|
||||
document.getElementById('firewallProtocol').value = 'ANY';
|
||||
document.getElementById('firewallSource').value = '';
|
||||
document.getElementById('firewallNote').value = '';
|
||||
|
||||
// Refresh firewall rules after adding
|
||||
setTimeout(function() {
|
||||
@@ -629,13 +629,21 @@ function updateFirewallTable(data) {
|
||||
|
||||
var protocolBadge = '<span class="badge badge-secondary">' + (rule.protocol || lang.firewall.any) + '</span>';
|
||||
|
||||
// Direction badge
|
||||
var directionBadge = '';
|
||||
if (rule.direction === 'out') {
|
||||
directionBadge = '<span class="badge badge-warning"><i class="fa fa-arrow-up mr-1"></i>' + (lang.firewall.outgoing || 'OUT') + '</span>';
|
||||
} else {
|
||||
directionBadge = '<span class="badge badge-info"><i class="fa fa-arrow-down mr-1"></i>' + (lang.firewall.incoming || 'IN') + '</span>';
|
||||
}
|
||||
|
||||
var row = document.createElement('tr');
|
||||
row.innerHTML =
|
||||
'<td>' + directionBadge + '</td>' +
|
||||
'<td>' + actionBadge + '</td>' +
|
||||
'<td>' + protocolBadge + '</td>' +
|
||||
'<td>' + (rule.port || '<span class="text-muted">' + lang.general.any + '</span>') + '</td>' +
|
||||
'<td><code>' + (rule.source || '0.0.0.0/0') + '</code></td>' +
|
||||
'<td>' + (rule.note || '<span class="text-muted">' + lang.general.emptyValue + '</span>') + '</td>' +
|
||||
'<td class="text-center">' +
|
||||
(rule.id !== 'info' ?
|
||||
'<button class="btn btn-sm btn-danger" onclick="deleteFirewallRule(\'' + rule.id + '\'); return false;" title="' + lang.delete + '">' +
|
||||
@@ -652,25 +660,58 @@ function updateFirewallTable(data) {
|
||||
}
|
||||
|
||||
function addFirewallRule() {
|
||||
var direction = document.getElementById('firewallDirection').value;
|
||||
var action = document.getElementById('firewallAction').value;
|
||||
var protocol = document.getElementById('firewallProtocol').value;
|
||||
var port = document.getElementById('firewallPort').value;
|
||||
var source = document.getElementById('firewallSource').value || '0.0.0.0/0';
|
||||
var note = document.getElementById('firewallNote').value;
|
||||
|
||||
// Validate port for TCP/UDP
|
||||
if ((protocol === 'TCP' || protocol === 'UDP') && !port) {
|
||||
if ((protocol === 'TCP' || protocol === 'UDP' || protocol === 'ANY') && !port) {
|
||||
showNotification(lang.messages.portRequired, 'error');
|
||||
document.getElementById('firewallPort').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate port format (single port or range)
|
||||
if (port) {
|
||||
// Check if it's a range (e.g., "8080-8090")
|
||||
if (port.includes('-')) {
|
||||
var parts = port.split('-');
|
||||
if (parts.length !== 2) {
|
||||
showNotification('Invalid port range format. Use format: 8080-8090', 'error');
|
||||
document.getElementById('firewallPort').focus();
|
||||
return false;
|
||||
}
|
||||
var startPort = parseInt(parts[0]);
|
||||
var endPort = parseInt(parts[1]);
|
||||
if (isNaN(startPort) || isNaN(endPort) || startPort < 1 || startPort > 65535 || endPort < 1 || endPort > 65535) {
|
||||
showNotification('Port range values must be between 1 and 65535', 'error');
|
||||
document.getElementById('firewallPort').focus();
|
||||
return false;
|
||||
}
|
||||
if (startPort >= endPort) {
|
||||
showNotification('Start port must be less than end port', 'error');
|
||||
document.getElementById('firewallPort').focus();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Single port
|
||||
var portNum = parseInt(port);
|
||||
if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
|
||||
showNotification('Port must be between 1 and 65535', 'error');
|
||||
document.getElementById('firewallPort').focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArkHostHetznerVPS_API('Add Firewall rules', true, {
|
||||
direction: direction,
|
||||
firewallAction: action,
|
||||
protocol: protocol,
|
||||
source: source,
|
||||
port: port,
|
||||
note: note
|
||||
port: port
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user