From 58110e461ecf0b48eace3d1164659af07a998f6b Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 3 Jul 2018 16:24:14 -0500 Subject: [PATCH] improving new communicator bootstrapping, do not connect to self --- onionr/communicator2.py | 11 +++++++---- onionr/onionrutils.py | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/onionr/communicator2.py b/onionr/communicator2.py index eb930b73..5a2111fc 100755 --- a/onionr/communicator2.py +++ b/onionr/communicator2.py @@ -72,7 +72,9 @@ class OnionrCommunicatorDaemon: OnionrCommunicatorTimers(self, self.heartbeat, 10) # Initalize peer online list + logger.warn('Onionr is not yet ready to recieve commands.') self.getOnlinePeers() + logger.info('\033[4mOnionr is ready\033[0m.') # Set timers, function reference, seconds OnionrCommunicatorTimers(self, self.daemonCommands, 5) @@ -222,7 +224,7 @@ class OnionrCommunicatorDaemon: def addBootstrapListToPeerList(self, peerList): '''Add the bootstrap list to the peer list (no duplicates)''' for i in self._core.bootstrapList: - if i not in peerList: + if i not in peerList and i not in self.offlinePeers and i != self._core.hsAdder: peerList.append(i) def connectNewPeer(self, peer='', useBootstrap=False): @@ -261,9 +263,10 @@ class OnionrCommunicatorDaemon: '''logs online peer list''' if len(self.onlinePeers) == 0: logger.warn('No online peers') - return - for i in self.onlinePeers: - logger.info(self.onlinePeers[i]) + else: + logger.info('Online peers:') + for i in self.onlinePeers: + logger.info(i) def peerAction(self, peer, action, data=''): '''Perform a get request to a peer''' diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 9534ddee..1948aca8 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -33,7 +33,7 @@ if sys.version_info < (3, 6): class OnionrUtils: ''' - Various useful function + Various useful functions for validating things, etc functions, connectivity ''' def __init__(self, coreInstance): self.fingerprintFile = 'data/own-fingerprint.txt' @@ -41,6 +41,9 @@ class OnionrUtils: self.timingToken = '' + self.avoidDupe = [] # list used to prevent duplicate requests per peer for certain actions + self.peerProcessing = {} # dict of current peer actions: peer, actionList + return def getTimeBypassToken(self):