[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 e14cf93e2c93e94c00d55d51ffc8ca26e063377c
Merge: 4a55d35 57e54f9
Author: Arturo FilastoÌ? <hellais@xxxxxxxxxxxxxx>
Date: Wed Aug 17 19:38:47 2011 +0200
Merge branch 'master' of ssh://git-rw.torproject.org/torouter
packages/torouter-web/config.py | 16 ---
packages/torouter-web/runui.py | 35 ------
packages/torouter-web/setup.py | 16 +++
packages/torouter-web/src/config.py | 16 +++
packages/torouter-web/src/runui.py | 35 ++++++
packages/torouter-web/src/static/main.css | 56 +++++++++
packages/torouter-web/src/tui/controllers/main.py | 26 ++++
.../torouter-web/src/tui/controllers/network.py | 129 ++++++++++++++++++++
.../torouter-web/src/tui/controllers/old/main.py | 11 ++
.../torouter-web/src/tui/controllers/old/status.py | 9 ++
.../torouter-web/src/tui/controllers/old/wizard.py | 81 ++++++++++++
packages/torouter-web/src/tui/controllers/tor.py | 35 ++++++
.../torouter-web/src/tui/models/router_config.py | 19 +++
.../torouter-web/src/tui/utils/configuration.py | 85 +++++++++++++
packages/torouter-web/src/tui/utils/parsing.py | 105 ++++++++++++++++
packages/torouter-web/src/tui/utils/session.py | 26 ++++
packages/torouter-web/src/tui/views/base.html | 30 +++++
packages/torouter-web/src/tui/views/firewall.html | 7 +
packages/torouter-web/src/tui/views/index.html | 1 +
packages/torouter-web/src/tui/views/login.html | 7 +
packages/torouter-web/src/tui/views/logout.html | 1 +
packages/torouter-web/src/tui/views/main.html | 1 +
packages/torouter-web/src/tui/views/saved.html | 8 ++
packages/torouter-web/src/tui/views/status.html | 3 +
packages/torouter-web/src/tui/views/torconfig.html | 1 +
packages/torouter-web/src/tui/views/torstatus.html | 3 +
packages/torouter-web/src/tui/views/wired.html | 7 +
packages/torouter-web/src/tui/views/wireless.html | 8 ++
packages/torouter-web/src/tui/views/wizard.html | 12 ++
packages/torouter-web/src/view.py | 11 ++
packages/torouter-web/static/main.css | 56 ---------
packages/torouter-web/tui/controllers/main.py | 26 ----
packages/torouter-web/tui/controllers/network.py | 129 --------------------
packages/torouter-web/tui/controllers/old/main.py | 11 --
.../torouter-web/tui/controllers/old/status.py | 9 --
.../torouter-web/tui/controllers/old/wizard.py | 81 ------------
packages/torouter-web/tui/controllers/tor.py | 35 ------
packages/torouter-web/tui/models/router_config.py | 19 ---
packages/torouter-web/tui/utils/configuration.py | 85 -------------
packages/torouter-web/tui/utils/parsing.py | 105 ----------------
packages/torouter-web/tui/utils/session.py | 26 ----
packages/torouter-web/tui/views/base.html | 30 -----
packages/torouter-web/tui/views/firewall.html | 7 -
packages/torouter-web/tui/views/index.html | 1 -
packages/torouter-web/tui/views/login.html | 7 -
packages/torouter-web/tui/views/logout.html | 1 -
packages/torouter-web/tui/views/main.html | 1 -
packages/torouter-web/tui/views/saved.html | 8 --
packages/torouter-web/tui/views/status.html | 3 -
packages/torouter-web/tui/views/torconfig.html | 1 -
packages/torouter-web/tui/views/torstatus.html | 3 -
packages/torouter-web/tui/views/wired.html | 7 -
packages/torouter-web/tui/views/wireless.html | 8 --
packages/torouter-web/tui/views/wizard.html | 12 --
packages/torouter-web/view.py | 11 --
55 files changed, 749 insertions(+), 733 deletions(-)
diff --cc packages/torouter-web/src/static/main.css
index 0000000,34e26cf..7277912
mode 000000,100644..100644
--- a/packages/torouter-web/src/static/main.css
+++ b/packages/torouter-web/src/static/main.css
@@@ -1,0 -1,51 +1,56 @@@
+
+ /* 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;
+ }
+
++div.header ul#submenu li a.sel {
++ color: black;
++ text-decoration: none;
++}
++
+ /* 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/network.py
index 0000000,d189d0c..cc46643
mode 000000,100644..100644
--- a/packages/torouter-web/src/tui/controllers/network.py
+++ b/packages/torouter-web/src/tui/controllers/network.py
@@@ -1,0 -1,129 +1,129 @@@
+ import web
+ import view, config
+ from view import render
+ from tui.utils import session,configuration,parsing
+
+ """
+ This function is used to generate the network
+ submenus.
+ """
+ def menu(n):
+ a = []
+ for i in range(0,5):
+ if i == n:
+ a.append("sel")
+ else:
+ a.append("")
+ print a
+ return """<ul id="submenu">
+ <li><a href="/network" class="%s">Main</a></li>
+ <li><a href="/network/firewall" class="%s">Firewall</a></li>
+ <li><a href="/network/wireless" class="%s">Wireless</a></li>
+ <li><a href="/network/wired" class="%s">Wired</a></li>
+ <li><a href="/network/status" class="%s">Status</a></li>
+ </ul>
+ """ % tuple(a)
+
+ """
+ The main page for network configuration
+ """
+ class main:
+ # XXX do all the backend stuff
+ def update_config(self, data):
+ return True
+
+ def GET(self):
+ if session.is_logged() > 0:
+ return render.base(render.main(),menu(0))
+ else:
+ return render.base(render.login())
+
+ def POST(self):
+ if session.is_logged() > 0:
+ self.update_config(web.input())
+ return render.base(render.main(),menu(0))
+ else:
+ return render.base(render.login())
+
+ """
+ The firewall configuration page
+ """
+ class firewall:
+ # XXX do all the backend stuff
+ def update_config(self, data):
+ return True
+
+ def GET(self):
+ if session.is_logged() > 0:
- return render.base(render.firewall(configuration.get_form("firewall")),menu(0))
++ return render.base(render.firewall(configuration.get_form("firewall")),menu(1))
+ else:
+ return render.base(render.login())
+
+ def POST(self):
+ if session.is_logged() > 0:
+ self.update_config(web.input())
- return render.base(render.firewall(),menu(1))
++ return render.base(render.firewall(configuration.get_form("firewall")),menu(1))
+ else:
+ return render.base(render.login())
+
+
+
+ """
+ Wireless network configuration page
+ """
+ class wireless:
+ # XXX do all the backend stuff
+ def update_config(self, data):
+ return True
+
+ def GET(self):
+ if session.is_logged() > 0:
+ return render.base(render.wireless(configuration.get_form("wireless")),menu(2))
+ else:
+ return render.base(render.login())
+
+ def POST(self):
+ if session.is_logged() > 0:
+ self.update_config(web.input())
+ print web.input()
+ return render.base(render.saved(web.input()),menu(2))
+ else:
+ return render.base(render.login())
+
+ """
+ Wired network configuration page
+ """
+ class wired:
+ # XXX do all the backend stuff
+ def update_config(self, data):
+ return True
+
+ def GET(self):
+ if session.is_logged() > 0:
+ return render.base(render.wired(configuration.get_form("wired")),menu(3))
+ else:
+ return render.base(render.login())
+
+ def POST(self):
+ if session.is_logged() > 0:
+ self.update_config(web.input())
+ return render.base(render.wired(),menu(3))
+ else:
+ return render.base(render.login())
+
+ """
+ General status page, displays a bit more detail than main
+ """
+ class status:
+ def GET(self):
+ itfc = parsing.interfaces(config.interfaces_file)
+ itfc.parse()
+ network = itfc.html_output(itfc.wifi) + itfc.html_output(itfc.eth0) + itfc.html_output(itfc.eth1)
+ return render.base(render.status(network),menu(4))
+
+ def POST(self):
+ itfc = parsing.interfaces(config.interfaces_file)
+ itfc.parse()
+ network = itfc.html_output(itfc.wifi) + itfc.html_output(itfc.eth0) + itfc.html_output(itfc.eth1)
+ return render.base(render.status(),menu(4))
+
diff --cc packages/torouter-web/src/tui/utils/parsing.py
index 0000000,6acf988..beb45d3
mode 000000,100644..100644
--- a/packages/torouter-web/src/tui/utils/parsing.py
+++ b/packages/torouter-web/src/tui/utils/parsing.py
@@@ -1,0 -1,104 +1,105 @@@
+ # 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():
++ line = line.lstrip()
+ 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)
+
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits