def check_non_block(ip):
"""Checks if the ip is in the nonblocklist."""
nonblockdict = parse_nonblock_file(NONBLOCKFILE)
# We have the result of the nonblock.cfg-file in the dict
# nonblockdict. This dict contains 3 things:
# 1 - Specific ip-addresses
# 2 - Ip-ranges (129.241.xxx.xxx/xx)
# 3 - Ip lists (129.241.xxx.xxx-xxx)
# Specific ip-addresses
if ip in nonblockdict['ip']:
LOGGER.info('Computer in nonblock list, skipping')
raise InExceptionListError
# Ip-ranges
for ip_range in nonblockdict['range']:
if ip in IP(ip_range):
raise InExceptionListError
评论列表
文章目录