aboutsummaryrefslogtreecommitdiffstats
path: root/packages/torouter-web/tui/controllers
diff options
context:
space:
mode:
authorJacob Appelbaum <jacob@appelbaum.net>2011-08-13 04:39:04 +0200
committerJacob Appelbaum <jacob@appelbaum.net>2011-08-13 04:39:04 +0200
commita56b3841d2adb8c995d6fe4603a7e7751bfa6d78 (patch)
tree75a5c6285f155c4d36154001c3d06b8b5414e6f3 /packages/torouter-web/tui/controllers
parent2196124bf23eb9a9e4b708b2ed098011eb54df2c (diff)
parentf54fe96d36551fc61d746d875365e6722d56afd2 (diff)
downloadtorouter-a56b3841d2adb8c995d6fe4603a7e7751bfa6d78.tar.gz
torouter-a56b3841d2adb8c995d6fe4603a7e7751bfa6d78.zip
Merge branch 'master' of ssh://git-rw.torproject.org/torouter
Diffstat (limited to 'packages/torouter-web/tui/controllers')
-rw-r--r--packages/torouter-web/tui/controllers/network.py56
-rw-r--r--packages/torouter-web/tui/controllers/tor.py4
2 files changed, 26 insertions, 34 deletions
diff --git a/packages/torouter-web/tui/controllers/network.py b/packages/torouter-web/tui/controllers/network.py
index 7022ca4..b5da4e3 100644
--- a/packages/torouter-web/tui/controllers/network.py
+++ b/packages/torouter-web/tui/controllers/network.py
@@ -1,7 +1,7 @@
import web
import view, config
from view import render
-from tui.utils import session
+from tui.utils import session,configuration
"""
This function is used to generate the network
@@ -15,7 +15,7 @@ def menu(n):
else:
a.append("")
print a
- return """<ul>
+ 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>
@@ -28,6 +28,10 @@ def menu(n):
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))
@@ -36,6 +40,7 @@ class main:
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())
@@ -44,14 +49,19 @@ class main:
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.main(),menu(0))
+ return render.base(render.firewall(configuration.get_form("firewall")),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.firewall(),menu(1))
else:
return render.base(render.login())
@@ -62,46 +72,19 @@ class firewall:
Wireless network configuration page
"""
class wireless:
- def get_current_config(self):
- conf = {'essid' : None, 'encryption' : None, 'key' : None}
-
- # XXX Dummy default config for testing purposes
- # plugin here the actual code for config retreival
- conf['essid'] = "Torouter"
- conf['encryption'] = "WPA2"
- conf['key'] = "ljdasjkbcuBH12389Ba"
-
-
- return conf
-
- def build_form(self):
- c = self.get_current_config()
- ret_form = web.form.Form(
- web.form.Textbox(name='essid',
- description='Wireless ESSID', value=c['essid']),
- web.form.Dropdown(name='enctype', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
- description='Wireless encryption scheme', value=c['encryption']),
- web.form.Password(name='key',
- description='key', value=c['key']),
- web.form.Button('save')
- )
- self.form = ret_form
-
- return True
-
+ # XXX do all the backend stuff
def update_config(self, data):
return True
def GET(self):
if session.is_logged() > 0:
- if self.build_form():
- return render.base(render.wireless(self.form()),menu(2))
+ 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(None)
+ self.update_config(web.input())
print web.input()
return render.base(render.saved(web.input()),menu(2))
else:
@@ -111,14 +94,19 @@ class wireless:
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(),menu(3))
+ 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())
diff --git a/packages/torouter-web/tui/controllers/tor.py b/packages/torouter-web/tui/controllers/tor.py
index ca96209..d07cb71 100644
--- a/packages/torouter-web/tui/controllers/tor.py
+++ b/packages/torouter-web/tui/controllers/tor.py
@@ -17,9 +17,13 @@ class status:
Tor configuration page
"""
class config:
+ 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())