remove obsolete IP related code from DNSUtils class

# Conflicts:
#	fail2ban/server/filter.py
pull/1414/head
Alexander Koeppe 2016-03-15 00:36:08 +01:00 committed by sebres
parent ce196744d1
commit 9ede535a61
1 changed files with 3 additions and 33 deletions

View File

@ -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.
#