def clientConnectionMade(self, broker): if self.sslContextFactory and not self.sslContextFactory.certificate_verified: self.remote_client.log.error( "A remote cloud could not prove that its security certificate is " "from {host}. This may cause a misconfiguration or an attacker " "intercepting your connection.", host=self.sslContextFactory.host, ) return self.remote_client.disconnect() pb.PBClientFactory.clientConnectionMade(self, broker) protocol.ReconnectingClientFactory.resetDelay(self) self.remote_client.log.info("Successfully connected") self.remote_client.log.info("Authenticating") auth_token = None try: auth_token = AccountClient().fetch_authentication_token() except Exception as e: # pylint:disable=broad-except d = defer.Deferred() d.addErrback(self.clientAuthorizationFailed) d.errback(pb.Error(e)) return d d = self.login( credentials.UsernamePassword( auth_token.encode(), get_host_id().encode(), ), client=self.remote_client, ) d.addCallback(self.remote_client.cb_client_authorization_made) d.addErrback(self.clientAuthorizationFailed) return d
def __init__(self): self.log_level = LogLevel.warn self.log = Logger(namespace="remote", observer=self._log_observer) self.id = app.get_host_id() self.name = app.get_host_name() self.join_options = {"corever": __version__} self.perspective = None self.agentpool = None self._ping_id = 0 self._ping_caller = None self._ping_counter = 0 self._reactor_stopped = False self._exit_code = 0