[tor-commits] [torouter/master] Add support for displaying content of torrc file
hellais at torproject.org
hellais at torproject.org
Wed Aug 17 16:17:16 UTC 2011
commit d435505bea5b9d735447f4900d7e502cae11412f
Author: Arturo FilastoÌ <hellais at torproject.org>
Date: Wed Aug 17 18:16:22 2011 +0200
Add support for displaying content of torrc file
---
packages/torouter-web/config.py | 1 +
packages/torouter-web/runui.py | 2 +-
packages/torouter-web/static/main.css | 14 ++++++++++++++
packages/torouter-web/tui/controllers/tor.py | 14 ++++++++++----
packages/torouter-web/tui/utils/parsing.py | 21 +++++++++++++++++++++
packages/torouter-web/tui/views/torstatus.html | 4 +++-
6 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/packages/torouter-web/config.py b/packages/torouter-web/config.py
index 8fd716d..15057df 100644
--- a/packages/torouter-web/config.py
+++ b/packages/torouter-web/config.py
@@ -12,4 +12,5 @@ globals = {}
authinfo = ("test", "test")
interfaces_file = os.getcwd() + "/../torouter-prep/configs/interfaces"
+torrc_file = os.getcwd() + "/../torouter-prep/configs/torrc"
diff --git a/packages/torouter-web/runui.py b/packages/torouter-web/runui.py
index 3d2dfc8..80836b3 100644
--- a/packages/torouter-web/runui.py
+++ b/packages/torouter-web/runui.py
@@ -20,7 +20,7 @@ urls = (
'/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',
diff --git a/packages/torouter-web/static/main.css b/packages/torouter-web/static/main.css
index 5626e92..34e26cf 100644
--- a/packages/torouter-web/static/main.css
+++ b/packages/torouter-web/static/main.css
@@ -35,3 +35,17 @@ 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 --git a/packages/torouter-web/tui/controllers/tor.py b/packages/torouter-web/tui/controllers/tor.py
index d07cb71..af8678c 100644
--- a/packages/torouter-web/tui/controllers/tor.py
+++ b/packages/torouter-web/tui/controllers/tor.py
@@ -1,22 +1,28 @@
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
diff --git a/packages/torouter-web/tui/utils/parsing.py b/packages/torouter-web/tui/utils/parsing.py
index e9ccc83..6acf988 100644
--- a/packages/torouter-web/tui/utils/parsing.py
+++ b/packages/torouter-web/tui/utils/parsing.py
@@ -74,6 +74,27 @@ class interfaces:
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()
diff --git a/packages/torouter-web/tui/views/torstatus.html b/packages/torouter-web/tui/views/torstatus.html
index ed83531..27b2888 100644
--- a/packages/torouter-web/tui/views/torstatus.html
+++ b/packages/torouter-web/tui/views/torstatus.html
@@ -1 +1,3 @@
-The main Tor status page
+$def with (content, torrc)
+<h2>This is the content of $:torrc</h2>
+$:content
More information about the tor-commits
mailing list