mirror of
https://github.com/rscmbbng/Border-Check.git
synced 2024-12-25 21:41:28 +01:00
corrected some errors, xml functionality is still faulty
This commit is contained in:
parent
2954627fba
commit
f2aa3bfc30
22
main.py
22
main.py
@ -41,7 +41,7 @@ class bc(object):
|
|||||||
self.url = ""
|
self.url = ""
|
||||||
self.old_url = ""
|
self.old_url = ""
|
||||||
self.ip = ""
|
self.ip = ""
|
||||||
self.host_name =""
|
self.hop_host_name =""
|
||||||
self.city = ""
|
self.city = ""
|
||||||
self.country = ""
|
self.country = ""
|
||||||
self.routes = ""
|
self.routes = ""
|
||||||
@ -270,20 +270,24 @@ class bc(object):
|
|||||||
for ip in parts:
|
for ip in parts:
|
||||||
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):
|
||||||
record = self.geoip.record_by_addr(ip)
|
record = self.geoip.record_by_addr(ip)
|
||||||
self.host_name = socket.gethostbyaddr(ip)[0]
|
|
||||||
#print record
|
#print record
|
||||||
|
try:
|
||||||
|
self.hop_host_name = socket.gethostbyaddr(ip)[0]
|
||||||
|
except:
|
||||||
|
self.hop_host_name = 'No hostname'
|
||||||
try:
|
try:
|
||||||
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:", count, "->", ip, "->", city, "->", country
|
|
||||||
|
print "Trace:", count, "->", ip, "->", city, "->", country, "->", self.hop_host_name
|
||||||
count+=1
|
count+=1
|
||||||
self.city = city
|
self.city = city
|
||||||
self.country = country
|
self.country = country
|
||||||
self.routes = "Trace:", count, "->", ip, "->", city, "->", country
|
self.routes = "Trace:", count, "->", ip, "->", city, "->", country
|
||||||
elif record.has_key('country_name'):
|
elif record.has_key('country_name'):
|
||||||
country = record['country_name']
|
country = record['country_name']
|
||||||
print "Trace:", count, "->", ip, "->", country
|
print "Trace:", count, "->", ip, "->", country, "->", self.hop_host_name
|
||||||
self.country = country
|
self.country = country
|
||||||
self.routes = "Trace:", count, "->", ip, "->", country
|
self.routes = "Trace:", count, "->", ip, "->", country
|
||||||
count+=1
|
count+=1
|
||||||
@ -368,7 +372,10 @@ class bc(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
|
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 '='*45 + "\n"
|
||||||
print "Status: Waiting for new urls ...\n"
|
print "Status: Waiting for new urls ...\n"
|
||||||
# stay latent waiting for new urls
|
# stay latent waiting for new urls
|
||||||
@ -381,8 +388,9 @@ class bc(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
|
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
|
||||||
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 __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = bc()
|
app = bc()
|
||||||
|
6
webserver.py
Normal file → Executable file
6
webserver.py
Normal file → Executable file
@ -12,6 +12,7 @@ from runpy import run_module
|
|||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
from cgi import parse_qs #, parse_header, parse_multipart
|
from cgi import parse_qs #, parse_header, parse_multipart
|
||||||
import cgi
|
import cgi
|
||||||
|
from options import BCOptions
|
||||||
|
|
||||||
port = 8080
|
port = 8080
|
||||||
wwwroot = "web/"
|
wwwroot = "web/"
|
||||||
@ -69,8 +70,9 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||||||
content = query.get('upfile')
|
content = query.get('upfile')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# only for debug mode
|
# print interactions w server
|
||||||
#print "Request from %s:%d"%self.client_address + " " + uri
|
# if self.options.debug == True:
|
||||||
|
# print "Request from %s:%d"%self.client_address + " " + uri
|
||||||
if uri[-1] == '/' or os.path.isdir(file):
|
if uri[-1] == '/' or os.path.isdir(file):
|
||||||
file = file + "/index.py"
|
file = file + "/index.py"
|
||||||
if os.path.isfile(file + ".py"):
|
if os.path.isfile(file + ".py"):
|
||||||
|
Loading…
Reference in New Issue
Block a user