mirror of
https://github.com/swissmakers/fail2ban-ui.git
synced 2026-04-19 06:53:14 +02:00
Add sections to integrations
This commit is contained in:
@@ -17,6 +17,10 @@ func init() {
|
||||
Register(&mikrotikIntegration{})
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Interface Implementation
|
||||
// =========================================================================
|
||||
|
||||
func (m *mikrotikIntegration) ID() string {
|
||||
return "mikrotik"
|
||||
}
|
||||
@@ -41,6 +45,10 @@ func (m *mikrotikIntegration) Validate(cfg config.AdvancedActionsConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Block/Unblock
|
||||
// =========================================================================
|
||||
|
||||
func (m *mikrotikIntegration) BlockIP(req Request) error {
|
||||
if err := m.Validate(req.Config); err != nil {
|
||||
return err
|
||||
@@ -59,6 +67,10 @@ func (m *mikrotikIntegration) UnblockIP(req Request) error {
|
||||
return m.runCommand(req, cmd)
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// SSH Communication
|
||||
// =========================================================================
|
||||
|
||||
func (m *mikrotikIntegration) runCommand(req Request, command string) error {
|
||||
cfg := req.Config.Mikrotik
|
||||
|
||||
@@ -97,7 +109,6 @@ func (m *mikrotikIntegration) runCommand(req Request, command string) error {
|
||||
address := net.JoinHostPort(cfg.Host, fmt.Sprintf("%d", port))
|
||||
client, err := ssh.Dial("tcp", address, clientCfg)
|
||||
if err != nil {
|
||||
// Provide more specific error messages for common connection issues
|
||||
if netErr, ok := err.(net.Error); ok {
|
||||
if netErr.Timeout() {
|
||||
return fmt.Errorf("connection to mikrotik at %s timed out: %w", address, err)
|
||||
|
||||
Reference in New Issue
Block a user