Make IP regex neater in modules/ip_addresses.py

This commit is contained in:
jesopo 2018-11-15 15:41:55 +00:00
parent 64a58fe041
commit cec97749e5

View file

@ -2,10 +2,9 @@ import re, socket
from src import ModuleManager, utils from src import ModuleManager, utils
URL_GEOIP = "http://ip-api.com/json/%s" URL_GEOIP = "http://ip-api.com/json/%s"
REGEX_IP = ("((?:(?:[a-f0-9]{1,4}:){2,}|[a-f0-9:]*::)[a-f0-9:]*)" # ipv6 REGEX_IPv6 = r"(?:(?:[a-f0-9]{1,4}:){2,}|[a-f0-9:]*::)[a-f0-9:]*"
"|" REGEX_IPv4 = r"(?:\d{1,3}\.){3}\d{1,3}"
"((?:\d{1,3}\.){3}\d{1,3})") # ipv4 REGEX_IP = re.compile("%s|%s" % (REGEX_IPv4, REGEX_IPv6), re.I)
REGEX_IP = re.compile(REGEX_IP, re.I)
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
@utils.hook("received.command.dns", min_args=1) @utils.hook("received.command.dns", min_args=1)