def do_handshake(self): self.logger.info('Do handshake') self.channel.send_name(self.node_name) _, status = self.channel.recv_status() if status == 'ok': self.logger.info('Status is "ok"') else: self.logger.warning( 'Status is "%s" does not know ' 'what to do with it', status) return challenge = self.channel.recv_challenge() out_challenge = challenge[3] challenge = gen_challenge() self.channel.send_challenge_reply(self.cookie, challenge, out_challenge) challenge_ack = self.channel.recv_challenge_ack() if challenge_ack[1] == gen_digest(challenge, self.cookie): self.logger.info('Connection is up') self._state = 'connected' if self.connected_event is not None: self.connected_event.set() else: self.logger.warning('Cannot set up connection, ' 'because of digest missmatch.')
def test_handshake(self): conn = EPMDKeepAliveConnection('test', 9999) conn.start() res = port2_please(self.erl_node_name) erl_port = res[1] channel = Channel(None) channel.connect(erl_port) node_name = self.erl_node_name + '@' + socket.gethostname() channel.send_name(node_name) self.assertEqual(channel.recv_status(), ('s', 'ok')) res = channel.recv_challenge() self.assertEqual(len(res), 5) self.assertEqual(res[0], 'n') self.assertEqual(res[4], node_name) out_challenge = res[3] challenge = gen_challenge() channel.send_challenge_reply(self.erl_node_secret, challenge, out_challenge) res = channel.recv_challenge_ack() self.assertEqual(len(res), 2) self.assertEqual(res[0], 'a')
def do_handshake(self): self.logger.info('Do handshake') self.channel.send_name(self.node_name) _, status = self.channel.recv_status() if status == 'ok': self.logger.info('Status is "ok"') else: self.logger.warning('Status is "%s" does not know ' 'what to do with it', status) return challenge = self.channel.recv_challenge() out_challenge = challenge[3] challenge = gen_challenge() self.channel.send_challenge_reply(self.cookie, challenge, out_challenge) challenge_ack = self.channel.recv_challenge_ack() if challenge_ack[1] == gen_digest(challenge, self.cookie): self.logger.info('Connection is up') self._state = 'connected' if self.connected_event is not None: self.connected_event.set() else: self.logger.warning('Cannot set up connection, ' 'because of digest missmatch.')