`retrieve_block_timeout(...)` crashes entire horde if invalid ip is added to timeout
tazlin opened this issue · 0 comments
tazlin commented
@staticmethod
def retrieve_block_timeout(ipaddr):
'''Checks if the IP is in a block timeout'''
if not ip_t_r:
return
for ip_block_key in ip_t_r.scan_iter("ipblock_*"):
ip_range = ip_block_key.decode().split('_',1)[1]
if ipaddress.ip_address(ipaddr) in ipaddress.ip_network(ip_range):
ttl = ip_t_r.ttl(ip_block_key)
return int(ttl)
return 0
The line if ipaddress.ip_address(ipaddr) in ipaddress.ip_network(ip_range):
needs to try/except or check for an invalid IP to eliminate the possibility of a moderator bringing the entire horde down over a typo in the IP.