mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 14:03:15 +02:00
Add missing swissmakers header and section comments
This commit is contained in:
@@ -1,3 +1,19 @@
|
|||||||
|
// Fail2ban UI - A Swiss made, management interface for Fail2ban.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2026 Swissmakers GmbH (https://swissmakers.ch)
|
||||||
|
//
|
||||||
|
// Licensed under the GNU General Public License, Version 3 (GPL-3.0)
|
||||||
|
// You may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -14,6 +30,10 @@ import (
|
|||||||
"github.com/swissmakers/fail2ban-ui/internal/storage"
|
"github.com/swissmakers/fail2ban-ui/internal/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// Threshold Evaluation
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
func evaluateAdvancedActions(ctx context.Context, settings config.AppSettings, server config.Fail2banServer, ip string) {
|
func evaluateAdvancedActions(ctx context.Context, settings config.AppSettings, server config.Fail2banServer, ip string) {
|
||||||
cfg := settings.AdvancedActions
|
cfg := settings.AdvancedActions
|
||||||
if !cfg.Enabled || cfg.Threshold <= 0 || cfg.Integration == "" {
|
if !cfg.Enabled || cfg.Threshold <= 0 || cfg.Integration == "" {
|
||||||
@@ -38,6 +58,7 @@ func evaluateAdvancedActions(ctx context.Context, settings config.AppSettings, s
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only if everything above is ok, we execute the configured "advanced actions" integration.
|
||||||
if err := runAdvancedIntegrationAction(ctx, "block", ip, settings, server, map[string]any{
|
if err := runAdvancedIntegrationAction(ctx, "block", ip, settings, server, map[string]any{
|
||||||
"reason": "automatic_threshold",
|
"reason": "automatic_threshold",
|
||||||
"count": count,
|
"count": count,
|
||||||
@@ -47,6 +68,10 @@ func evaluateAdvancedActions(ctx context.Context, settings config.AppSettings, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// Integration Execution
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
func runAdvancedIntegrationAction(ctx context.Context, action, ip string, settings config.AppSettings, server config.Fail2banServer, details map[string]any, skipLoggingIfAlreadyBlocked bool) error {
|
func runAdvancedIntegrationAction(ctx context.Context, action, ip string, settings config.AppSettings, server config.Fail2banServer, details map[string]any, skipLoggingIfAlreadyBlocked bool) error {
|
||||||
cfg := settings.AdvancedActions
|
cfg := settings.AdvancedActions
|
||||||
if cfg.Integration == "" {
|
if cfg.Integration == "" {
|
||||||
@@ -92,7 +117,6 @@ func runAdvancedIntegrationAction(ctx context.Context, action, ip string, settin
|
|||||||
message = err.Error()
|
message = err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If IP is already blocked, don't update the database entry - leave existing entry as is
|
|
||||||
if !skipLoggingIfAlreadyBlocked {
|
if !skipLoggingIfAlreadyBlocked {
|
||||||
if details == nil {
|
if details == nil {
|
||||||
details = map[string]any{}
|
details = map[string]any{}
|
||||||
|
|||||||
Reference in New Issue
Block a user