From 80648cc9206bee3b70b7d4b8e4e1e14f0a0c1b57 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 3 Jul 2018 18:44:12 -0500 Subject: [PATCH] added kex command --- onionr/communicator2.py | 8 ++++++-- onionr/onionr.py | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index 5a2111fc..154d2f66 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -248,7 +248,9 @@ class OnionrCommunicatorDaemon: continue if self.peerAction(address, 'ping') == 'pong!': logger.info('Connected to ' + address) - self.onlinePeers.append(address) + time.sleep(0.1) + if address not in self.onlinePeers: + self.onlinePeers.append(address) retData = address break else: @@ -307,7 +309,9 @@ class OnionrCommunicatorDaemon: elif cmd[0] == 'connectedPeers': self.printOnlinePeers() elif cmd[0] == 'kex': - self.timers['lookupKeys'].count = (self.timers['lookupKeys'].frequency - 1) + for i in self.timers: + if i.timerFunction.__name__ == 'lookupKeys': + i.count = (i.frequency - 1) else: logger.info('Recieved daemonQueue command:' + cmd[0]) self.decrementThreadCount('daemonCommands') diff --git a/onionr/onionr.py b/onionr/onionr.py index abe69b3c..bed40a99 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -207,6 +207,7 @@ class Onionr: 'introduce': self.onionrCore.introduceNode, 'connect': self.addAddress, + 'kex': self.doKEX, 'getpassword': self.getWebPassword } @@ -231,6 +232,7 @@ class Onionr: 'add-file': 'Create an Onionr block from a file', 'import-blocks': 'import blocks from the disk (Onionr is transport-agnostic!)', 'listconn': 'list connected peers', + 'kex': 'exchange keys with peers (done automatically)', 'introduce': 'Introduce your node to the public Onionr network', } @@ -333,6 +335,11 @@ class Onionr: logger.info('Running on %s %s' % (platform.platform(), platform.release())) return + + def doKEX(self): + '''make communicator do kex''' + logger.info('Sending kex to command queue...') + self.onionrCore.daemonQueueAdd('kex') def sendEncrypt(self): '''