[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torouter/master] Merge branch 'master' of ssh://git-rw.torproject.org/torouter



commit 57e54f969b840546925d16ceceb130a0f3927140
Merge: 7026005 525766e
Author: Jacob Appelbaum <jacob@xxxxxxxxxxxxx>
Date:   Wed Aug 17 19:31:22 2011 +0200

    Merge branch 'master' of ssh://git-rw.torproject.org/torouter

 packages/torouter-web/src/config.py                |    1 +
 packages/torouter-web/src/runui.py                 |    2 +-
 packages/torouter-web/src/static/main.css          |   14 +++++++++++++
 packages/torouter-web/src/tui/controllers/tor.py   |   14 +++++++++---
 packages/torouter-web/src/tui/utils/parsing.py     |   21 ++++++++++++++++++++
 packages/torouter-web/src/tui/views/torstatus.html |    4 ++-
 6 files changed, 50 insertions(+), 6 deletions(-)

diff --cc packages/torouter-web/src/config.py
index 8fd716d,0000000..15057df
mode 100644,000000..100644
--- a/packages/torouter-web/src/config.py
+++ b/packages/torouter-web/src/config.py
@@@ -1,15 -1,0 +1,16 @@@
 +# tui, Tor web UI
 +# by Arturo Filasto' <hellais@xxxxxxxxxxxxxx>
 +#
 +
 +import web, os
 +
 +cache = False
 +
 +globals = {}
 +
 +# Add your own (username, password) pair
 +authinfo = ("test", "test")
 +
 +interfaces_file = os.getcwd() + "/../torouter-prep/configs/interfaces"
++torrc_file = os.getcwd() + "/../torouter-prep/configs/torrc"
 +
diff --cc packages/torouter-web/src/runui.py
index 3d2dfc8,0000000..80836b3
mode 100644,000000..100644
--- a/packages/torouter-web/src/runui.py
+++ b/packages/torouter-web/src/runui.py
@@@ -1,35 -1,0 +1,35 @@@
 +# tui - Tor web UI
 +# by Arturo Filasto' <hellais@xxxxxxxxxxxxxx>
 +#
 +
 +import web
 +import config
 +import tui.controllers
 +
 +from tui.utils import session
 +from view import render
 +
 +
 +# This is the main structure of URLs
 +urls = (
 +    '/', 'tui.controllers.main.index',
 +#    '/config/(tor|router)', 'tui.controllers.main.config',
 +    '/network', 'tui.controllers.network.main',
 +    '/network/firewall', 'tui.controllers.network.firewall',
 +    '/network/wireless', 'tui.controllers.network.wireless',
 +    '/network/wired', 'tui.controllers.network.wired',
 +    '/network/status', 'tui.controllers.network.status',
 +    '/tor', 'tui.controllers.tor.status',
-     '/tor/config', 'tui.controllers.tor.config',
++    '/tor/config', 'tui.controllers.tor.torrc',
 +    '/logout', 'tui.controllers.main.logout'
 +    )
 +#    '/wizard/([0-9a-f]{1,2})?', 'tui.controllers.wizard.step',
 +#    '/status', 'tui.controllers.status')
 +
 +if __name__ == "__main__":
 +  app = web.application(urls, globals())
 +  # Add session management to the app
 +  session.add_session_to_app(app)
 +  app.internalerror = web.debugerror
 +  app.run()
 +
diff --cc packages/torouter-web/src/static/main.css
index 5626e92,0000000..34e26cf
mode 100644,000000..100644
--- a/packages/torouter-web/src/static/main.css
+++ b/packages/torouter-web/src/static/main.css
@@@ -1,37 -1,0 +1,51 @@@
 +
 +/* Clear all */
 +body { margin: 0;border: 0;padding: 0; }
 +
 +div.wrapper {
 +  min-height: 300px;
 +  width: 800px;
 +  margin: 0 auto;
 +}
 +
 +div.footer {
 +  text-align: center;
 +  background-color: #333;
 +  color: white;
 +  padding-top: 20px;
 +  padding-bottom: 20px;
 +}
 +
 +div.header {
 +  color: white;
 +}
 +
 +div.header ul {
 +  list-style: none;
 +  height: 20px;
 +}
 +
 +div.header ul li {
 +  font-size: 20px;
 +  float: left;
 +  padding: 5px 10px;
 +}
 +
 +div.header ul#submenu li {
 +  font-size: 15px;
 +}
 +
++/* More specific stuff */
++#torrc {
++list-style: none;
++line-height: 2em;
++}
++
++#torrc em {
++font-weight: bold;
++font-style: normal;
++}
++
++
++
++
diff --cc packages/torouter-web/src/tui/controllers/tor.py
index d07cb71,0000000..af8678c
mode 100644,000000..100644
--- a/packages/torouter-web/src/tui/controllers/tor.py
+++ b/packages/torouter-web/src/tui/controllers/tor.py
@@@ -1,29 -1,0 +1,35 @@@
 +import web
 +import view, config
 +from view import render
- from tui.utils import session
++from tui.utils import session, parsing
 +
 +"""
 +The main Tor status page
 +"""
 +class status:
 +  def GET(self):
-     return render.base(render.torstatus())
++    trc = parsing.torrc(config.torrc_file)
++    trc.parse()
++    output = trc.html_output()
++    return render.base(render.torstatus(output,config.torrc_file))
 +
 +  def POST(self):
-     return render.base(render.torstatus())
++    trc = parsing.torrc(config.torrc_file)
++    trc.parse()
++    output = trc.html_output()
++    return render.base(render.torstatus(output,config.torrc_file))
 +
 +"""
 +Tor configuration page
 +"""
- class config:
++class torrc:
 +  def update_config(self, data):
 +    return True
 +
 +  def GET(self):
 +    return render.base(render.torconfig())
 +
 +  def POST(self):
 +    self.update_config(web.input())
 +    return render.base(render.torconfig())
 +
diff --cc packages/torouter-web/src/tui/utils/parsing.py
index e9ccc83,0000000..6acf988
mode 100644,000000..100644
--- a/packages/torouter-web/src/tui/utils/parsing.py
+++ b/packages/torouter-web/src/tui/utils/parsing.py
@@@ -1,83 -1,0 +1,104 @@@
 +# These functions are for parsing /etc/network/interface
 +# files, they will be used inside torouter to visualize
 +# and edit configuration
 +import os
 +
 +class interfaces:
 +  def __init__(self,filename):
 +    self.fp = open(filename, "r")
 +    self.wifi = {}
 +    self.eth1 = {}
 +    self.eth0 = {}
 + 
 +  def parse_line(self, line, iface):
 +    name   = line.split(" ")[0]
 +    values = " ".join(line.split(" ")[1:]).rstrip()
 +    if iface == "uap0":
 +      if self.wifi.has_key(name):
 +        if type(self.wifi[name]) is list:
 +          self.wifi[name].append(values)
 +        else:
 +          self.wifi[name] = [self.wifi[name],values]
 +      else:
 +        self.wifi.update({name : values})
 +    elif iface == "eth1":
 +      if self.eth1.has_key(name):
 +        if type(self.eth1[name]) is list:
 +          self.eth1[name].append(values)
 +        else:
 +          self.eth1[name] = [self.eth1[name],values]
 +      else:
 +        self.eth1.update({name : values})
 +    elif iface == "eth0":
 +      if self.eth0.has_key(name):
 +        if type(self.eth0[name]) is list:
 +          self.eth0[name].append(values)
 +        else:
 +          self.eth0[name] = [self.eth0[name],values]
 +      else:
 +        self.eth0.update({name : values})
 +  
 +  def parse(self):
 +    iface = None
 +    for line in self.fp.readlines():
 +      line = line.lstrip()
 +      if line.startswith("#") or line == "":
 +        continue
 +      if line.startswith("iface"):
 +        iface = line.split(" ")[1]
 +      if iface:
 +        self.parse_line(line, iface)
 +
 +  def html_output(self, data):
 +    output = "<h3>Interface %s</h3>\n" % data['iface'].split(" ")[0]
 +    output += "<table class=\"interface\" id=\"%s\">\n" % data['iface'].split(" ")[0]
 +    
 +    for item in data.items():
 +      if item[0] != "iface":
 +        if type(item[1]) is list:
 +          for i in item[1]:
 +            output += "<tr><td>%s</td><td>%s</td></tr>\n" % (item[0], i)
 +        else:
 +          output += "<tr><td>%s</td><td>%s</td></tr>\n" % (item[0],item[1])
 +    output += "</table>"
 +    print output
 +    return output 
 +
 +  def output(self, data):
 +    print "iface %s" % data['iface']
 +    for item in data.items():
 +      if item[0] != "iface":
 +        if type(item[1]) is list:
 +          for i in item[1]:
 +            print "%s %s" % (item[0], i)
 +        else:
 +          print "%s %s" % (item[0],item[1])
 +
++class torrc:
++  def __init__(self,filename):
++    self.fp = open(filename, "r")
++    self.parsed = []
++
++  def parse(self):
++    for line in self.fp.readlines():
++      if line.startswith("#") or line == "":
++        continue
++      else:
++        self.parsed.append(line)
++
++  def html_output(self):
++    output = "<ul id=\"torrc\">"
++    for line in self.parsed:
++      if line != "\n":
++        output += "<li><em>%s</em> %s</li>" % (line.split(" ")[0], " ".join(line.split(" ")[1:]))
++    output += "</ul>"
++    print output
++    return output
++
 +#interfaces_file = os.getcwd() + "/../../../torouter-prep/configs/interfaces"
 +#itfc = interfaces(interfaces_file)
 +#itfc.parse()
 +#itfc.html_output(itfc.wifi)
 +#itfc.html_output(itfc.eth1)
 +#itfc.html_output(itfc.eth0)
 +  
diff --cc packages/torouter-web/src/tui/views/torstatus.html
index ed83531,0000000..27b2888
mode 100644,000000..100644
--- a/packages/torouter-web/src/tui/views/torstatus.html
+++ b/packages/torouter-web/src/tui/views/torstatus.html
@@@ -1,1 -1,0 +1,3 @@@
- The main Tor status page
++$def with (content, torrc)
++<h2>This is the content of $:torrc</h2>
++$:content

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits