Browse Source

fixed timestamp

pull/3/head
rscmbbng 11 years ago
parent
commit
168a6f27c5
  1. 12
      main.py
  2. 9
      web/index.py

12
main.py

@ -357,6 +357,11 @@ class bc(object):
line = line.split() line = line.split()
for ip in line: for ip in line:
if re.match(r'\d{1,4}\.\dms$', ip):
self.timestamp = ip.replace('ms', '')
print self.timestamp
print ('*'*45)
if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip): if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip):
self.hop_ip = ip self.hop_ip = ip
record = self.geoip.record_by_addr(ip) record = self.geoip.record_by_addr(ip)
@ -381,14 +386,14 @@ class bc(object):
if record.has_key('country_name') and record['city'] is not '': if record.has_key('country_name') and record['city'] is not '':
country = record['country_name'] country = record['country_name']
city = record['city'] city = record['city']
print "Trace:", self.hop_count, "->", ip, "->", longitude + ":" + latitude, "->", city, "->", country, "->", self.hop_host_name, "->", self.asn print "Trace:", self.hop_count, "->", ip, "->", longitude + ":" + latitude, "->", city, "->", country, "->", self.hop_host_name, "->", self.asn, '->', self.timestamp+'ms'
#self.hop_count +=1 #self.hop_count +=1
self.city = city self.city = city
self.country = country self.country = country
self.server_name = self.hop_host_name self.server_name = self.hop_host_name
elif record.has_key('country_name'): elif record.has_key('country_name'):
country = record['country_name'] country = record['country_name']
print "Trace:", self.hop_count, "->", ip, "->", longitude + ":" + latitude, "->", country, "->", self.hop_host_name, "->", self.asn print "Trace:", self.hop_count, "->", ip, "->", longitude + ":" + latitude, "->", country, "->", self.hop_host_name, "->", self.asn, '->', self.timestamp+'ms'
self.country = country self.country = country
self.city = '-' self.city = '-'
self.server_name = self.hop_host_name self.server_name = self.hop_host_name
@ -404,8 +409,7 @@ class bc(object):
xml_results = xml_reporting(self) xml_results = xml_reporting(self)
xml_results.print_xml_results('data.xml') xml_results.print_xml_results('data.xml')
if re.match(r'\d{1,2}\.\dms$', ip):
self.timestamp = ip.replace('ms', '')
if self.options.debug == True: if self.options.debug == True:
logfile.close() logfile.close()

9
web/index.py

@ -22,6 +22,7 @@ geoarray = []
latlong= [] latlong= []
asn_list =[] asn_list =[]
server_name_list = [] server_name_list = []
timestamp_list = []
last_hop = int(xml.findall('hop')[-1].text) last_hop = int(xml.findall('hop')[-1].text)
for counter in range(1, last_hop+1): for counter in range(1, last_hop+1):
@ -33,6 +34,7 @@ for counter in range(1, last_hop+1):
hop_ip = hop_element.getElementsByTagName('hop_ip')[0].toxml().replace('<hop_ip>','').replace('</hop_ip>','') hop_ip = hop_element.getElementsByTagName('hop_ip')[0].toxml().replace('<hop_ip>','').replace('</hop_ip>','')
longitude = hop_element.getElementsByTagName('longitude')[0].toxml().replace('<longitude>','').replace('</longitude>','') longitude = hop_element.getElementsByTagName('longitude')[0].toxml().replace('<longitude>','').replace('</longitude>','')
latitude = hop_element.getElementsByTagName('latitude')[0].toxml().replace('<latitude>','').replace('</latitude>','') latitude = hop_element.getElementsByTagName('latitude')[0].toxml().replace('<latitude>','').replace('</latitude>','')
timestamp = hop_element.getElementsByTagName('timestamp')[0].toxml().replace('<timestamp>','').replace('</timestamp>','')
latlong = [float(latitude.encode('utf-8')), float(longitude.encode('utf-8'))] latlong = [float(latitude.encode('utf-8')), float(longitude.encode('utf-8'))]
geoarray.append(latlong) geoarray.append(latlong)
@ -40,6 +42,7 @@ for counter in range(1, last_hop+1):
hop_list.append(str(hop)) hop_list.append(str(hop))
hop_ip_list.append(hop_ip.encode('utf-8')) hop_ip_list.append(hop_ip.encode('utf-8'))
server_name_list.append(server_name.encode('utf-8')) server_name_list.append(server_name.encode('utf-8'))
timestamp_list.append(float(timestamp))
f = open('kaart.html', 'w') f = open('kaart.html', 'w')
@ -101,6 +104,7 @@ output = """
var latlong = """+str(geoarray)+""" var latlong = """+str(geoarray)+"""
var asn_list = """+str(asn_list)+""" var asn_list = """+str(asn_list)+"""
server_name_list = """+str(server_name_list)+""" server_name_list = """+str(server_name_list)+"""
timestamp_list = """+str(timestamp_list)+"""
//var polyline = L.polyline(latlong, {color: 'red'}).addTo(map); //var polyline = L.polyline(latlong, {color: 'red'}).addTo(map);
index = 0 index = 0
@ -136,6 +140,11 @@ function processStep (index) {
AddStep(latlong[index], latlong[index], index) AddStep(latlong[index], latlong[index], index)
}, 500);} }, 500);}
else
if (index = counter_max-1){
console.log('fin')
}
index = index + 1 index = index + 1
} }
}; };

Loading…
Cancel
Save