mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-17 05:53:15 +02:00
Implement unban events and API and also add it to the Recent stored events, as well some cleanups
This commit is contained in:
@@ -77,6 +77,10 @@ type AppSettings struct {
|
||||
GeoIPProvider string `json:"geoipProvider"` // "maxmind" or "builtin"
|
||||
GeoIPDatabasePath string `json:"geoipDatabasePath"` // Path to MaxMind database (optional)
|
||||
MaxLogLines int `json:"maxLogLines"` // Maximum log lines to include (default: 50)
|
||||
|
||||
// Email alert preferences
|
||||
EmailAlertsForBans bool `json:"emailAlertsForBans"` // Enable email alerts for ban events (default: true)
|
||||
EmailAlertsForUnbans bool `json:"emailAlertsForUnbans"` // Enable email alerts for unban events (default: false)
|
||||
}
|
||||
|
||||
type AdvancedActionsConfig struct {
|
||||
@@ -132,9 +136,7 @@ func normalizeAdvancedActionsConfig(cfg AdvancedActionsConfig) AdvancedActionsCo
|
||||
// init paths to key-files
|
||||
const (
|
||||
settingsFile = "fail2ban-ui-settings.json" // this file is created, relatively to where the app was started
|
||||
defaultJailFile = "/etc/fail2ban/jail.conf"
|
||||
jailFile = "/etc/fail2ban/jail.local" // Path to jail.local (to override conf-values from jail.conf)
|
||||
jailDFile = "/etc/fail2ban/jail.d/ui-custom-action.conf"
|
||||
jailFile = "/etc/fail2ban/jail.local"
|
||||
actionFile = "/etc/fail2ban/action.d/ui-custom-action.conf"
|
||||
actionCallbackPlaceholder = "__CALLBACK_URL__"
|
||||
actionServerIDPlaceholder = "__SERVER_ID__"
|
||||
@@ -184,6 +186,18 @@ actionban = /usr/bin/curl -X POST __CALLBACK_URL__/api/ban \
|
||||
--arg logs "$(tac <logpath> | grep <grepopts> -wF <ip>)" \
|
||||
'{serverId: $serverId, ip: $ip, jail: $jail, hostname: $hostname, failures: $failures, logs: $logs}')"
|
||||
|
||||
# Option: actionunban
|
||||
# This executes a cURL request to notify our API when an IP is unbanned.
|
||||
|
||||
actionunban = /usr/bin/curl -X POST __CALLBACK_URL__/api/unban \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-Callback-Secret: __CALLBACK_SECRET__" \
|
||||
-d "$(jq -n --arg serverId '__SERVER_ID__' \
|
||||
--arg ip '<ip>' \
|
||||
--arg jail '<name>' \
|
||||
--arg hostname '<fq-hostname>' \
|
||||
'{serverId: $serverId, ip: $ip, jail: $jail, hostname: $hostname}')"
|
||||
|
||||
[Init]
|
||||
|
||||
# Default name of the chain
|
||||
@@ -396,6 +410,8 @@ func applyAppSettingsRecordLocked(rec storage.AppSettingsRecord) {
|
||||
currentSettings.GeoIPDatabasePath = rec.GeoIPDatabasePath
|
||||
currentSettings.MaxLogLines = rec.MaxLogLines
|
||||
currentSettings.CallbackSecret = rec.CallbackSecret
|
||||
currentSettings.EmailAlertsForBans = rec.EmailAlertsForBans
|
||||
currentSettings.EmailAlertsForUnbans = rec.EmailAlertsForUnbans
|
||||
}
|
||||
|
||||
func applyServerRecordsLocked(records []storage.ServerRecord) {
|
||||
@@ -447,33 +463,41 @@ func toAppSettingsRecordLocked() (storage.AppSettingsRecord, error) {
|
||||
}
|
||||
|
||||
return storage.AppSettingsRecord{
|
||||
Language: currentSettings.Language,
|
||||
Port: currentSettings.Port,
|
||||
Debug: currentSettings.Debug,
|
||||
CallbackURL: currentSettings.CallbackURL,
|
||||
RestartNeeded: currentSettings.RestartNeeded,
|
||||
AlertCountriesJSON: string(countryBytes),
|
||||
SMTPHost: currentSettings.SMTP.Host,
|
||||
SMTPPort: currentSettings.SMTP.Port,
|
||||
SMTPUsername: currentSettings.SMTP.Username,
|
||||
SMTPPassword: currentSettings.SMTP.Password,
|
||||
SMTPFrom: currentSettings.SMTP.From,
|
||||
SMTPUseTLS: currentSettings.SMTP.UseTLS,
|
||||
BantimeIncrement: currentSettings.BantimeIncrement,
|
||||
DefaultJailEnable: currentSettings.DefaultJailEnable,
|
||||
// Basic app settings
|
||||
Language: currentSettings.Language,
|
||||
Port: currentSettings.Port,
|
||||
Debug: currentSettings.Debug,
|
||||
RestartNeeded: currentSettings.RestartNeeded,
|
||||
// Callback settings
|
||||
CallbackURL: currentSettings.CallbackURL,
|
||||
CallbackSecret: currentSettings.CallbackSecret,
|
||||
// Alert settings
|
||||
AlertCountriesJSON: string(countryBytes),
|
||||
EmailAlertsForBans: currentSettings.EmailAlertsForBans,
|
||||
EmailAlertsForUnbans: currentSettings.EmailAlertsForUnbans,
|
||||
// SMTP settings
|
||||
SMTPHost: currentSettings.SMTP.Host,
|
||||
SMTPPort: currentSettings.SMTP.Port,
|
||||
SMTPUsername: currentSettings.SMTP.Username,
|
||||
SMTPPassword: currentSettings.SMTP.Password,
|
||||
SMTPFrom: currentSettings.SMTP.From,
|
||||
SMTPUseTLS: currentSettings.SMTP.UseTLS,
|
||||
// Fail2Ban DEFAULT settings
|
||||
BantimeIncrement: currentSettings.BantimeIncrement,
|
||||
DefaultJailEnable: currentSettings.DefaultJailEnable,
|
||||
// Convert IgnoreIPs array to space-separated string for storage
|
||||
IgnoreIP: strings.Join(currentSettings.IgnoreIPs, " "),
|
||||
Bantime: currentSettings.Bantime,
|
||||
Findtime: currentSettings.Findtime,
|
||||
MaxRetry: currentSettings.Maxretry,
|
||||
DestEmail: currentSettings.Destemail,
|
||||
Banaction: currentSettings.Banaction,
|
||||
BanactionAllports: currentSettings.BanactionAllports,
|
||||
IgnoreIP: strings.Join(currentSettings.IgnoreIPs, " "),
|
||||
Bantime: currentSettings.Bantime,
|
||||
Findtime: currentSettings.Findtime,
|
||||
MaxRetry: currentSettings.Maxretry,
|
||||
DestEmail: currentSettings.Destemail,
|
||||
Banaction: currentSettings.Banaction,
|
||||
BanactionAllports: currentSettings.BanactionAllports,
|
||||
// Advanced features
|
||||
AdvancedActionsJSON: string(advancedBytes),
|
||||
GeoIPProvider: currentSettings.GeoIPProvider,
|
||||
GeoIPDatabasePath: currentSettings.GeoIPDatabasePath,
|
||||
MaxLogLines: currentSettings.MaxLogLines,
|
||||
CallbackSecret: currentSettings.CallbackSecret,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -531,6 +555,18 @@ func setDefaultsLocked() {
|
||||
if currentSettings.Language == "" {
|
||||
currentSettings.Language = "en"
|
||||
}
|
||||
|
||||
// Set email alert defaults
|
||||
if !currentSettings.EmailAlertsForBans && !currentSettings.EmailAlertsForUnbans {
|
||||
// Check if it is uninitialized by checking if we have other initialized values
|
||||
// If we have a callback secret or port set, it means we've loaded from storage, so we don't override
|
||||
if currentSettings.CallbackSecret == "" && currentSettings.Port == 0 {
|
||||
// Uninitialized so we set defaults
|
||||
currentSettings.EmailAlertsForBans = true
|
||||
currentSettings.EmailAlertsForUnbans = false
|
||||
}
|
||||
}
|
||||
|
||||
// Check for PORT environment variable first - it always takes priority
|
||||
if portEnv := os.Getenv("PORT"); portEnv != "" {
|
||||
if port, err := strconv.Atoi(portEnv); err == nil && port > 0 && port <= 65535 {
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Alarm-Länder",
|
||||
"settings.alert_countries_description": "Wählen Sie die Länder aus, für die E-Mail-Alarme ausgelöst werden sollen, wenn eine Sperrung erfolgt.",
|
||||
"settings.email_alerts_for_bans": "E-Mail-Benachrichtigungen für Sperrungen aktivieren",
|
||||
"settings.email_alerts_for_unbans": "E-Mail-Benachrichtigungen für Entsperrungen aktivieren",
|
||||
"settings.smtp": "SMTP-Konfiguration",
|
||||
"settings.smtp_host": "SMTP-Host",
|
||||
"settings.smtp_host_placeholder": "z.B. smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "WHOIS-Daten wurden für dieses Ereignis nicht erfasst.",
|
||||
"email.logs.no_data": "Für diesen Block wurden keine Log-Einträge erfasst.",
|
||||
"email.footer.text": "Diese Nachricht wurde automatisch von Fail2Ban-UI generiert",
|
||||
"email.unban.title": "IP-Adresse entsperrt",
|
||||
"email.unban.intro": "IP-Adresse aus Fail2Ban-Jail entsperrt.",
|
||||
"email.unban.subject.unbanned": "Entsperrt",
|
||||
"email.unban.subject.from": "von",
|
||||
"email.unban.details.unbanned_ip": "Entsperrte IP",
|
||||
"email.unban.details.jail": "Jail",
|
||||
"email.unban.details.hostname": "Hostname",
|
||||
"email.unban.details.country": "Land",
|
||||
"email.unban.details.timestamp": "Zeitstempel",
|
||||
"lotr.email.title": "Ein dunkler Diener wurde verbannt",
|
||||
"lotr.email.intro": "Die Wächter von Mittelerde haben eine Bedrohung erkannt und aus dem Reich verbannt.",
|
||||
"lotr.email.you_shall_not_pass": "DU KANNST NICHT VORBEI",
|
||||
@@ -289,8 +300,15 @@
|
||||
"lotr.email.details.realm_protection": "Das Reich des Schutzes",
|
||||
"lotr.email.details.origins": "Herkunft aus den",
|
||||
"lotr.email.details.banished_at": "Verbannt zur",
|
||||
"lotr.email.unban.title": "Der festgehaltene wird wider freigelassen",
|
||||
"lotr.email.unban.intro": "Die Wächter von Mittelerde haben den Zugang wiederhergestellt.",
|
||||
"lotr.email.unban.details.restored_ip": "Wiederhergestellte IP",
|
||||
"lotr.banished": "Aus dem Reich verbannt",
|
||||
"lotr.realms_protected": "Geschützte Reiche",
|
||||
"lotr.threats_banished": "Verbannte Bedrohungen"
|
||||
"lotr.threats_banished": "Verbannte Bedrohungen",
|
||||
"toast.ban.title": "Neue Blockierung aufgetreten",
|
||||
"toast.ban.action": "gesperrt in",
|
||||
"toast.unban.title": "IP entsperrt",
|
||||
"toast.unban.action": "entsperrt von"
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Alarm-Länder",
|
||||
"settings.alert_countries_description": "Wähl d'Länder us, für weli du per Email ä Alarm becho wetsch, wenn e Sperrig erfolgt.",
|
||||
"settings.email_alerts_for_bans": "Email-Benachrichtigunge für Sperrige aktiviere",
|
||||
"settings.email_alerts_for_unbans": "Email-Benachrichtigunge für Entsperrige aktiviere",
|
||||
"settings.smtp": "SMTP-Konfiguration",
|
||||
"settings.smtp_host": "SMTP-Host",
|
||||
"settings.smtp_host_placeholder": "z.B. smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "WHOIS-Date si für das Ereignis nid erfasst worde.",
|
||||
"email.logs.no_data": "Für de Block sind keni Log-Iiträg erfasst worde.",
|
||||
"email.footer.text": "Diä Nachricht isch automatisch vom Fail2Ban-UI generiert worde",
|
||||
"email.unban.title": "IP-Adrässä entsperrt",
|
||||
"email.unban.intro": "E IP-Adrässä isch usem Fail2Ban-Jail entsperrt worde.",
|
||||
"email.unban.subject.unbanned": "Entsperrt",
|
||||
"email.unban.subject.from": "vo",
|
||||
"email.unban.details.unbanned_ip": "Entsperrti IP",
|
||||
"email.unban.details.jail": "Jail",
|
||||
"email.unban.details.hostname": "Hostname",
|
||||
"email.unban.details.country": "Land",
|
||||
"email.unban.details.timestamp": "Ziitstämpfel",
|
||||
"lotr.email.title": "E dunkle Diener isch verbannt worde",
|
||||
"lotr.email.intro": "D Wächter vo Mittelerde hei e Bedrohig erkannt und us dim Riich verbannt.",
|
||||
"lotr.email.you_shall_not_pass": "DU DARFSCH NID VERBII",
|
||||
@@ -289,8 +300,15 @@
|
||||
"lotr.email.details.realm_protection": "S Riich vom Schutz",
|
||||
"lotr.email.details.origins": "Herkunft us de",
|
||||
"lotr.email.details.banished_at": "Verbannt zur",
|
||||
"lotr.email.unban.title": "Dr festghautnig wird wider freiglah",
|
||||
"lotr.email.unban.intro": "D Wächter vo Mittelerde hei dr Zugang wiederhergstellt.",
|
||||
"lotr.email.unban.details.restored_ip": "Widerhergstellti IP",
|
||||
"lotr.banished": "Us em Riich verbannt",
|
||||
"lotr.realms_protected": "Gschützti Riich",
|
||||
"lotr.threats_banished": "Verbannti Bedrohige"
|
||||
"lotr.threats_banished": "Verbannti Bedrohige",
|
||||
"toast.ban.title": "Neui Blockierig ufträte",
|
||||
"toast.ban.action": "gsperrt i",
|
||||
"toast.unban.title": "IP entsperrt",
|
||||
"toast.unban.action": "entsperrt vo"
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Alert Countries",
|
||||
"settings.alert_countries_description": "Choose the countries for which you want to receive email alerts when a block is triggered.",
|
||||
"settings.email_alerts_for_bans": "Enable email alerts for bans",
|
||||
"settings.email_alerts_for_unbans": "Enable email alerts for unbans",
|
||||
"settings.smtp": "SMTP Configuration",
|
||||
"settings.smtp_host": "SMTP Host",
|
||||
"settings.smtp_host_placeholder": "e.g., smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "WHOIS data was not captured for this event.",
|
||||
"email.logs.no_data": "No log entries were captured for this block.",
|
||||
"email.footer.text": "This message was generated automatically by Fail2Ban-UI",
|
||||
"email.unban.title": "IP Address Unbanned",
|
||||
"email.unban.intro": "An IP address has been unbanned from a Fail2Ban jail.",
|
||||
"email.unban.subject.unbanned": "Unbanned",
|
||||
"email.unban.subject.from": "from",
|
||||
"email.unban.details.unbanned_ip": "Unbanned IP",
|
||||
"email.unban.details.jail": "Jail",
|
||||
"email.unban.details.hostname": "Hostname",
|
||||
"email.unban.details.country": "Country",
|
||||
"email.unban.details.timestamp": "Timestamp",
|
||||
"lotr.email.title": "A Dark Servant Has Been Banished",
|
||||
"lotr.email.intro": "The guardians of Middle-earth have detected a threat and banished it from the realm.",
|
||||
"lotr.email.you_shall_not_pass": "YOU SHALL NOT PASS",
|
||||
@@ -289,8 +300,15 @@
|
||||
"lotr.email.details.realm_protection": "The Realm of Protection",
|
||||
"lotr.email.details.origins": "Origins from the",
|
||||
"lotr.email.details.banished_at": "Banished at the",
|
||||
"lotr.email.unban.title": "The held prisoner has been released",
|
||||
"lotr.email.unban.intro": "The guardians of Middle-earth have restored access to the realm.",
|
||||
"lotr.email.unban.details.restored_ip": "Restored IP",
|
||||
"lotr.banished": "Banished from the realm",
|
||||
"lotr.realms_protected": "Realms Protected",
|
||||
"lotr.threats_banished": "Threats Banished"
|
||||
"lotr.threats_banished": "Threats Banished",
|
||||
"toast.ban.title": "New block occurred",
|
||||
"toast.ban.action": "banned in",
|
||||
"toast.unban.title": "IP unblocked",
|
||||
"toast.unban.action": "unblocked from"
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Países para alerta",
|
||||
"settings.alert_countries_description": "Elige los países para los que deseas recibir alertas por correo electrónico cuando se produzca un bloqueo.",
|
||||
"settings.email_alerts_for_bans": "Activar alertas por email para bloqueos",
|
||||
"settings.email_alerts_for_unbans": "Activar alertas por email para desbloqueos",
|
||||
"settings.smtp": "Configuración SMTP",
|
||||
"settings.smtp_host": "Host SMTP",
|
||||
"settings.smtp_host_placeholder": "p.ej., smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "No se capturaron datos WHOIS para este evento.",
|
||||
"email.logs.no_data": "No se capturaron entradas de registro para este bloqueo.",
|
||||
"email.footer.text": "Este mensaje fue generado automáticamente por Fail2Ban-UI",
|
||||
"email.unban.title": "Dirección IP desbloqueada",
|
||||
"email.unban.intro": "Una dirección IP ha sido desbloqueada de una prisión Fail2Ban.",
|
||||
"email.unban.subject.unbanned": "Desbloqueado",
|
||||
"email.unban.subject.from": "de",
|
||||
"email.unban.details.unbanned_ip": "IP desbloqueada",
|
||||
"email.unban.details.jail": "Prisión",
|
||||
"email.unban.details.hostname": "Nombre de host",
|
||||
"email.unban.details.country": "País",
|
||||
"email.unban.details.timestamp": "Marca de tiempo",
|
||||
"lotr.email.title": "Un siervo oscuro ha sido desterrado",
|
||||
"lotr.email.intro": "Los guardianes de la Tierra Media han detectado una amenaza y la han desterrado del reino.",
|
||||
"lotr.email.you_shall_not_pass": "NO PASARÁS",
|
||||
@@ -289,7 +300,14 @@
|
||||
"lotr.email.details.realm_protection": "El reino de la protección",
|
||||
"lotr.email.details.origins": "Orígenes de las",
|
||||
"lotr.email.details.banished_at": "Desterrado a las",
|
||||
"lotr.email.unban.title": "El prisionero detenido ha sido liberado",
|
||||
"lotr.email.unban.intro": "Los guardianes de la Tierra Media han restaurado el acceso al reino.",
|
||||
"lotr.email.unban.details.restored_ip": "IP restaurada",
|
||||
"lotr.banished": "Desterrado del reino",
|
||||
"lotr.realms_protected": "Reinos protegidos",
|
||||
"lotr.threats_banished": "Amenazas desterradas"
|
||||
"lotr.threats_banished": "Amenazas desterradas",
|
||||
"toast.ban.title": "Nuevo bloqueo ocurrido",
|
||||
"toast.ban.action": "bloqueado en",
|
||||
"toast.unban.title": "IP desbloqueada",
|
||||
"toast.unban.action": "desbloqueada de"
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Pays d'alerte",
|
||||
"settings.alert_countries_description": "Choisissez les pays pour lesquels vous souhaitez recevoir des alertes par email lors d'un blocage.",
|
||||
"settings.email_alerts_for_bans": "Activer les alertes email pour les bannissements",
|
||||
"settings.email_alerts_for_unbans": "Activer les alertes email pour les débannissements",
|
||||
"settings.smtp": "Configuration SMTP",
|
||||
"settings.smtp_host": "Hôte SMTP",
|
||||
"settings.smtp_host_placeholder": "par exemple, smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "Les données WHOIS n'ont pas été capturées pour cet événement.",
|
||||
"email.logs.no_data": "Aucune entrée de journal n'a été capturée pour ce blocage.",
|
||||
"email.footer.text": "Ce message a été généré automatiquement par Fail2Ban-UI",
|
||||
"email.unban.title": "Adresse IP débannie",
|
||||
"email.unban.intro": "Une adresse IP a été débannie d'une prison Fail2Ban.",
|
||||
"email.unban.subject.unbanned": "Débanni",
|
||||
"email.unban.subject.from": "de",
|
||||
"email.unban.details.unbanned_ip": "IP débannie",
|
||||
"email.unban.details.jail": "Prison",
|
||||
"email.unban.details.hostname": "Nom d'hôte",
|
||||
"email.unban.details.country": "Pays",
|
||||
"email.unban.details.timestamp": "Horodatage",
|
||||
"lotr.email.title": "Un serviteur des ténèbres a été banni",
|
||||
"lotr.email.intro": "Les gardiens de la Terre du Milieu ont détecté une menace et l'ont bannie du royaume.",
|
||||
"lotr.email.you_shall_not_pass": "TU NE PASSERAS PAS",
|
||||
@@ -289,7 +300,14 @@
|
||||
"lotr.email.details.realm_protection": "Le royaume de la protection",
|
||||
"lotr.email.details.origins": "Origines des",
|
||||
"lotr.email.details.banished_at": "Banni à",
|
||||
"lotr.email.unban.title": "Le détenu a été libéré",
|
||||
"lotr.email.unban.intro": "Les gardiens de la Terre du Milieu ont restauré l'accès au royaume.",
|
||||
"lotr.email.unban.details.restored_ip": "IP restaurée",
|
||||
"lotr.banished": "Banni du royaume",
|
||||
"lotr.realms_protected": "Royaumes protégés",
|
||||
"lotr.threats_banished": "Menaces bannies"
|
||||
"lotr.threats_banished": "Menaces bannies",
|
||||
"toast.ban.title": "Nouveau blocage survenu",
|
||||
"toast.ban.action": "banni dans",
|
||||
"toast.unban.title": "IP débloquée",
|
||||
"toast.unban.action": "débloquée de"
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
"settings.destination_email_placeholder": "alerts@swissmakers.ch",
|
||||
"settings.alert_countries": "Paesi per allarme",
|
||||
"settings.alert_countries_description": "Seleziona i paesi per i quali desideri ricevere allarmi via email quando si verifica un blocco.",
|
||||
"settings.email_alerts_for_bans": "Abilita allarmi email per i ban",
|
||||
"settings.email_alerts_for_unbans": "Abilita allarmi email per gli unban",
|
||||
"settings.smtp": "Configurazione SMTP",
|
||||
"settings.smtp_host": "Host SMTP",
|
||||
"settings.smtp_host_placeholder": "es. smtp.gmail.com",
|
||||
@@ -281,6 +283,15 @@
|
||||
"email.whois.no_data": "I dati WHOIS non sono stati acquisiti per questo evento.",
|
||||
"email.logs.no_data": "Nessuna voce di log è stata acquisita per questo blocco.",
|
||||
"email.footer.text": "Questo messaggio è stato generato automaticamente da Fail2Ban-UI",
|
||||
"email.unban.title": "Indirizzo IP sbannato",
|
||||
"email.unban.intro": "Un indirizzo IP è stato sbannato da una prigione Fail2Ban.",
|
||||
"email.unban.subject.unbanned": "Sbannato",
|
||||
"email.unban.subject.from": "da",
|
||||
"email.unban.details.unbanned_ip": "IP sbannato",
|
||||
"email.unban.details.jail": "Prigione",
|
||||
"email.unban.details.hostname": "Nome host",
|
||||
"email.unban.details.country": "Paese",
|
||||
"email.unban.details.timestamp": "Timestamp",
|
||||
"lotr.email.title": "Un servitore oscuro è stato bandito",
|
||||
"lotr.email.intro": "I guardiani della Terra di Mezzo hanno rilevato una minaccia e l'hanno bandita dal regno.",
|
||||
"lotr.email.you_shall_not_pass": "NON PASSERAI",
|
||||
@@ -289,7 +300,14 @@
|
||||
"lotr.email.details.realm_protection": "Il regno della protezione",
|
||||
"lotr.email.details.origins": "Origini dalle",
|
||||
"lotr.email.details.banished_at": "Bandito alle",
|
||||
"lotr.email.unban.title": "Il detenuto è stato rilasciato",
|
||||
"lotr.email.unban.intro": "I guardiani della Terra di Mezzo hanno ripristinato l'accesso al regno.",
|
||||
"lotr.email.unban.details.restored_ip": "IP ripristinato",
|
||||
"lotr.banished": "Bandito dal regno",
|
||||
"lotr.realms_protected": "Regni protetti",
|
||||
"lotr.threats_banished": "Minacce bandite"
|
||||
"lotr.threats_banished": "Minacce bandite",
|
||||
"toast.ban.title": "Nuovo blocco verificato",
|
||||
"toast.ban.action": "bannato in",
|
||||
"toast.unban.title": "IP sbloccato",
|
||||
"toast.unban.action": "sbloccato da"
|
||||
}
|
||||
|
||||
@@ -48,32 +48,40 @@ func intFromNull(ni sql.NullInt64) int {
|
||||
}
|
||||
|
||||
type AppSettingsRecord struct {
|
||||
Language string
|
||||
Port int
|
||||
Debug bool
|
||||
CallbackURL string
|
||||
RestartNeeded bool
|
||||
AlertCountriesJSON string
|
||||
SMTPHost string
|
||||
SMTPPort int
|
||||
SMTPUsername string
|
||||
SMTPPassword string
|
||||
SMTPFrom string
|
||||
SMTPUseTLS bool
|
||||
BantimeIncrement bool
|
||||
DefaultJailEnable bool
|
||||
IgnoreIP string // Stored as space-separated string, converted to array in AppSettings
|
||||
Bantime string
|
||||
Findtime string
|
||||
MaxRetry int
|
||||
DestEmail string
|
||||
Banaction string
|
||||
BanactionAllports string
|
||||
// Basic app settings
|
||||
Language string
|
||||
Port int
|
||||
Debug bool
|
||||
RestartNeeded bool
|
||||
// Callback settings
|
||||
CallbackURL string
|
||||
CallbackSecret string
|
||||
// Alert settings
|
||||
AlertCountriesJSON string
|
||||
EmailAlertsForBans bool
|
||||
EmailAlertsForUnbans bool
|
||||
// SMTP settings
|
||||
SMTPHost string
|
||||
SMTPPort int
|
||||
SMTPUsername string
|
||||
SMTPPassword string
|
||||
SMTPFrom string
|
||||
SMTPUseTLS bool
|
||||
// Fail2Ban DEFAULT settings
|
||||
BantimeIncrement bool
|
||||
DefaultJailEnable bool
|
||||
IgnoreIP string // Stored as space-separated string, converted to array in AppSettings
|
||||
Bantime string
|
||||
Findtime string
|
||||
MaxRetry int
|
||||
DestEmail string
|
||||
Banaction string
|
||||
BanactionAllports string
|
||||
// Advanced features
|
||||
AdvancedActionsJSON string
|
||||
GeoIPProvider string
|
||||
GeoIPDatabasePath string
|
||||
MaxLogLines int
|
||||
CallbackSecret string
|
||||
}
|
||||
|
||||
type ServerRecord struct {
|
||||
@@ -97,7 +105,7 @@ type ServerRecord struct {
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// BanEventRecord represents a single ban event stored in the internal database.
|
||||
// BanEventRecord represents a single ban or unban event stored in the internal database.
|
||||
type BanEventRecord struct {
|
||||
ID int64 `json:"id"`
|
||||
ServerID string `json:"serverId"`
|
||||
@@ -109,6 +117,7 @@ type BanEventRecord struct {
|
||||
Failures string `json:"failures"`
|
||||
Whois string `json:"whois"`
|
||||
Logs string `json:"logs"`
|
||||
EventType string `json:"eventType"`
|
||||
OccurredAt time.Time `json:"occurredAt"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
@@ -175,17 +184,17 @@ func GetAppSettings(ctx context.Context) (AppSettingsRecord, bool, error) {
|
||||
}
|
||||
|
||||
row := db.QueryRowContext(ctx, `
|
||||
SELECT language, port, debug, callback_url, restart_needed, alert_countries, smtp_host, smtp_port, smtp_username, smtp_password, smtp_from, smtp_use_tls, bantime_increment, default_jail_enable, ignore_ip, bantime, findtime, maxretry, destemail, banaction, banaction_allports, advanced_actions, geoip_provider, geoip_database_path, max_log_lines, callback_secret
|
||||
SELECT language, port, debug, restart_needed, callback_url, callback_secret, alert_countries, email_alerts_for_bans, email_alerts_for_unbans, smtp_host, smtp_port, smtp_username, smtp_password, smtp_from, smtp_use_tls, bantime_increment, default_jail_enable, ignore_ip, bantime, findtime, maxretry, destemail, banaction, banaction_allports, advanced_actions, geoip_provider, geoip_database_path, max_log_lines
|
||||
FROM app_settings
|
||||
WHERE id = 1`)
|
||||
|
||||
var (
|
||||
lang, callback, alerts, smtpHost, smtpUser, smtpPass, smtpFrom, ignoreIP, bantime, findtime, destemail, banaction, banactionAllports, advancedActions, geoipProvider, geoipDatabasePath, callbackSecret sql.NullString
|
||||
lang, callback, callbackSecret, alerts, smtpHost, smtpUser, smtpPass, smtpFrom, ignoreIP, bantime, findtime, destemail, banaction, banactionAllports, advancedActions, geoipProvider, geoipDatabasePath sql.NullString
|
||||
port, smtpPort, maxretry, maxLogLines sql.NullInt64
|
||||
debug, restartNeeded, smtpTLS, bantimeInc, defaultJailEn sql.NullInt64
|
||||
debug, restartNeeded, smtpTLS, bantimeInc, defaultJailEn, emailAlertsForBans, emailAlertsForUnbans sql.NullInt64
|
||||
)
|
||||
|
||||
err := row.Scan(&lang, &port, &debug, &callback, &restartNeeded, &alerts, &smtpHost, &smtpPort, &smtpUser, &smtpPass, &smtpFrom, &smtpTLS, &bantimeInc, &defaultJailEn, &ignoreIP, &bantime, &findtime, &maxretry, &destemail, &banaction, &banactionAllports, &advancedActions, &geoipProvider, &geoipDatabasePath, &maxLogLines, &callbackSecret)
|
||||
err := row.Scan(&lang, &port, &debug, &restartNeeded, &callback, &callbackSecret, &alerts, &emailAlertsForBans, &emailAlertsForUnbans, &smtpHost, &smtpPort, &smtpUser, &smtpPass, &smtpFrom, &smtpTLS, &bantimeInc, &defaultJailEn, &ignoreIP, &bantime, &findtime, &maxretry, &destemail, &banaction, &banactionAllports, &advancedActions, &geoipProvider, &geoipDatabasePath, &maxLogLines)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return AppSettingsRecord{}, false, nil
|
||||
}
|
||||
@@ -194,32 +203,40 @@ WHERE id = 1`)
|
||||
}
|
||||
|
||||
rec := AppSettingsRecord{
|
||||
Language: stringFromNull(lang),
|
||||
Port: intFromNull(port),
|
||||
Debug: intToBool(intFromNull(debug)),
|
||||
CallbackURL: stringFromNull(callback),
|
||||
RestartNeeded: intToBool(intFromNull(restartNeeded)),
|
||||
AlertCountriesJSON: stringFromNull(alerts),
|
||||
SMTPHost: stringFromNull(smtpHost),
|
||||
SMTPPort: intFromNull(smtpPort),
|
||||
SMTPUsername: stringFromNull(smtpUser),
|
||||
SMTPPassword: stringFromNull(smtpPass),
|
||||
SMTPFrom: stringFromNull(smtpFrom),
|
||||
SMTPUseTLS: intToBool(intFromNull(smtpTLS)),
|
||||
BantimeIncrement: intToBool(intFromNull(bantimeInc)),
|
||||
DefaultJailEnable: intToBool(intFromNull(defaultJailEn)),
|
||||
IgnoreIP: stringFromNull(ignoreIP),
|
||||
Bantime: stringFromNull(bantime),
|
||||
Findtime: stringFromNull(findtime),
|
||||
MaxRetry: intFromNull(maxretry),
|
||||
DestEmail: stringFromNull(destemail),
|
||||
Banaction: stringFromNull(banaction),
|
||||
BanactionAllports: stringFromNull(banactionAllports),
|
||||
// Basic app settings
|
||||
Language: stringFromNull(lang),
|
||||
Port: intFromNull(port),
|
||||
Debug: intToBool(intFromNull(debug)),
|
||||
RestartNeeded: intToBool(intFromNull(restartNeeded)),
|
||||
// Callback settings
|
||||
CallbackURL: stringFromNull(callback),
|
||||
CallbackSecret: stringFromNull(callbackSecret),
|
||||
// Alert settings
|
||||
AlertCountriesJSON: stringFromNull(alerts),
|
||||
EmailAlertsForBans: intToBool(intFromNull(emailAlertsForBans)),
|
||||
EmailAlertsForUnbans: intToBool(intFromNull(emailAlertsForUnbans)),
|
||||
// SMTP settings
|
||||
SMTPHost: stringFromNull(smtpHost),
|
||||
SMTPPort: intFromNull(smtpPort),
|
||||
SMTPUsername: stringFromNull(smtpUser),
|
||||
SMTPPassword: stringFromNull(smtpPass),
|
||||
SMTPFrom: stringFromNull(smtpFrom),
|
||||
SMTPUseTLS: intToBool(intFromNull(smtpTLS)),
|
||||
// Fail2Ban DEFAULT settings
|
||||
BantimeIncrement: intToBool(intFromNull(bantimeInc)),
|
||||
DefaultJailEnable: intToBool(intFromNull(defaultJailEn)),
|
||||
IgnoreIP: stringFromNull(ignoreIP),
|
||||
Bantime: stringFromNull(bantime),
|
||||
Findtime: stringFromNull(findtime),
|
||||
MaxRetry: intFromNull(maxretry),
|
||||
DestEmail: stringFromNull(destemail),
|
||||
Banaction: stringFromNull(banaction),
|
||||
BanactionAllports: stringFromNull(banactionAllports),
|
||||
// Advanced features
|
||||
AdvancedActionsJSON: stringFromNull(advancedActions),
|
||||
GeoIPProvider: stringFromNull(geoipProvider),
|
||||
GeoIPDatabasePath: stringFromNull(geoipDatabasePath),
|
||||
MaxLogLines: intFromNull(maxLogLines),
|
||||
CallbackSecret: stringFromNull(callbackSecret),
|
||||
}
|
||||
|
||||
return rec, true, nil
|
||||
@@ -231,16 +248,19 @@ func SaveAppSettings(ctx context.Context, rec AppSettingsRecord) error {
|
||||
}
|
||||
_, err := db.ExecContext(ctx, `
|
||||
INSERT INTO app_settings (
|
||||
id, language, port, debug, callback_url, restart_needed, alert_countries, smtp_host, smtp_port, smtp_username, smtp_password, smtp_from, smtp_use_tls, bantime_increment, default_jail_enable, ignore_ip, bantime, findtime, maxretry, destemail, banaction, banaction_allports, advanced_actions, geoip_provider, geoip_database_path, max_log_lines, callback_secret
|
||||
id, language, port, debug, restart_needed, callback_url, callback_secret, alert_countries, email_alerts_for_bans, email_alerts_for_unbans, smtp_host, smtp_port, smtp_username, smtp_password, smtp_from, smtp_use_tls, bantime_increment, default_jail_enable, ignore_ip, bantime, findtime, maxretry, destemail, banaction, banaction_allports, advanced_actions, geoip_provider, geoip_database_path, max_log_lines
|
||||
) VALUES (
|
||||
1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||
) ON CONFLICT(id) DO UPDATE SET
|
||||
language = excluded.language,
|
||||
port = excluded.port,
|
||||
debug = excluded.debug,
|
||||
callback_url = excluded.callback_url,
|
||||
restart_needed = excluded.restart_needed,
|
||||
callback_url = excluded.callback_url,
|
||||
callback_secret = excluded.callback_secret,
|
||||
alert_countries = excluded.alert_countries,
|
||||
email_alerts_for_bans = excluded.email_alerts_for_bans,
|
||||
email_alerts_for_unbans = excluded.email_alerts_for_unbans,
|
||||
smtp_host = excluded.smtp_host,
|
||||
smtp_port = excluded.smtp_port,
|
||||
smtp_username = excluded.smtp_username,
|
||||
@@ -259,14 +279,16 @@ INSERT INTO app_settings (
|
||||
advanced_actions = excluded.advanced_actions,
|
||||
geoip_provider = excluded.geoip_provider,
|
||||
geoip_database_path = excluded.geoip_database_path,
|
||||
max_log_lines = excluded.max_log_lines,
|
||||
callback_secret = excluded.callback_secret
|
||||
max_log_lines = excluded.max_log_lines
|
||||
`, rec.Language,
|
||||
rec.Port,
|
||||
boolToInt(rec.Debug),
|
||||
rec.CallbackURL,
|
||||
boolToInt(rec.RestartNeeded),
|
||||
rec.CallbackURL,
|
||||
rec.CallbackSecret,
|
||||
rec.AlertCountriesJSON,
|
||||
boolToInt(rec.EmailAlertsForBans),
|
||||
boolToInt(rec.EmailAlertsForUnbans),
|
||||
rec.SMTPHost,
|
||||
rec.SMTPPort,
|
||||
rec.SMTPUsername,
|
||||
@@ -286,7 +308,6 @@ INSERT INTO app_settings (
|
||||
rec.GeoIPProvider,
|
||||
rec.GeoIPDatabasePath,
|
||||
rec.MaxLogLines,
|
||||
rec.CallbackSecret,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -462,10 +483,16 @@ func RecordBanEvent(ctx context.Context, record BanEventRecord) error {
|
||||
record.OccurredAt = now
|
||||
}
|
||||
|
||||
// Default to 'ban' if event type is not set
|
||||
eventType := record.EventType
|
||||
if eventType == "" {
|
||||
eventType = "ban"
|
||||
}
|
||||
|
||||
const query = `
|
||||
INSERT INTO ban_events (
|
||||
server_id, server_name, jail, ip, country, hostname, failures, whois, logs, occurred_at, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
server_id, server_name, jail, ip, country, hostname, failures, whois, logs, event_type, occurred_at, created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
|
||||
_, err := db.ExecContext(
|
||||
ctx,
|
||||
@@ -479,6 +506,7 @@ INSERT INTO ban_events (
|
||||
record.Failures,
|
||||
record.Whois,
|
||||
record.Logs,
|
||||
eventType,
|
||||
record.OccurredAt.UTC(),
|
||||
record.CreatedAt.UTC(),
|
||||
)
|
||||
@@ -500,7 +528,7 @@ func ListBanEvents(ctx context.Context, serverID string, limit int, since time.T
|
||||
}
|
||||
|
||||
baseQuery := `
|
||||
SELECT id, server_id, server_name, jail, ip, country, hostname, failures, whois, logs, occurred_at, created_at
|
||||
SELECT id, server_id, server_name, jail, ip, country, hostname, failures, whois, logs, event_type, occurred_at, created_at
|
||||
FROM ban_events
|
||||
WHERE 1=1`
|
||||
|
||||
@@ -526,6 +554,7 @@ WHERE 1=1`
|
||||
var results []BanEventRecord
|
||||
for rows.Next() {
|
||||
var rec BanEventRecord
|
||||
var eventType sql.NullString
|
||||
if err := rows.Scan(
|
||||
&rec.ID,
|
||||
&rec.ServerID,
|
||||
@@ -537,11 +566,18 @@ WHERE 1=1`
|
||||
&rec.Failures,
|
||||
&rec.Whois,
|
||||
&rec.Logs,
|
||||
&eventType,
|
||||
&rec.OccurredAt,
|
||||
&rec.CreatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Default to 'ban' if event_type is NULL (for backward compatibility)
|
||||
if eventType.Valid {
|
||||
rec.EventType = eventType.String
|
||||
} else {
|
||||
rec.EventType = "ban"
|
||||
}
|
||||
results = append(results, rec)
|
||||
}
|
||||
|
||||
@@ -786,18 +822,26 @@ func ensureSchema(ctx context.Context) error {
|
||||
const createTable = `
|
||||
CREATE TABLE IF NOT EXISTS app_settings (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
-- Basic app settings
|
||||
language TEXT,
|
||||
port INTEGER,
|
||||
debug INTEGER,
|
||||
callback_url TEXT,
|
||||
restart_needed INTEGER,
|
||||
-- Callback settings
|
||||
callback_url TEXT,
|
||||
callback_secret TEXT,
|
||||
-- Alert settings
|
||||
alert_countries TEXT,
|
||||
email_alerts_for_bans INTEGER DEFAULT 1,
|
||||
email_alerts_for_unbans INTEGER DEFAULT 0,
|
||||
-- SMTP settings
|
||||
smtp_host TEXT,
|
||||
smtp_port INTEGER,
|
||||
smtp_username TEXT,
|
||||
smtp_password TEXT,
|
||||
smtp_from TEXT,
|
||||
smtp_use_tls INTEGER,
|
||||
-- Fail2Ban DEFAULT settings
|
||||
bantime_increment INTEGER,
|
||||
default_jail_enable INTEGER,
|
||||
ignore_ip TEXT,
|
||||
@@ -807,11 +851,11 @@ CREATE TABLE IF NOT EXISTS app_settings (
|
||||
destemail TEXT,
|
||||
banaction TEXT,
|
||||
banaction_allports TEXT,
|
||||
-- Advanced features
|
||||
advanced_actions TEXT,
|
||||
geoip_provider TEXT,
|
||||
geoip_database_path TEXT,
|
||||
max_log_lines INTEGER,
|
||||
callback_secret TEXT
|
||||
max_log_lines INTEGER
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS servers (
|
||||
@@ -846,6 +890,7 @@ CREATE TABLE IF NOT EXISTS ban_events (
|
||||
failures TEXT,
|
||||
whois TEXT,
|
||||
logs TEXT,
|
||||
event_type TEXT NOT NULL DEFAULT 'ban',
|
||||
occurred_at DATETIME NOT NULL,
|
||||
created_at DATETIME NOT NULL
|
||||
);
|
||||
@@ -873,69 +918,16 @@ CREATE INDEX IF NOT EXISTS idx_perm_blocks_status ON permanent_blocks(status);
|
||||
return err
|
||||
}
|
||||
|
||||
// Backfill needs_restart column for existing databases that predate it.
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE servers ADD COLUMN needs_restart INTEGER DEFAULT 0`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Backfill banaction columns for existing databases that predate them.
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN banaction TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN banaction_allports TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN advanced_actions TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Add geoip_provider column
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN geoip_provider TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Add geoip_database_path column
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN geoip_database_path TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Add max_log_lines column
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN max_log_lines INTEGER`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Add callback_secret column
|
||||
if _, err := db.ExecContext(ctx, `ALTER TABLE app_settings ADD COLUMN callback_secret TEXT`); err != nil {
|
||||
if !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Set default values for new columns if they are NULL
|
||||
if _, err := db.ExecContext(ctx, `UPDATE app_settings SET geoip_provider = 'maxmind' WHERE geoip_provider IS NULL`); err != nil {
|
||||
log.Printf("Warning: Failed to set default value for geoip_provider: %v", err)
|
||||
}
|
||||
if _, err := db.ExecContext(ctx, `UPDATE app_settings SET geoip_database_path = '/usr/share/GeoIP/GeoLite2-Country.mmdb' WHERE geoip_database_path IS NULL`); err != nil {
|
||||
log.Printf("Warning: Failed to set default value for geoip_database_path: %v", err)
|
||||
}
|
||||
if _, err := db.ExecContext(ctx, `UPDATE app_settings SET max_log_lines = 50 WHERE max_log_lines IS NULL OR max_log_lines = 0`); err != nil {
|
||||
log.Printf("Warning: Failed to set default value for max_log_lines: %v", err)
|
||||
}
|
||||
// NOTE: Database migrations for feature releases
|
||||
// For this version, we start with a fresh schema. Future feature releases
|
||||
// that require database schema changes should add migration logic here.
|
||||
// Example migration pattern:
|
||||
// if _, err := db.ExecContext(ctx, `ALTER TABLE table_name ADD COLUMN new_column TYPE DEFAULT value`); err != nil {
|
||||
// if err != nil && !strings.Contains(strings.ToLower(err.Error()), "duplicate column name") {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
_ = strings.Contains // Keep strings import for migration example above
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user