Commit 0b012c01 authored by Tom Niget's avatar Tom Niget

Add logs

parent 748ea1d3
...@@ -99,7 +99,9 @@ class RegistryServer: ...@@ -99,7 +99,9 @@ class RegistryServer:
"prefix TEXT PRIMARY KEY NOT NULL", "prefix TEXT PRIMARY KEY NOT NULL",
"email TEXT", "email TEXT",
"cert TEXT") "cert TEXT")
logging.debug("Checking for existing certs...")
if not self.db.execute("SELECT 1 FROM cert LIMIT 1").fetchone(): if not self.db.execute("SELECT 1 FROM cert LIMIT 1").fetchone():
logging.debug("No existing certs found, creating a blank one...")
self.db.execute("INSERT INTO cert VALUES ('',null,null)") self.db.execute("INSERT INTO cert VALUES ('',null,null)")
prev = '-' prev = '-'
...@@ -265,7 +267,7 @@ class RegistryServer: ...@@ -265,7 +267,7 @@ class RegistryServer:
if x <= old: if x <= old:
if prefix == self.prefix: if prefix == self.prefix:
logging.critical("Refuse to delete certificate" logging.critical("Refuse to delete certificate"
" of main node: wrong clock ?") " of main node: wrong clock ? Alternatively, try deleting .db")
sys.exit(1) sys.exit(1)
logging.info("Delete %s: %s (invalid since %s)", logging.info("Delete %s: %s (invalid since %s)",
"certificate requested by '%s'" % email "certificate requested by '%s'" % email
...@@ -350,9 +352,11 @@ class RegistryServer: ...@@ -350,9 +352,11 @@ class RegistryServer:
def getCert(self, client_prefix): def getCert(self, client_prefix):
assert self.lock.locked() assert self.lock.locked()
return self.db.execute("SELECT cert FROM cert" cert = self.db.execute("SELECT cert FROM cert"
" WHERE prefix=? AND cert IS NOT NULL", " WHERE prefix=? AND cert IS NOT NULL", (client_prefix,)).fetchone()
(client_prefix,)).fetchone()[0] assert cert, ("cert query from db is None, should not happen",
self.db.execute("SELECT * FROM cert").fetchall())
return cert[0]
@rpc_private @rpc_private
def isToken(self, token): def isToken(self, token):
...@@ -433,6 +437,7 @@ class RegistryServer: ...@@ -433,6 +437,7 @@ class RegistryServer:
return default return default
def mergePrefixes(self): def mergePrefixes(self):
logging.debug("Merging prefixes")
q = self.db.execute q = self.db.execute
prev_prefix = None prev_prefix = None
max_len = 128, max_len = 128,
...@@ -455,6 +460,7 @@ class RegistryServer: ...@@ -455,6 +460,7 @@ class RegistryServer:
prev_prefix = prefix prev_prefix = prefix
def newPrefix(self, prefix_len, community): def newPrefix(self, prefix_len, community):
logging.info("Allocating /%u prefix for %s", prefix_len, community)
community_len = len(community) community_len = len(community)
prefix_len += community_len prefix_len += community_len
max_len = 128 - len(self.network) max_len = 128 - len(self.network)
...@@ -494,6 +500,7 @@ class RegistryServer: ...@@ -494,6 +500,7 @@ class RegistryServer:
@rpc @rpc
def requestCertificate(self, token, req, location='', ip=''): def requestCertificate(self, token, req, location='', ip=''):
logging.debug("Requesting certificate with token %s", token)
req = crypto.load_certificate_request(crypto.FILETYPE_PEM, req) req = crypto.load_certificate_request(crypto.FILETYPE_PEM, req)
with self.lock: with self.lock:
with self.db: with self.db:
......
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