mirror of https://github.com/fail2ban/fail2ban
conditionally import dnspython
parent
ef3c942808
commit
07a47179a7
|
@ -26,9 +26,6 @@ __license__ = "GPL"
|
||||||
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
import dns.exception
|
|
||||||
import dns.resolver
|
|
||||||
|
|
||||||
from .ticket import BanTicket
|
from .ticket import BanTicket
|
||||||
from .mytime import MyTime
|
from .mytime import MyTime
|
||||||
from ..helpers import getLogger
|
from ..helpers import getLogger
|
||||||
|
@ -139,8 +136,17 @@ class BanManager:
|
||||||
# @return {"asn": [], "country": [], "rir": []} dict for self.__banList IPs
|
# @return {"asn": [], "country": [], "rir": []} dict for self.__banList IPs
|
||||||
|
|
||||||
def getBanListExtendedCymruInfo(self):
|
def getBanListExtendedCymruInfo(self):
|
||||||
self.__lock.acquire()
|
|
||||||
return_dict = {"asn": [], "country": [], "rir": []}
|
return_dict = {"asn": [], "country": [], "rir": []}
|
||||||
|
try:
|
||||||
|
import dns.exception
|
||||||
|
import dns.resolver
|
||||||
|
except ImportError:
|
||||||
|
logSys.error("dnspython package is required but could not be imported")
|
||||||
|
return_dict["asn"].append("error")
|
||||||
|
return_dict["country"].append("error")
|
||||||
|
return_dict["rir"].append("error")
|
||||||
|
return return_dict
|
||||||
|
self.__lock.acquire()
|
||||||
try:
|
try:
|
||||||
for banData in self.__banList:
|
for banData in self.__banList:
|
||||||
ip = banData.getIP()
|
ip = banData.getIP()
|
||||||
|
|
Loading…
Reference in New Issue