From 57ea37ea2c34183fe7eb06a5fefbcf3b178e55fe Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Sat, 3 Feb 2024 22:29:59 -0500 Subject: [PATCH] internetdb speed optimization --- bbot/modules/internetdb.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bbot/modules/internetdb.py b/bbot/modules/internetdb.py index cc6bde5758..5e33f1155c 100644 --- a/bbot/modules/internetdb.py +++ b/bbot/modules/internetdb.py @@ -115,10 +115,11 @@ def get_ip(self, event): elif event.type == "DNS_NAME": # always try IPv4 first ipv6 = [] - for host in event.resolved_hosts: - if self.helpers.is_ip(host, version=4): - return host - elif self.helpers.is_ip(host, version=6): - ipv6.append(host) + ips = [self.helpers.make_ip_type(h) for h in event.resolved_hosts if self.helpers.is_ip(h)] + for ip in sorted(ips): + if self.helpers.is_ip(ip, version=4): + return ip + elif self.helpers.is_ip(ip, version=6): + ipv6.append(ip) for ip in ipv6: return ip