From cec97749e5fe889931ca49399f8e1f8368869c78 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 15 Nov 2018 15:41:55 +0000 Subject: Make IP regex neater in modules/ip_addresses.py --- modules/ip_addresses.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/ip_addresses.py b/modules/ip_addresses.py index 6441f4b7..1d1e262a 100644 --- a/modules/ip_addresses.py +++ b/modules/ip_addresses.py @@ -2,10 +2,9 @@ import re, socket from src import ModuleManager, utils URL_GEOIP = "http://ip-api.com/json/%s" -REGEX_IP = ("((?:(?:[a-f0-9]{1,4}:){2,}|[a-f0-9:]*::)[a-f0-9:]*)" # ipv6 - "|" - "((?:\d{1,3}\.){3}\d{1,3})") # ipv4 -REGEX_IP = re.compile(REGEX_IP, re.I) +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}" +REGEX_IP = re.compile("%s|%s" % (REGEX_IPv4, REGEX_IPv6), re.I) class Module(ModuleManager.BaseModule): @utils.hook("received.command.dns", min_args=1) -- cgit v1.3.1-10-gc9f91