def __init__(self, *args, **kwargs): checkPortAvailable(kwargs['ha']) basedirpath = kwargs.get('basedirpath') keep = RoadKeep(basedirpath=basedirpath, stackname=kwargs['name'], auto=kwargs.get('auto'), baseroledirpath=basedirpath) # type: RoadKeep kwargs['keep'] = keep localRoleData = keep.loadLocalRoleData() sighex = kwargs.pop('sighex', None) or localRoleData['sighex'] if not sighex: (sighex, _), (prihex, _) = getEd25519AndCurve25519Keys() else: prihex = ed25519SkToCurve25519(sighex, toHex=True) kwargs['sigkey'] = sighex kwargs['prikey'] = prihex self.msgHandler = kwargs.pop('msgHandler', None) # type: Callable super().__init__(*args, **kwargs) if self.ha[1] != kwargs['ha'].port: error("the stack port number has changed, likely due to " "information in the keep. {} passed {}, actual {}".format( kwargs['name'], kwargs['ha'].port, self.ha[1])) self.created = time.perf_counter() self.coro = None config = getConfig() try: self.messageTimeout = config.RAETMessageTimeout except AttributeError: # if no timeout is set then message will never timeout self.messageTimeout = 0
def __init__(self, *args, **kwargs): checkPortAvailable(kwargs['ha']) basedirpath = kwargs.get('basedirpath') keep = RoadKeep(basedirpath=basedirpath, stackname=kwargs['name'], auto=kwargs.get('auto'), baseroledirpath=basedirpath) # type: RoadKeep kwargs['keep'] = keep localRoleData = keep.loadLocalRoleData() sighex = kwargs.pop('sighex', None) or localRoleData['sighex'] if not sighex: (sighex, _), (prihex, _) = getEd25519AndCurve25519Keys() else: prihex = ed25519SkToCurve25519(sighex, toHex=True) kwargs['sigkey'] = sighex kwargs['prikey'] = prihex self.msgHandler = kwargs.pop('msgHandler', None) # type: Callable super().__init__(*args, **kwargs) if self.ha[1] != kwargs['ha'].port: error("the stack port number has changed, likely due to " "information in the keep. {} passed {}, actual {}". format(kwargs['name'], kwargs['ha'].port, self.ha[1])) self.created = time.perf_counter() self.coro = None config = getConfig() try: self.messageTimeout = config.RAETMessageTimeout except AttributeError: # if no timeout is set then message will never timeout self.messageTimeout = 0
def isLocalKeepSetup(name, baseDir=None) -> bool: """ Check that the local RAET keep has the values of role, sighex and prihex populated for the given node :param name: the name of the node to check the keys for :param baseDir: base directory of Plenum :return: whether the keys are setup """ keep = RoadKeep(stackname=name, baseroledirpath=baseDir) localRoleData = keep.loadLocalRoleData() return hasKeys(localRoleData, ['role', 'sighex', 'prihex'])
def isLocalKeepSetup(name, baseDir=None) -> bool: """ Check that the local RAET keep has the values of role, sighex and prihex populated for the given node :param name: the name of the node to check the keys for :param baseDir: base directory of Plenum :return: whether the keys are setup """ keep = RoadKeep(stackname=name, baseroledirpath=baseDir) localRoleData = keep.loadLocalRoleData() return hasKeys(localRoleData, ['role', 'sighex', 'prihex'])
def __init__(self, *args, **kwargs): keep = RoadKeep(basedirpath=kwargs.get('basedirpath'), stackname=kwargs['name'], auto=kwargs.get('auto'), baseroledirpath=kwargs.get('basedirpath')) kwargs['keep'] = keep localRoleData = keep.loadLocalRoleData() kwargs['sigkey'] = localRoleData['sighex'] kwargs['prikey'] = localRoleData['prihex'] super().__init__(*args, **kwargs) self.created = time.perf_counter() self.coro = self._raetcoro() self.msgHandler = None # type: Callable
def __init__(self, *args, **kwargs): checkPortAvailable(kwargs['ha']) basedirpath = kwargs.get('basedirpath') authMode = kwargs.pop('auth_mode', None) kwargs['auto'] = self._getAuto(authMode) keep = RoadKeep(basedirpath=basedirpath, stackname=kwargs['name'], auto=kwargs.get('auto'), baseroledirpath=basedirpath) # type: RoadKeep kwargs['keep'] = keep localRoleData = keep.loadLocalRoleData() sighex = kwargs.pop('sighex', None) or localRoleData['sighex'] if not sighex: (sighex, _), (prihex, _) = getEd25519AndCurve25519Keys() else: prihex = ed25519SkToCurve25519(sighex, toHex=True) kwargs['sigkey'] = sighex kwargs['prikey'] = prihex self.msgHandler = kwargs.pop('msgHandler', None) # type: Callable # if no timeout is set then message will never timeout self.messageTimeout = kwargs.pop('messageTimeout', 0) self.raetStack = RoadStack(*args, **kwargs) if self.ha[1] != kwargs['ha'].port: error("{}the stack port number has changed, likely due to " "information in the keep. {} passed {}, actual {}".format( CONNECTION_PREFIX, kwargs['name'], kwargs['ha'].port, self.ha[1])) self._created = time.perf_counter() self.coro = None self._conns = set() # type: Set[str]
def getLocalKeep(name, baseDir=None): keep = RoadKeep(stackname=name, baseroledirpath=baseDir) localRoleData = keep.loadLocalRoleData() return localRoleData
def getLocalKeep(name, baseDir=None): keep = RoadKeep(stackname=name, baseroledirpath=baseDir) localRoleData = keep.loadLocalRoleData() return localRoleData