From 9f426c80993692a7fa56a502699e5d692acd7a4a Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Wed, 21 Apr 2021 16:42:55 +0200 Subject: [PATCH] chg: [stackpath] host IPv6 addresses are without subnet --- tools/generate-stackpath.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/generate-stackpath.py b/tools/generate-stackpath.py index d147a4e..b791166 100755 --- a/tools/generate-stackpath.py +++ b/tools/generate-stackpath.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- from generator import download_to_file, get_version, write_to_file, get_abspath_source_file - +import ipaddress def process(files, dst): warninglist = { @@ -18,11 +18,15 @@ def process(files, dst): with open(get_abspath_source_file(file), 'r') as f: ips = f.readlines() for ip in ips: - warninglist['list'].append(ip.strip()) + iptoadd = ip.strip() + try: + ipaddress.ip_network(ip.strip()) + except ValueError as err:# if it's host given strip to the subnet + iptoadd = str(ipaddress.IPv6Interface(ip.strip()).ip) + warninglist['list'].append(iptoadd) write_to_file(warninglist, dst) - if __name__ == '__main__': sp_base_url = "https://support.stackpath.com/hc/en-us/article_attachments/360083735711/" uri_list = ['ipblocks.txt']