@@ -19,15 +19,13 @@ def ip2long(ip):
1919 return int (hexn , 16 )
2020
2121
22- def long2ip (n ):
22+ def long2ip (num ):
2323 "convert long int to dotted quad string"
24- d = 256 * 256 * 256
25- q = []
26- while d > 0 :
27- m , n = divmod (n , d )
28- q .append (str (m ))
29- d = d / 256
30- return '.' .join (q )
24+ iplist = []
25+ for n in range (4 ):
26+ num ,mod = divmod (num ,256 )
27+ iplist .insert (0 ,str (mod ))
28+ return '.' .join (iplist )
3129
3230
3331class IPPool (object ):
@@ -103,7 +101,7 @@ def LoadRecord(self):
103101 continue
104102 p = None
105103 # p = re.match(ur"(.*),(.*),(.*),(.*)", router)
106- p = str ( router . encode ( 'utf-8' )) .strip ().split (',' )
104+ p = router .strip ().split (',' )
107105 if p is None :
108106 logger .warning (
109107 "maybe record file format error: %s" % self .recordfile )
@@ -133,6 +131,7 @@ def LoadRecord(self):
133131 elif match [3 ] not in self .locmapip [fqdn ][match [0 ]][match [1 ]][match [2 ]]:
134132 self .locmapip [fqdn ][match [0 ]][match [1 ]][match [2 ]][match [3 ]] = \
135133 [self .record [fqdn ][router ], weight ]
134+ print (self .locmapip )
136135 f .close ()
137136 # logger.warning(self.locmapip)
138137
@@ -203,6 +202,8 @@ def FindIP(self, ip, name):
203202 if not re .search (r'[^0-9.]' , tmp_ip ) and self .monitor_mapping .check (name , tmp_ip )]
204203 logger .info ("userip:[%s] domain:[%s] section:[%s-%s] location:[%s,%s,%s,%s] ip_list:%s" % (
205204 ip , name , long2ip (ipstart ), long2ip (ipend ), country , province , city , sp , ip_list ))
205+ print (self .iphash [i ])
206+ print (name , ipnum , ip , long2ip (ipstart ), long2ip (ipend ),country , province , city , sp , ip_list )
206207 if not ip_list or len (ip_list ) == 0 :
207208 # maybe something wrong
208209 tmp_ip_list = [
0 commit comments