diff --git a/main.py b/main.py
index cfe82d6..4edf6a7 100644
--- a/main.py
+++ b/main.py
@@ -20,6 +20,7 @@ except:
import subprocess, socket, threading
from options import BCOptions
from webserver import BorderCheckWebserver
+from xml_exporter import xml_reporting
import webbrowser
# set to emit debug messages about errors (0 = off).
@@ -360,6 +361,9 @@ 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')
print '='*45 + "\n"
print "Status: Waiting for new urls ...\n"
# stay latent waiting for new urls
diff --git a/web/index.py b/web/index.py
index 97c1121..4b04294 100644
--- a/web/index.py
+++ b/web/index.py
@@ -1,12 +1,58 @@
+#!/usr/local/bin/python
+# -*- coding: iso-8859-15 -*-
+"""
+BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes.
+GPLv3 - 2013 by psy (epsylon@riseup.net)
+"""
+from xml.dom.minidom import parseString
+# extract data from a xml file
+file = open('data.xml','r')
+data = file.read()
+file.close()
+dom = parseString(data)
+xmlTag = dom.getElementsByTagName('travel')[0].toxml()
+xmlData= xmlTag.replace('','').replace('','')
+xmlHost = dom.getElementsByTagName('host')[0].toxml()
+xmlIP = dom.getElementsByTagName('ip')[0].toxml()
+xmlRoutes = dom.getElementsByTagName('routes')[0].toxml()
+xmlMeta = dom.getElementsByTagName('meta')[0].toxml()
+
output = """
- Border Check
+ Border Check - Web Visualizator
-
-
-
+
+
+
+ |
+
+
+
+
+
+
+ Host: |
+ """+xmlHost+""" |
+
+
+ IP: |
+ """+xmlIP+""" |
+
+
+ Packages Route: |
+ """+xmlRoutes+""" |
+
+
+ Metadata: |
+ """+xmlMeta+""" |
+
+
+
+ |
+
+
"""
diff --git a/webserver.py b/webserver.py
index 9915c16..5481fc0 100644
--- a/webserver.py
+++ b/webserver.py
@@ -69,7 +69,8 @@ class HttpHandler(BaseHTTPRequestHandler):
content = query.get('upfile')
except:
pass
- print "Request from %s:%d"%self.client_address + " " + uri
+ # only for debug mode
+ #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"):
diff --git a/xml_exporter.py b/xml_exporter.py
new file mode 100644
index 0000000..90da0c6
--- /dev/null
+++ b/xml_exporter.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+# -*- coding: iso-8859-15 -*-
+"""
+BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes.
+GPLv3 - 2013 by psy (epsylon@riseup.net)
+"""
+import xml.etree.ElementTree as ET
+
+class xml_reporting(object):
+ """
+ Print results from a traceroute in an XML fashion
+ """
+ def __init__(self, bc):
+ # initialize main BC
+ self.instance = bc
+
+ def print_xml_results(self, filename):
+ root = ET.Element("travel")
+ host = ET.SubElement(root, "host")
+ ip = ET.SubElement(root, "ip")
+ routes = ET.SubElement(root, "routes")
+ meta = ET.SubElement(root, "meta")
+
+ host.text = self.instance.url[0]
+ ip.text = self.instance.ip
+ routes.text = self.instance.routes
+ meta.text = "Connect here XML metadata"
+
+ tree = ET.ElementTree(root)
+ tree.write(filename)
+