Browse Source

corrected some errors, xml functionality is still faulty

pull/3/head
rscmbbng 11 years ago
parent
commit
f2aa3bfc30
  1. 22
      main.py
  2. 6
      webserver.py

22
main.py

@ -41,7 +41,7 @@ class bc(object):
self.url = ""
self.old_url = ""
self.ip = ""
self.host_name =""
self.hop_host_name =""
self.city = ""
self.country = ""
self.routes = ""
@ -270,20 +270,24 @@ class bc(object):
for ip in parts:
if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",ip):
record = self.geoip.record_by_addr(ip)
self.host_name = socket.gethostbyaddr(ip)[0]
#print record
try:
self.hop_host_name = socket.gethostbyaddr(ip)[0]
except:
self.hop_host_name = 'No hostname'
try:
if record.has_key('country_name') and record['city'] is not '':
country = record['country_name']
city = record['city']
print "Trace:", count, "->", ip, "->", city, "->", country
print "Trace:", count, "->", ip, "->", city, "->", country, "->", self.hop_host_name
count+=1
self.city = city
self.country = country
self.routes = "Trace:", count, "->", ip, "->", city, "->", country
elif record.has_key('country_name'):
country = record['country_name']
print "Trace:", count, "->", ip, "->", country
print "Trace:", count, "->", ip, "->", country, "->", self.hop_host_name
self.country = country
self.routes = "Trace:", count, "->", ip, "->", country
count+=1
@ -368,7 +372,10 @@ class bc(object):
pass
else:
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
# export data to XML
#xml_results = xml_reporting(self)
#xml_results.print_xml_results('data.xml')
# export data to XML
print '='*45 + "\n"
print "Status: Waiting for new urls ...\n"
# stay latent waiting for new urls
@ -381,8 +388,9 @@ class bc(object):
pass
else:
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
xml_results = xml_reporting(self)
xml_results.print_xml_results('data.xml')
#xml_results = xml_reporting(self)
#xml_results.print_xml_results('data.xml')
if __name__ == "__main__":
app = bc()

6
webserver.py

@ -12,6 +12,7 @@ from runpy import run_module
from urlparse import urlparse
from cgi import parse_qs #, parse_header, parse_multipart
import cgi
from options import BCOptions
port = 8080
wwwroot = "web/"
@ -69,8 +70,9 @@ class HttpHandler(BaseHTTPRequestHandler):
content = query.get('upfile')
except:
pass
# only for debug mode
#print "Request from %s:%d"%self.client_address + " " + uri
# print interactions w server
# if self.options.debug == True:
# print "Request from %s:%d"%self.client_address + " " + uri
if uri[-1] == '/' or os.path.isdir(file):
file = file + "/index.py"
if os.path.isfile(file + ".py"):

Loading…
Cancel
Save