diff options
author | terminaldweller <thabogre@gmail.com> | 2021-06-05 21:31:14 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2021-06-05 21:31:14 +0000 |
commit | acf6683d531ca50c97e4f553faad7a8bfb86ed0e (patch) | |
tree | aa452b333e7f1e7c05b9d884e5dc4ffcdb41d3cb /bin/exclude_ip_list | |
parent | fixed the w3m script problems. now using exa. some other small stuff (diff) | |
download | scripts-acf6683d531ca50c97e4f553faad7a8bfb86ed0e.tar.gz scripts-acf6683d531ca50c97e4f553faad7a8bfb86ed0e.zip |
too much to talk about...
Diffstat (limited to 'bin/exclude_ip_list')
-rwxr-xr-x | bin/exclude_ip_list | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/exclude_ip_list b/bin/exclude_ip_list new file mode 100755 index 0000000..2fa3e6f --- /dev/null +++ b/bin/exclude_ip_list @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +from ipaddress import ip_network + +start = '0.0.0.0/0' +exclude = ['127.0.0.1', '192.168.1.0/24', '185.126.202.69', '87.236.209.206'] + +result = [ip_network(start)] +for x in exclude: + n = ip_network(x) + new = [] + for y in result: + if y.overlaps(n): + new.extend(y.address_exclude(n)) + else: + new.append(y) + result = new + +print(','.join(str(x) for x in sorted(result))) |