Commit f344eb78 authored by Max Lv's avatar Max Lv

update chnroute

parent 5f6effba
......@@ -10,14 +10,14 @@ import IPy
def main():
china_list_set = IPy.IPSet()
# for line in sys.stdin:
# line_params = line.split("|")
# if len(line_params) < 5 or line_params[2] != "ipv4" or line_params[1] != "CN":
# continue
# ip_addr = line_params[3]
# ip_length = float(line_params[4])
# ip_mask = 32 - int(math.ceil(math.log(ip_length, 2)))
# china_list_set.add(IPy.IP("%s/%d" % (ip_addr, ip_mask)))
for line in sys.stdin:
line_params = line.split("|")
if len(line_params) < 5 or line_params[2] != "ipv4" or line_params[1] != "CN":
continue
ip_addr = line_params[3]
ip_length = float(line_params[4])
ip_mask = 32 - int(math.ceil(math.log(ip_length, 2)))
china_list_set.add(IPy.IP("%s/%d" % (ip_addr, ip_mask)))
# 添加内网地址
internal_list = IPy.IPSet(map(IPy.IP, [
......@@ -41,11 +41,13 @@ def main():
]))
china_list_set += internal_list
all = china_list_set
# 取反
all = IPy.IPSet([IPy.IP("0.0.0.0/0")])
# all = IPy.IPSet([IPy.IP("0.0.0.0/0")])
# 剔除所有孤立的C段
for ip in china_list_set:
all.discard(ip)
# for ip in china_list_set:
# all.discard(ip)
# filter = itertools.ifilter(lambda x: len(x) <= 65536, all)
# for ip in filter:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment