improving new communicator bootstrapping, do not connect to self

master
Kevin Froman 2018-07-03 16:24:14 -05:00
parent 267220ad72
commit 58110e461e
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 11 additions and 5 deletions

View File

@ -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
else:
logger.info('Online peers:')
for i in self.onlinePeers:
logger.info(self.onlinePeers[i])
logger.info(i)
def peerAction(self, peer, action, data=''):
'''Perform a get request to a peer'''

View File

@ -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):