Commit e803749b authored by Julien Muchembled's avatar Julien Muchembled

demo: generate certs that expire quickly to check renewal

parent 0234d059
...@@ -7,6 +7,26 @@ def __file__(): ...@@ -7,6 +7,26 @@ def __file__():
_parse_args = ArgumentParser.parse_args _parse_args = ArgumentParser.parse_args
ArgumentParser.parse_args = lambda self: _parse_args(self, sys.argv[2:]) ArgumentParser.parse_args = lambda self: _parse_args(self, sys.argv[2:])
if 1:
# Check renewal of certificate.
from random import randrange
from re6st import registry
registry.RENEW_PERIOD = 60
_createCertificate = registry.RegistryServer.createCertificate
def createCertificate(self, client_prefix, *args):
self.cert_duration = 200 if int(client_prefix, 2) == 7 else \
randrange(10, 60) ** 2
try:
return _createCertificate(self, client_prefix, *args)
finally:
del self.cert_duration
registry.RegistryServer.createCertificate = createCertificate
# Simulate the case of a node that does
# not renew its certificate in time.
if sys.argv[2] == "@m7/re6stnet.conf":
registry.RENEW_PERIOD = -30
return os.path.join(sys.path[0], sys.argv[1]) return os.path.join(sys.path[0], sys.argv[1])
__file__ = __file__() __file__ = __file__()
execfile(__file__) execfile(__file__)
...@@ -43,10 +43,10 @@ def rpc(f): ...@@ -43,10 +43,10 @@ def rpc(f):
class RegistryServer(object): class RegistryServer(object):
peers = 0, () peers = 0, ()
cert_duration = 365 * 86400
def __init__(self, config): def __init__(self, config):
self.config = config self.config = config
self.cert_duration = 365 * 86400
self.lock = threading.Lock() self.lock = threading.Lock()
self.sessions = {} self.sessions = {}
self.sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) self.sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
......
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