aboutsummaryrefslogtreecommitdiffstats
path: root/bin/exclude_ip_list
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xbin/exclude_ip_list18
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)))