Created
March 28, 2016 21:25
-
-
Save eiginn/3285baf647fd1403ce18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# GistID: 3285baf647fd1403ce18 | |
import sys | |
from netaddr import IPNetwork, cidr_merge, AddrFormatError | |
CF_ANYCAST_NETS = [] | |
lines = [] | |
if len(sys.argv) > 1: | |
with open(sys.argv[1]) as f: | |
for line in f.readlines(): | |
lines.append(line) | |
else: | |
for line in sys.stdin.readlines(): | |
lines.append(line) | |
for line in lines: | |
try: | |
CF_ANYCAST_NETS.append(IPNetwork(line)) | |
except AddrFormatError: | |
pass | |
for net in cidr_merge(CF_ANYCAST_NETS): | |
print net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment