Skip to content

Instantly share code, notes, and snippets.

@maliubiao
Created March 12, 2017 06:02
Show Gist options
  • Save maliubiao/a28cf33c514da60e533b4e0dfabc8fb2 to your computer and use it in GitHub Desktop.
Save maliubiao/a28cf33c514da60e533b4e0dfabc8fb2 to your computer and use it in GitHub Desktop.
china ip range for proxy config.
import socket
import re
import struct
def cidr_to_ip_range(cidr):
start, bits = cidr.split("/")
return start, socket.inet_ntoa(struct.pack(">I", struct.unpack(">I", socket.inet_aton(start))[0] | (0xffffffff >> int(bits))))
china_ip = """
1.68.0.0/14
1.80.0.0/13
1.92.0.0/14
1.192.0.0/13
1.202.0.0/15
1.204.0.0/14
14.112.0.0/12
14.144.0.0/12
14.208.0.0/12
23.80.54.0/24
23.104.141.0/24
23.105.14.0/24
23.226.208.0/24
27.8.0.0/13
27.16.0.0/12
27.36.0.0/14
27.40.0.0/13
27.50.128.0/17
27.54.192.0/18
27.106.128.0/18
27.115.0.0/17
27.148.0.0/14
27.152.0.0/13
27.184.0.0/13
36.32.0.0/14
36.248.0.0/14
39.128.0.0/10
42.96.128.0/17
42.120.0.0/15
42.156.0.0/16
43.255.0.0/20
43.255.16.0/22
43.255.48.0/22
43.255.60.0/22
43.255.64.0/20
43.255.96.0/20
43.255.144.0/22
43.255.168.0/22
43.255.176.0/22
43.255.184.0/22
43.255.192.0/22
43.255.200.0/21
43.255.208.0/21
43.255.224.0/21
43.255.232.0/22
43.255.244.0/22
49.64.0.0/11
54.222.0.0/15
58.16.0.0/15
58.20.0.0/16
58.21.0.0/16
58.22.0.0/15
58.34.0.0/16
58.37.0.0/16
58.38.0.0/16
58.40.0.0/16
58.42.0.0/16
58.44.0.0/14
58.48.0.0/13
58.56.0.0/15
58.58.0.0/16
58.59.0.0/17
58.60.0.0/14
58.68.128.0/17
58.82.0.0/15
58.100.0.0/15
58.208.0.0/12
58.242.0.0/15
58.246.0.0/15
58.248.0.0/13
59.32.0.0/12
59.51.0.0/16
59.52.0.0/14
59.56.0.0/13
59.72.0.0/16
59.108.0.0/15
59.172.0.0/14
60.0.0.0/13
60.11.0.0/16
60.12.0.0/16
60.24.0.0/13
60.160.0.0/11
60.194.0.0/15
60.208.0.0/12
61.4.64.0/20
61.4.80.0/22
61.4.176.0/20
61.48.0.0/13
61.128.0.0/10
61.135.0.0/16
61.136.0.0/18
61.139.0.0/16
61.145.73.208/28
61.147.0.0/16
61.150.0.0/16
61.152.0.0/16
61.154.0.0/16
61.160.0.0/16
61.162.0.0/15
61.164.0.0/16
61.172.0.0/15
61.175.0.0/16
61.177.0.0/16
61.179.0.0/16
61.183.0.0/16
61.184.0.0/16
61.185.219.232/29
61.187.0.0/16
61.188.0.0/16
61.232.0.0/14
61.236.0.0/15
61.240.0.0/14
101.64.0.0/13
101.72.0.0/14
101.76.0.0/15
101.80.0.0/12
103.253.4.0/22
106.80.0.0/12
106.108.0.0/14
106.112.0.0/13
110.6.0.0/15
110.51.0.0/16
110.52.0.0/15
110.80.0.0/13
110.88.0.0/14
110.96.0.0/11
110.173.0.0/19
110.173.32.0/20
110.173.64.0/18
110.176.0.0/14
110.192.0.0/11
110.240.0.0/12
111.0.0.0/10
111.72.0.0/13
111.121.0.0/16
111.128.0.0/11
111.160.0.0/13
111.172.0.0/14
111.176.0.0/13
111.192.0.0/12
111.228.0.0/14
112.0.0.0/10
112.64.0.0/14
112.80.0.0/12
112.100.0.0/14
112.109.128.0/17
112.111.0.0/16
112.122.0.0/15
112.224.0.0/11
113.0.0.0/13
113.8.0.0/15
113.12.0.0/14
113.16.0.0/15
113.18.0.0/16
113.54.0.0/15
113.56.0.0/15
113.58.0.0/16
113.59.0.0/17
113.62.0.0/15
113.64.0.0/10
113.120.0.0/13
113.128.0.0/15
113.136.0.0/13
113.194.0.0/15
113.204.0.0/14
114.28.0.0/16
114.80.0.0/12
114.96.0.0/13
114.104.0.0/14
114.112.0.0/14
114.215.0.0/16
114.216.0.0/13
114.224.0.0/11
115.24.0.0/15
115.28.0.0/15
115.32.0.0/14
115.48.0.0/12
115.84.0.0/18
115.100.0.0/15
115.148.0.0/14
115.152.0.0/15
115.159.0.0/16
115.166.64.0/19
115.168.0.0/14
115.212.0.0/16
115.230.0.0/16
115.236.96.0/23
115.236.136.0/22
115.239.228.0/22
116.1.0.0/16
116.2.0.0/15
116.4.0.0/14
116.8.0.0/14
116.16.0.0/12
116.52.0.0/14
116.76.0.0/15
116.90.80.0/20
116.112.0.0/14
116.128.0.0/10
116.204.0.0/15
116.207.0.0/16
116.208.0.0/14
116.224.0.0/12
116.254.128.0/18
117.8.0.0/13
117.21.0.0/16
117.22.0.0/15
117.24.0.0/13
117.32.0.0/13
117.40.0.0/14
117.44.0.0/15
117.60.0.0/14
117.79.224.0/20
117.80.0.0/12
117.128.0.0/10
118.26.0.0/16
118.72.0.0/13
118.112.0.0/13
118.120.0.0/14
118.132.0.0/14
118.144.0.0/14
118.180.0.0/14
118.186.0.0/15
118.192.0.0/15
118.248.0.0/13
119.0.0.0/13
119.8.0.0/16
119.10.0.0/17
119.18.192.0/20
119.36.0.0/16
119.57.0.0/16
119.60.0.0/16
119.88.0.0/14
119.96.0.0/13
119.112.0.0/13
119.120.0.0/13
119.128.0.0/12
119.144.0.0/14
119.164.0.0/14
119.176.0.0/12
119.233.0.0/16
120.0.0.0/12
120.24.0.0/14
120.32.0.0/13
120.40.0.0/14
120.68.0.0/14
120.80.0.0/13
120.192.0.0/10
121.0.16.0/20
121.8.0.0/13
121.16.0.0/12
121.32.0.0/14
121.40.0.0/14
121.60.0.0/14
121.76.0.0/15
121.100.128.0/17
121.196.0.0/14
121.204.0.0/14
121.224.0.0/12
122.10.128.0/17
122.51.128.0/17
122.64.0.0/11
122.96.0.0/15
122.119.0.0/16
122.136.0.0/13
122.156.0.0/14
122.188.0.0/14
122.192.0.0/14
122.198.0.0/16
122.200.64.0/18
122.224.0.0/12
123.4.0.0/14
123.8.0.0/13
123.52.0.0/14
123.56.0.0/14
123.64.0.0/11
123.97.128.0/17
123.100.0.0/19
123.112.0.0/12
123.128.0.0/13
123.138.0.0/15
123.150.0.0/15
123.152.0.0/13
123.164.0.0/14
123.180.0.0/14
123.184.0.0/14
123.196.0.0/15
123.232.0.0/14
123.249.0.0/16
124.42.64.0/18
124.64.0.0/15
124.67.0.0/16
124.72.0.0/16
124.73.0.0/16
124.88.0.0/16
124.114.0.0/15
124.126.0.0/15
124.128.0.0/13
124.160.0.0/15
124.162.0.0/16
124.163.0.0/16
124.192.0.0/15
124.200.0.0/13
124.226.0.0/15
124.228.0.0/14
124.236.0.0/14
124.240.0.0/17
124.240.128.0/18
124.248.0.0/17
125.36.0.0/14
125.40.0.0/13
125.64.0.0/12
125.79.0.0/16
125.80.0.0/13
125.88.0.0/13
125.104.0.0/13
125.112.0.0/12
125.210.0.0/15
139.129.0.0/16
139.208.0.0/13
140.224.0.0/16
140.237.0.0/16
140.246.0.0/16
140.249.0.0/16
142.4.117.0/30
153.99.0.0/16
159.226.0.0/16
171.34.0.0/15
171.36.0.0/14
171.40.0.0/13
171.88.0.0/13
171.116.0.0/14
171.208.0.0/12
175.0.0.0/12
175.16.0.0/13
175.24.0.0/14
175.30.0.0/15
175.42.0.0/15
175.44.0.0/16
175.46.0.0/15
175.48.0.0/12
175.64.0.0/11
175.102.0.0/16
175.106.128.0/17
175.146.0.0/15
175.148.0.0/14
175.152.0.0/14
175.160.0.0/12
175.178.0.0/16
175.184.128.0/18
175.185.0.0/16
175.186.0.0/15
175.188.0.0/14
180.76.0.0/16
180.96.0.0/11
180.136.0.0/13
180.152.0.0/13
180.160.0.0/12
180.208.0.0/15
182.18.0.0/17
182.32.0.0/12
182.88.0.0/14
182.112.0.0/12
182.128.0.0/12
182.240.0.0/13
183.0.0.0/10
183.64.0.0/13
183.128.0.0/12
183.148.0.0/16
183.160.0.0/12
183.184.0.0/13
183.192.0.0/11
192.34.109.224/28
192.74.224.0/19
198.2.203.64/28
198.2.212.160/28
198.15.171.64/26
202.43.144.0/22
202.46.32.0/19
202.66.0.0/16
202.75.208.0/20
202.96.0.0/12
202.111.160.0/19
202.112.0.0/14
202.117.0.0/16
202.165.176.0/20
202.196.80.0/20
203.69.0.0/16
203.86.0.0/18
203.86.64.0/19
203.93.0.0/16
203.169.160.0/19
203.171.224.0/20
203.195.160.0/23
210.5.0.0/19
210.14.128.0/19
210.21.0.0/16
210.32.0.0/14
210.51.0.0/16
210.52.0.0/15
210.77.0.0/16
210.192.96.0/19
211.76.96.0/20
211.78.208.0/20
211.86.144.0/20
211.90.0.0/15
211.92.0.0/14
211.96.0.0/13
211.136.0.0/13
211.144.12.0/22
211.144.96.0/19
211.144.160.0/20
211.147.0.0/16
211.150.0.0/15
211.152.0.0/14
211.157.32.0/19
211.160.0.0/13
211.233.70.0/24
218.0.0.0/11
218.56.0.0/13
218.64.0.0/11
218.84.0.0/14
218.88.0.0/13
218.96.0.0/14
218.102.0.0/16
218.104.0.0/14
218.108.0.0/15
218.194.80.0/20
218.200.0.0/13
218.240.0.0/13
219.128.0.0/11
219.154.0.0/15
219.223.192.0/18
219.232.0.0/16
219.234.80.0/20
219.235.0.0/16
220.112.0.0/16
220.154.0.0/15
220.160.0.0/11
220.181.0.0/16
220.191.0.0/16
220.192.0.0/12
220.228.70.0/24
220.242.0.0/15
220.248.0.0/14
220.250.0.0/19
220.252.0.0/16
221.0.0.0/12
221.122.0.0/15
221.172.0.0/14
221.176.0.0/13
221.192.0.0/14
221.200.0.0/14
221.204.0.0/15
221.206.0.0/16
221.207.0.0/16
221.208.0.0/12
221.212.0.0/15
221.214.0.0/15
221.216.0.0/13
221.224.0.0/13
221.228.0.0/14
221.232.0.0/13
222.32.0.0/11
222.64.0.0/12
222.80.0.0/12
222.132.0.0/14
222.136.0.0/13
222.160.0.0/14
222.168.0.0/13
222.172.222.0/24
222.176.0.0/13
222.184.0.0/13
222.200.0.0/16
222.208.0.0/13
222.219.0.0/16
222.220.0.0/15
222.240.0.0/13
223.4.0.0/14
223.64.0.0/11
223.144.0.0/12
223.240.0.0/13
"""
"""
1.68.0.0-1.71.255.255;1.80.0.0-1.87.255.255;1.92.0.0-1.95.255.255;1.192.0.0-1.199.255.255;1.202.0.0-1.203.255.255;1.204.0.0-1.207.255.255;14.112.0.0-14.127.255.255;14.144.0.0-14.159.255.255;14.208.0.0-14.223.255.255;23.80.54.0-23.80.54.255;23.104.141.0-23.104.141.255;23.105.14.0-23.105.14.255;23.226.208.0-23.226.208.255;27.8.0.0-27.15.255.255;27.16.0.0-27.31.255.255;27.36.0.0-27.39.255.255;27.40.0.0-27.47.255.255;27.50.128.0-27.50.255.255;27.54.192.0-27.54.255.255;27.106.128.0-27.106.191.255;27.115.0.0-27.115.127.255;27.148.0.0-27.151.255.255;27.152.0.0-27.159.255.255;27.184.0.0-27.191.255.255;36.32.0.0-36.35.255.255;36.248.0.0-36.251.255.255;39.128.0.0-39.191.255.255;42.96.128.0-42.96.255.255;42.120.0.0-42.121.255.255;42.156.0.0-42.156.255.255;43.255.0.0-43.255.15.255;43.255.16.0-43.255.19.255;43.255.48.0-43.255.51.255;43.255.60.0-43.255.63.255;43.255.64.0-43.255.79.255;43.255.96.0-43.255.111.255;43.255.144.0-43.255.147.255;43.255.168.0-43.255.171.255;43.255.176.0-43.255.179.255;43.255.184.0-43.255.187.255;43.255.192.0-43.255.195.255;43.255.200.0-43.255.207.255;43.255.208.0-43.255.215.255;43.255.224.0-43.255.231.255;43.255.232.0-43.255.235.255;43.255.244.0-43.255.247.255;49.64.0.0-49.95.255.255;54.222.0.0-54.223.255.255;58.16.0.0-58.17.255.255;58.20.0.0-58.20.255.255;58.21.0.0-58.21.255.255;58.22.0.0-58.23.255.255;58.34.0.0-58.34.255.255;58.37.0.0-58.37.255.255;58.38.0.0-58.38.255.255;58.40.0.0-58.40.255.255;58.42.0.0-58.42.255.255;58.44.0.0-58.47.255.255;58.48.0.0-58.55.255.255;58.56.0.0-58.57.255.255;58.58.0.0-58.58.255.255;58.59.0.0-58.59.127.255;58.60.0.0-58.63.255.255;58.68.128.0-58.68.255.255;58.82.0.0-58.83.255.255;58.100.0.0-58.101.255.255;58.208.0.0-58.223.255.255;58.242.0.0-58.243.255.255;58.246.0.0-58.247.255.255;58.248.0.0-58.255.255.255;59.32.0.0-59.47.255.255;59.51.0.0-59.51.255.255;59.52.0.0-59.55.255.255;59.56.0.0-59.63.255.255;59.72.0.0-59.72.255.255;59.108.0.0-59.109.255.255;59.172.0.0-59.175.255.255;60.0.0.0-60.7.255.255;60.11.0.0-60.11.255.255;60.12.0.0-60.12.255.255;60.24.0.0-60.31.255.255;60.160.0.0-60.191.255.255;60.194.0.0-60.195.255.255;60.208.0.0-60.223.255.255;61.4.64.0-61.4.79.255;61.4.80.0-61.4.83.255;61.4.176.0-61.4.191.255;61.48.0.0-61.55.255.255;61.128.0.0-61.191.255.255;61.135.0.0-61.135.255.255;61.136.0.0-61.136.63.255;61.139.0.0-61.139.255.255;61.145.73.208-61.145.73.223;61.147.0.0-61.147.255.255;61.150.0.0-61.150.255.255;61.152.0.0-61.152.255.255;61.154.0.0-61.154.255.255;61.160.0.0-61.160.255.255;61.162.0.0-61.163.255.255;61.164.0.0-61.164.255.255;61.172.0.0-61.173.255.255;61.175.0.0-61.175.255.255;61.177.0.0-61.177.255.255;61.179.0.0-61.179.255.255;61.183.0.0-61.183.255.255;61.184.0.0-61.184.255.255;61.185.219.232-61.185.219.239;61.187.0.0-61.187.255.255;61.188.0.0-61.188.255.255;61.232.0.0-61.235.255.255;61.236.0.0-61.237.255.255;61.240.0.0-61.243.255.255;101.64.0.0-101.71.255.255;101.72.0.0-101.75.255.255;101.76.0.0-101.77.255.255;101.80.0.0-101.95.255.255;103.253.4.0-103.253.7.255;106.80.0.0-106.95.255.255;106.108.0.0-106.111.255.255;106.112.0.0-106.119.255.255;110.6.0.0-110.7.255.255;110.51.0.0-110.51.255.255;110.52.0.0-110.53.255.255;110.80.0.0-110.87.255.255;110.88.0.0-110.91.255.255;110.96.0.0-110.127.255.255;110.173.0.0-110.173.31.255;110.173.32.0-110.173.47.255;110.173.64.0-110.173.127.255;110.176.0.0-110.179.255.255;110.192.0.0-110.223.255.255;110.240.0.0-110.255.255.255;111.0.0.0-111.63.255.255;111.72.0.0-111.79.255.255;111.121.0.0-111.121.255.255;111.128.0.0-111.159.255.255;111.160.0.0-111.167.255.255;111.172.0.0-111.175.255.255;111.176.0.0-111.183.255.255;111.192.0.0-111.207.255.255;111.228.0.0-111.231.255.255;112.0.0.0-112.63.255.255;112.64.0.0-112.67.255.255;112.80.0.0-112.95.255.255;112.100.0.0-112.103.255.255;112.109.128.0-112.109.255.255;112.111.0.0-112.111.255.255;112.122.0.0-112.123.255.255;112.224.0.0-112.255.255.255;113.0.0.0-113.7.255.255;113.8.0.0-113.9.255.255;113.12.0.0-113.15.255.255;113.16.0.0-113.17.255.255;113.18.0.0-113.18.255.255;113.54.0.0-113.55.255.255;113.56.0.0-113.57.255.255;113.58.0.0-113.58.255.255;113.59.0.0-113.59.127.255;113.62.0.0-113.63.255.255;113.64.0.0-113.127.255.255;113.120.0.0-113.127.255.255;113.128.0.0-113.129.255.255;113.136.0.0-113.143.255.255;113.194.0.0-113.195.255.255;113.204.0.0-113.207.255.255;114.28.0.0-114.28.255.255;114.80.0.0-114.95.255.255;114.96.0.0-114.103.255.255;114.104.0.0-114.107.255.255;114.112.0.0-114.115.255.255;114.215.0.0-114.215.255.255;114.216.0.0-114.223.255.255;114.224.0.0-114.255.255.255;115.24.0.0-115.25.255.255;115.28.0.0-115.29.255.255;115.32.0.0-115.35.255.255;115.48.0.0-115.63.255.255;115.84.0.0-115.84.63.255;115.100.0.0-115.101.255.255;115.148.0.0-115.151.255.255;115.152.0.0-115.153.255.255;115.159.0.0-115.159.255.255;115.166.64.0-115.166.95.255;115.168.0.0-115.171.255.255;115.212.0.0-115.212.255.255;115.230.0.0-115.230.255.255;115.236.96.0-115.236.97.255;115.236.136.0-115.236.139.255;115.239.228.0-115.239.231.255;116.1.0.0-116.1.255.255;116.2.0.0-116.3.255.255;116.4.0.0-116.7.255.255;116.8.0.0-116.11.255.255;116.16.0.0-116.31.255.255;116.52.0.0-116.55.255.255;116.76.0.0-116.77.255.255;116.90.80.0-116.90.95.255;116.112.0.0-116.115.255.255;116.128.0.0-116.191.255.255;116.204.0.0-116.205.255.255;116.207.0.0-116.207.255.255;116.208.0.0-116.211.255.255;116.224.0.0-116.239.255.255;116.254.128.0-116.254.191.255;117.8.0.0-117.15.255.255;117.21.0.0-117.21.255.255;117.22.0.0-117.23.255.255;117.24.0.0-117.31.255.255;117.32.0.0-117.39.255.255;117.40.0.0-117.43.255.255;117.44.0.0-117.45.255.255;117.60.0.0-117.63.255.255;117.79.224.0-117.79.239.255;117.80.0.0-117.95.255.255;117.128.0.0-117.191.255.255;118.26.0.0-118.26.255.255;118.72.0.0-118.79.255.255;118.112.0.0-118.119.255.255;118.120.0.0-118.123.255.255;118.132.0.0-118.135.255.255;118.144.0.0-118.147.255.255;118.180.0.0-118.183.255.255;118.186.0.0-118.187.255.255;118.192.0.0-118.193.255.255;118.248.0.0-118.255.255.255;119.0.0.0-119.7.255.255;119.8.0.0-119.8.255.255;119.10.0.0-119.10.127.255;119.18.192.0-119.18.207.255;119.36.0.0-119.36.255.255;119.57.0.0-119.57.255.255;119.60.0.0-119.60.255.255;119.88.0.0-119.91.255.255;119.96.0.0-119.103.255.255;119.112.0.0-119.119.255.255;119.120.0.0-119.127.255.255;119.128.0.0-119.143.255.255;119.144.0.0-119.147.255.255;119.164.0.0-119.167.255.255;119.176.0.0-119.191.255.255;119.233.0.0-119.233.255.255;120.0.0.0-120.15.255.255;120.24.0.0-120.27.255.255;120.32.0.0-120.39.255.255;120.40.0.0-120.43.255.255;120.68.0.0-120.71.255.255;120.80.0.0-120.87.255.255;120.192.0.0-120.255.255.255;121.0.16.0-121.0.31.255;121.8.0.0-121.15.255.255;121.16.0.0-121.31.255.255;121.32.0.0-121.35.255.255;121.40.0.0-121.43.255.255;121.60.0.0-121.63.255.255;121.76.0.0-121.77.255.255;121.100.128.0-121.100.255.255;121.196.0.0-121.199.255.255;121.204.0.0-121.207.255.255;121.224.0.0-121.239.255.255;122.10.128.0-122.10.255.255;122.51.128.0-122.51.255.255;122.64.0.0-122.95.255.255;122.96.0.0-122.97.255.255;122.119.0.0-122.119.255.255;122.136.0.0-122.143.255.255;122.156.0.0-122.159.255.255;122.188.0.0-122.191.255.255;122.192.0.0-122.195.255.255;122.198.0.0-122.198.255.255;122.200.64.0-122.200.127.255;122.224.0.0-122.239.255.255;123.4.0.0-123.7.255.255;123.8.0.0-123.15.255.255;123.52.0.0-123.55.255.255;123.56.0.0-123.59.255.255;123.64.0.0-123.95.255.255;123.97.128.0-123.97.255.255;123.100.0.0-123.100.31.255;123.112.0.0-123.127.255.255;123.128.0.0-123.135.255.255;123.138.0.0-123.139.255.255;123.150.0.0-123.151.255.255;123.152.0.0-123.159.255.255;123.164.0.0-123.167.255.255;123.180.0.0-123.183.255.255;123.184.0.0-123.187.255.255;123.196.0.0-123.197.255.255;123.232.0.0-123.235.255.255;123.249.0.0-123.249.255.255;124.42.64.0-124.42.127.255;124.64.0.0-124.65.255.255;124.67.0.0-124.67.255.255;124.72.0.0-124.72.255.255;124.73.0.0-124.73.255.255;124.88.0.0-124.88.255.255;124.114.0.0-124.115.255.255;124.126.0.0-124.127.255.255;124.128.0.0-124.135.255.255;124.160.0.0-124.161.255.255;124.162.0.0-124.162.255.255;124.163.0.0-124.163.255.255;124.192.0.0-124.193.255.255;124.200.0.0-124.207.255.255;124.226.0.0-124.227.255.255;124.228.0.0-124.231.255.255;124.236.0.0-124.239.255.255;124.240.0.0-124.240.127.255;124.240.128.0-124.240.191.255;124.248.0.0-124.248.127.255;125.36.0.0-125.39.255.255;125.40.0.0-125.47.255.255;125.64.0.0-125.79.255.255;125.79.0.0-125.79.255.255;125.80.0.0-125.87.255.255;125.88.0.0-125.95.255.255;125.104.0.0-125.111.255.255;125.112.0.0-125.127.255.255;125.210.0.0-125.211.255.255;139.129.0.0-139.129.255.255;139.208.0.0-139.215.255.255;140.224.0.0-140.224.255.255;140.237.0.0-140.237.255.255;140.246.0.0-140.246.255.255;140.249.0.0-140.249.255.255;142.4.117.0-142.4.117.3;153.99.0.0-153.99.255.255;159.226.0.0-159.226.255.255;171.34.0.0-171.35.255.255;171.36.0.0-171.39.255.255;171.40.0.0-171.47.255.255;171.88.0.0-171.95.255.255;171.116.0.0-171.119.255.255;171.208.0.0-171.223.255.255;175.0.0.0-175.15.255.255;175.16.0.0-175.23.255.255;175.24.0.0-175.27.255.255;175.30.0.0-175.31.255.255;175.42.0.0-175.43.255.255;175.44.0.0-175.44.255.255;175.46.0.0-175.47.255.255;175.48.0.0-175.63.255.255;175.64.0.0-175.95.255.255;175.102.0.0-175.102.255.255;175.106.128.0-175.106.255.255;175.146.0.0-175.147.255.255;175.148.0.0-175.151.255.255;175.152.0.0-175.155.255.255;175.160.0.0-175.175.255.255;175.178.0.0-175.178.255.255;175.184.128.0-175.184.191.255;175.185.0.0-175.185.255.255;175.186.0.0-175.187.255.255;175.188.0.0-175.191.255.255;180.76.0.0-180.76.255.255;180.96.0.0-180.127.255.255;180.136.0.0-180.143.255.255;180.152.0.0-180.159.255.255;180.160.0.0-180.175.255.255;180.208.0.0-180.209.255.255;182.18.0.0-182.18.127.255;182.32.0.0-182.47.255.255;182.88.0.0-182.91.255.255;182.112.0.0-182.127.255.255;182.128.0.0-182.143.255.255;182.240.0.0-182.247.255.255;183.0.0.0-183.63.255.255;183.64.0.0-183.71.255.255;183.128.0.0-183.143.255.255;183.148.0.0-183.148.255.255;183.160.0.0-183.175.255.255;183.184.0.0-183.191.255.255;183.192.0.0-183.223.255.255;192.34.109.224-192.34.109.239;192.74.224.0-192.74.255.255;198.2.203.64-198.2.203.79;198.2.212.160-198.2.212.175;198.15.171.64-198.15.171.127;202.43.144.0-202.43.147.255;202.46.32.0-202.46.63.255;202.66.0.0-202.66.255.255;202.75.208.0-202.75.223.255;202.96.0.0-202.111.255.255;202.111.160.0-202.111.191.255;202.112.0.0-202.115.255.255;202.117.0.0-202.117.255.255;202.165.176.0-202.165.191.255;202.196.80.0-202.196.95.255;203.69.0.0-203.69.255.255;203.86.0.0-203.86.63.255;203.86.64.0-203.86.95.255;203.93.0.0-203.93.255.255;203.169.160.0-203.169.191.255;203.171.224.0-203.171.239.255;203.195.160.0-203.195.161.255;210.5.0.0-210.5.31.255;210.14.128.0-210.14.159.255;210.21.0.0-210.21.255.255;210.32.0.0-210.35.255.255;210.51.0.0-210.51.255.255;210.52.0.0-210.53.255.255;210.77.0.0-210.77.255.255;210.192.96.0-210.192.127.255;211.76.96.0-211.76.111.255;211.78.208.0-211.78.223.255;211.86.144.0-211.86.159.255;211.90.0.0-211.91.255.255;211.92.0.0-211.95.255.255;211.96.0.0-211.103.255.255;211.136.0.0-211.143.255.255;211.144.12.0-211.144.15.255;211.144.96.0-211.144.127.255;211.144.160.0-211.144.175.255;211.147.0.0-211.147.255.255;211.150.0.0-211.151.255.255;211.152.0.0-211.155.255.255;211.157.32.0-211.157.63.255;211.160.0.0-211.167.255.255;211.233.70.0-211.233.70.255;218.0.0.0-218.31.255.255;218.56.0.0-218.63.255.255;218.64.0.0-218.95.255.255;218.84.0.0-218.87.255.255;218.88.0.0-218.95.255.255;218.96.0.0-218.99.255.255;218.102.0.0-218.102.255.255;218.104.0.0-218.107.255.255;218.108.0.0-218.109.255.255;218.194.80.0-218.194.95.255;218.200.0.0-218.207.255.255;218.240.0.0-218.247.255.255;219.128.0.0-219.159.255.255;219.154.0.0-219.155.255.255;219.223.192.0-219.223.255.255;219.232.0.0-219.232.255.255;219.234.80.0-219.234.95.255;219.235.0.0-219.235.255.255;220.112.0.0-220.112.255.255;220.154.0.0-220.155.255.255;220.160.0.0-220.191.255.255;220.181.0.0-220.181.255.255;220.191.0.0-220.191.255.255;220.192.0.0-220.207.255.255;220.228.70.0-220.228.70.255;220.242.0.0-220.243.255.255;220.248.0.0-220.251.255.255;220.250.0.0-220.250.31.255;220.252.0.0-220.252.255.255;221.0.0.0-221.15.255.255;221.122.0.0-221.123.255.255;221.172.0.0-221.175.255.255;221.176.0.0-221.183.255.255;221.192.0.0-221.195.255.255;221.200.0.0-221.203.255.255;221.204.0.0-221.205.255.255;221.206.0.0-221.206.255.255;221.207.0.0-221.207.255.255;221.208.0.0-221.223.255.255;221.212.0.0-221.213.255.255;221.214.0.0-221.215.255.255;221.216.0.0-221.223.255.255;221.224.0.0-221.231.255.255;221.228.0.0-221.231.255.255;221.232.0.0-221.239.255.255;222.32.0.0-222.63.255.255;222.64.0.0-222.79.255.255;222.80.0.0-222.95.255.255;222.132.0.0-222.135.255.255;222.136.0.0-222.143.255.255;222.160.0.0-222.163.255.255;222.168.0.0-222.175.255.255;222.172.222.0-222.172.222.255;222.176.0.0-222.183.255.255;222.184.0.0-222.191.255.255;222.200.0.0-222.200.255.255;222.208.0.0-222.215.255.255;222.219.0.0-222.219.255.255;222.220.0.0-222.221.255.255;222.240.0.0-222.247.255.255;223.4.0.0-223.7.255.255;223.64.0.0-223.95.255.255;223.144.0.0-223.159.255.255;223.240.0.0-223.247.255.255
"""
if __name__ == "__main__":
r = []
for cidr in re.findall("[0-9\.]+/\d+", china_ip):
r.append("-".join(cidr_to_ip_range(cidr)))
print ";".join(r)
raw_input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment