Commit f9f4e5f3 authored by Julien Muchembled's avatar Julien Muchembled

Allow to join the network without email/token

parent 761f50c6
......@@ -30,6 +30,9 @@ def main():
help="Email address where your token is sent. Use -r option if you"
" want to show an email in your certificate.")
_('--token', help="The token you received.")
_('--anonymous', action='store_true',
help="Request an anonymous certificate. No email is required but the"
" registry may deliver a longer prefix.")
config = parser.parse_args()
if config.dir:
......@@ -39,7 +42,7 @@ def main():
dh_path = 'dh2048.pem'
# Establish connection with server
s = xmlrpclib.ServerProxy(config.registry)
s = xmlrpclib.ServerProxy(config.registry, allow_none=True)
# Get CA
create(ca_path, s.getCa())
......@@ -74,7 +77,10 @@ def main():
cert_fd = token_advice = None
if not config.token:
if config.anonymous:
if not (config.token is is None):
parser.error("--anonymous conflicts with --email/--token")
elif not config.token:
if not = raw_input('Please enter your email address: ')
......@@ -72,8 +72,11 @@ class main(object):
help="re6stnet IP of the node on which runs the registry."
" Required for normal operation.")
_('--prefix-length', default=16,
_('--prefix-length', default=16, type=int,
help="Default length of allocated prefixes.")
_('--anonymous-prefix-length', type=int,
help="Length of allocated anonymous prefixes."
" If 0 or unset, registration by email is required")
_('-l', '--logfile', default='/var/log/re6stnet/registry.log',
help="Path to logging file.")
_('-v', '--verbose', default=1, type=int,
......@@ -199,11 +202,19 @@ class main(object):
req = crypto.load_certificate_request(crypto.FILETYPE_PEM, cert_req)
with self.db:
token, email, prefix_len, _ = self.db.execute("SELECT * FROM token WHERE token = ?", (token,)).next()
except StopIteration:
self.db.execute("DELETE FROM token WHERE token = ?", (token,))
if token is None:
prefix_len = self.config.anonymous_prefix_length
if not prefix_len:
email = None
token, email, prefix_len, _ = self.db.execute(
"SELECT * FROM token WHERE token = ?",
except StopIteration:
self.db.execute("DELETE FROM token WHERE token = ?", (token,))
# Get a new prefix
prefix = self._getPrefix(prefix_len)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment