Skip to content

Commit

Permalink
add minimal /introducerless_config page
Browse files Browse the repository at this point in the history
  • Loading branch information
leif committed Feb 6, 2014
1 parent 1947a04 commit e555653
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/allmydata/web/introducerless_config.py
@@ -0,0 +1,33 @@

from twisted.internet import defer
from nevow import rend, inevow, tags as T
from allmydata.web.common import getxmlfile

class IntroducerlessConfig(rend.Page):

docFactory = getxmlfile("introducerless_config.xhtml")

def __init__(self, client):
self.client = client

def data_servers(self, ctx, data):
sb = self.client.get_storage_broker()
return sorted(sb.get_known_servers(), key=lambda s: s.get_serverid())

def render_server_config(self, ctx, server):

announcement = server.get_announcement()
seed = announcement['permutation-seed-base32']
furl = announcement['anonymous-storage-FURL']
peerid = server.get_longname()
nickname = server.get_nickname()

config = """
server.%s.type = tahoe-foolscap
server.%s.nickname = %s
server.%s.seed = %s
server.%s.furl = %s
""" % (peerid, peerid, nickname, peerid, seed, peerid, furl)

return config

23 changes: 23 additions & 0 deletions src/allmydata/web/introducerless_config.xhtml
@@ -0,0 +1,23 @@
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
<head>
<title>Tahoe-LAFS - Introducerless Config</title>
<link href="/tahoe.css" rel="stylesheet" type="text/css"/>
<link href="/icon.png" rel="shortcut icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<h1>Introducerless Config</h1>

This version of Tahoe-LAFS supports introducerless operation. To connect to the currently-connected storage servers without an introducer, add the lines below to your gateway's <tt>tahoe.cfg</tt> and restart it.

<pre>
[client-server-selection]
use_introducer = false
<span n:render="sequence" n:data="servers"><span n:pattern="item" n:render="server_config"/></span>
</pre>

<div>Return to the <a href="/">Welcome Page</a></div>

</body>
</html>
13 changes: 11 additions & 2 deletions src/allmydata/web/root.py
Expand Up @@ -11,8 +11,8 @@
from allmydata import get_package_versions_string
from allmydata.util import log
from allmydata.interfaces import IFileNode
from allmydata.web import filenode, directory, unlinked, status, operations
from allmydata.web import storage
from allmydata.web import filenode, directory, unlinked, status, operations, \
storage, introducerless_config
from allmydata.web.common import abbreviate_size, getxmlfile, WebError, \
get_arg, RenderMixin, get_format, get_mutable_type, TIME_FORMAT

Expand Down Expand Up @@ -151,6 +151,7 @@ def __init__(self, client, clock=None):
self.child_named = FileHandler(client)
self.child_status = status.Status(client.get_history())
self.child_statistics = status.Statistics(client.stats_provider)
self.child_introducerless_config = introducerless_config.IntroducerlessConfig(client)
static_dir = resource_filename("allmydata.web", "static")
for filen in os.listdir(static_dir):
self.putChild(filen, nevow_File(os.path.join(static_dir, filen)))
Expand Down Expand Up @@ -396,3 +397,11 @@ def render_incident_button(self, ctx, data):
T.input(type="submit", value=u"Save \u00BB"),
]]
return T.div[form]

def render_show_introducerless_config(self, ctx, data):
if False: # FIXME: add config item for showing this
return ""
else:
return ctx.tag[T.a(href="introducerless_config")[
"Introducerless Config"]]

1 change: 1 addition & 0 deletions src/allmydata/web/welcome.xhtml
Expand Up @@ -116,6 +116,7 @@
<li class="nav-header">Tools</li>
<li><a href="status">Recent and Active Operations</a></li>
<li><a href="statistics">Operational Statistics</a></li>
<li n:render="show_introducerless_config"/>
</ul>
</div>
<hr/>
Expand Down

0 comments on commit e555653

Please sign in to comment.