From 9ede535a616802434ecb9826ed5c40a6ac81317f Mon Sep 17 00:00:00 2001 From: Alexander Koeppe Date: Tue, 15 Mar 2016 00:36:08 +0100 Subject: [PATCH] remove obsolete IP related code from DNSUtils class # Conflicts: # fail2ban/server/filter.py --- fail2ban/server/filter.py | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/fail2ban/server/filter.py b/fail2ban/server/filter.py index 04f34821..baf4bc9b 100644 --- a/fail2ban/server/filter.py +++ b/fail2ban/server/filter.py @@ -981,10 +981,10 @@ class JournalFilter(Filter): # pragma: systemd no cover return [] ## -# Utils class for DNS and IP handling. +# Utils class for DNS handling. +# +# This class contains only static methods used to handle DNS # -# This class contains only static methods used to handle DNS and IP -# addresses. import socket import struct @@ -1038,17 +1038,6 @@ class DNSUtils: DNSUtils.CACHE_ipToName.set(ip, v) return v - @staticmethod - def isValidIP(string): - """ Return true if str is a valid IP - """ - s = string.split('/', 1) - try: - socket.inet_aton(s[0]) - return True - except socket.error: # pragma: no cover - return False - @staticmethod def textToIp(text, useDns): """ Return the IP of DNS found in a given text. @@ -1072,25 +1061,6 @@ class DNSUtils: return ipList - @staticmethod - def addr2bin(ipstring, cidr=None): - """ Convert a string IPv4 address into binary form. - If cidr is supplied, return the network address for the given block - """ - if cidr is None: - return struct.unpack("!L", socket.inet_aton(ipstring))[0] - else: - MASK = 0xFFFFFFFFL - return ~(MASK >> cidr) & MASK & DNSUtils.addr2bin(ipstring) - - @staticmethod - def bin2addr(ipbin): - """ Convert a binary IPv4 address into string n.n.n.n form. - """ - return socket.inet_ntoa(struct.pack("!L", ipbin)) - - - ## # Class for IP address handling. #