def getVerKey(self, name): try: return self.loadPubKeyFromDisk(self.verifKeyDir, name) except KeyError: if self.isRestricted: raise VerKeyNotFoundOnDisk(self.name, name) return None
def connect(self, name=None, remoteId=None, ha=None, verKeyRaw=None, publicKeyRaw=None): """ Connect to the node specified by name. """ if not name: raise ValueError('Name needs to be specified') if name not in self.remotes: publicKey = None if not publicKeyRaw: try: publicKey = self.getPublicKey(name) except KeyError: raise PublicKeyNotFoundOnDisk(self.name, name) else: publicKey = z85.encode(publicKeyRaw) verKey = None if not verKeyRaw: try: verKey = self.getVerKey(name) except KeyError: if self.isRestricted: raise VerKeyNotFoundOnDisk(self.name, name) else: verKey = z85.encode(verKeyRaw) if not (ha and publicKey and (not self.isRestricted or verKey)): raise ValueError('{} doesnt have enough info to connect. ' 'Need ha, public key and verkey. {} {} {}'. format(name, ha, verKey, publicKey)) remote = self.addRemote(name, ha, verKey, publicKey) else: remote = self.remotes[name] public, secret = self.selfEncKeys remote.connect(self.ctx, public, secret) logger.info("{} looking for {} at {}:{}". format(self, name or remote.name, *remote.ha), extra={"cli": "PLAIN", "tags": ["node-looking"]}) # This should be scheduled as an async task self.sendPing(remote) return remote.uid