@@ -28,7 +28,7 @@ def query(domain, record_type='A',server=None):
28
28
#print "{0} {1}".format(domain,j.to_text())
29
29
tmpcname .append (j .to_text ())
30
30
line = "{0}\t {1}\t {2}" .format (domain .ljust (30 ),", " .join (tmpcname ),", " .join (tmpip ))
31
- if tmpip != None : #only collect IP that don't use CDN (cname)
31
+ if tmpip != None : #only collect IPs that don't use CDN (cname)
32
32
ips .extend (tmpip )
33
33
print line
34
34
return ips ,line
@@ -85,15 +85,15 @@ def iprange(ip_str_list):
85
85
for ip_str in ip_str_list :
86
86
ip = IPNetwork (ip_str )
87
87
ip .prefixlen = 24
88
- if ip .cidr == net :
88
+ if ip .cidr == net :#ip属于net
89
89
tmpIPlist .append (ip_str )
90
90
#print tmpIPlist
91
91
if len (tmpIPlist ) == 1 :
92
92
smaller_subnet .add (tmpIPlist [0 ])
93
93
elif len (tmpIPlist ) >= 2 :
94
94
smaller = netaddr .spanning_cidr (tmpIPlist ) #type is IPNetwork
95
- if smaller != net :
96
- smaller_subnet .add (smaller )
95
+ # if smaller != net:
96
+ smaller_subnet .add (smaller )
97
97
elif len (tmpIPlist ) == 0 :
98
98
print "{0} has no ip" .format (net )
99
99
@@ -102,15 +102,17 @@ def iprange(ip_str_list):
102
102
result .append (str (item ))
103
103
return result
104
104
105
- def smaller_network (ip_str_list ):
106
- x = netaddr .spanning_cidr (['192.168.0.0' , '192.168.2.245' , '192.168.2.255' ])
105
+ def smaller_network ():
106
+ #list = ['192.168.0.0', '192.168.0.245', '192.168.0.255']
107
+ #list = ['192.168.2.245']
108
+ x = netaddr .spanning_cidr (list )
107
109
print x
108
110
109
111
110
112
if __name__ == "__main__" :
111
-
112
-
113
- domains = open ("C:\Users\jax\Desktop\hrpc.txt" ).readlines ()
113
+ domains = open ("C:\Users\jax\Desktop\hrpc (2).txt" ).readlines ()
114
114
115
115
x ,lines = domains2ips (domains ,"172.30.35.35" )
116
- print lines
116
+ #print x
117
+ #print smaller_network()
118
+ print iprange (x )# problem
0 commit comments