diff --git a/smtpd_watcher/smtpd_watcher.py b/smtpd_watcher/smtpd_watcher.py index fd3703f..dafba20 100644 --- a/smtpd_watcher/smtpd_watcher.py +++ b/smtpd_watcher/smtpd_watcher.py @@ -48,7 +48,7 @@ class SmtpdWatcher: def _read_banned_ips(self): ips = {} result = subprocess.run( - ['/usr/bin/fail2ban-client', 'get', 'postfix', 'banned'], + ['/usr/bin/fail2ban-client', 'get', 'postfix', 'banned', '|', 'tr', '-d', '"][\',"'], encoding='utf-8', check=True, capture_output=True, @@ -56,18 +56,18 @@ class SmtpdWatcher: self._log.debug( result.stdout ) - ips['postfix'] = json.loads(result.stdout) + ips['postfix'] = result.stdout.split(' ') self._log.debug( "Banned IPs in postfix jail: %s", ips['postfix'] ) result = subprocess.run( - ['/usr/bin/fail2ban-client', 'get', 'postfix-sasl', 'banned'], + ['/usr/bin/fail2ban-client', 'get', 'postfix-sasl', 'banned', '|', 'tr', '-d', '"][\',"'], encoding='utf-8', check=True, capture_output=True, ) - ips['postfix-sasl'] = json.loads(result.stdout) + ips['postfix-sasl'] = result.stdout.split(' ') self._log.debug( "Banned IPs in postfix-sasl jail: %s", ips['postfix-sasl']