mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-11 13:47:05 +02:00
Make default jail state configurable
This commit is contained in:
@@ -1333,6 +1333,7 @@ func UpdateSettingsHandler(c *gin.Context) {
|
||||
// Compare IgnoreIPs arrays
|
||||
ignoreIPsChanged := !equalStringSlices(oldSettings.IgnoreIPs, newSettings.IgnoreIPs)
|
||||
defaultSettingsChanged := oldSettings.BantimeIncrement != newSettings.BantimeIncrement ||
|
||||
oldSettings.DefaultJailEnable != newSettings.DefaultJailEnable ||
|
||||
ignoreIPsChanged ||
|
||||
oldSettings.Bantime != newSettings.Bantime ||
|
||||
oldSettings.Findtime != newSettings.Findtime ||
|
||||
@@ -1459,6 +1460,7 @@ func ApplyFail2banSettings(jailLocalPath string) error {
|
||||
|
||||
newLines := []string{
|
||||
"[DEFAULT]",
|
||||
fmt.Sprintf("enabled = %t", s.DefaultJailEnable),
|
||||
fmt.Sprintf("bantime.increment = %t", s.BantimeIncrement),
|
||||
fmt.Sprintf("ignoreip = %s", strings.Join(s.IgnoreIPs, " ")),
|
||||
fmt.Sprintf("bantime = %s", s.Bantime),
|
||||
|
||||
@@ -82,6 +82,7 @@ function loadSettings() {
|
||||
}
|
||||
|
||||
document.getElementById('bantimeIncrement').checked = data.bantimeIncrement || false;
|
||||
document.getElementById('defaultJailEnable').checked = data.defaultJailEnable || false;
|
||||
document.getElementById('banTime').value = data.bantime || '';
|
||||
document.getElementById('findTime').value = data.findtime || '';
|
||||
document.getElementById('maxRetry').value = data.maxretry || '';
|
||||
@@ -141,6 +142,7 @@ function saveSettings(event) {
|
||||
callbackUrl: callbackUrl,
|
||||
alertCountries: selectedCountries.length > 0 ? selectedCountries : ["ALL"],
|
||||
bantimeIncrement: document.getElementById('bantimeIncrement').checked,
|
||||
defaultJailEnable: document.getElementById('defaultJailEnable').checked,
|
||||
bantime: document.getElementById('banTime').value.trim(),
|
||||
findtime: document.getElementById('findTime').value.trim(),
|
||||
maxretry: parseInt(document.getElementById('maxRetry').value, 10) || 3,
|
||||
|
||||
@@ -585,6 +585,15 @@
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 ml-9" data-i18n="settings.enable_bantime_increment.description">If set to true, the bantime will be calculated using the formula: bantime = findtime * (number of failures / maxretry) * (1 + bantime.rndtime).</p>
|
||||
</div>
|
||||
|
||||
<!-- Default Enabled -->
|
||||
<div class="mb-4">
|
||||
<div class="flex items-center mb-2">
|
||||
<input type="checkbox" id="defaultJailEnable" class="h-4 w-7 text-blue-600 transition duration-150 ease-in-out" />
|
||||
<label for="defaultJailEnable" class="ml-2 block text-sm font-medium text-gray-700" data-i18n="settings.default_jail_enable">Enable Jails by Default</label>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 ml-9" data-i18n="settings.default_jail_enable.description">If enabled, all jails will be enabled by default. When disabled, jails must be explicitly enabled.</p>
|
||||
</div>
|
||||
|
||||
<!-- Bantime -->
|
||||
<div class="mb-4">
|
||||
|
||||
Reference in New Issue
Block a user