diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py index 6b793b8f..e0719cde 100644 --- a/fail2ban/server/actions.py +++ b/fail2ban/server/actions.py @@ -291,6 +291,7 @@ class Actions(JailThread, Mapping): AI_DICT = { "ip": lambda self: self.__ticket.getIP(), "ip-rev": lambda self: self['ip'].getPTR(''), + "ip-host": lambda self: self['ip'].getHost(), "fid": lambda self: self.__ticket.getID(), "failures": lambda self: self.__ticket.getAttempt(), "time": lambda self: self.__ticket.getTime(), diff --git a/fail2ban/server/ipdns.py b/fail2ban/server/ipdns.py index 757cceba..8990618a 100644 --- a/fail2ban/server/ipdns.py +++ b/fail2ban/server/ipdns.py @@ -376,6 +376,11 @@ class IPAddr(object): return "%s.%s" % (".".join(reversed(exploded_ip)), suffix) + def getHost(self): + """Return the host name (DNS) of the provided IP address object + """ + return DNSUtils.ipToName(self.ntoa) + @property def isIPv4(self): """Either the IP object is of address family AF_INET