* fixed bug causing onionr to usually only have 1 peer at once

* do not crash when loading new peer profile
* removed code for defunct *address* proof of work
+ added maxStoredPeers and maxConnect config options (TODO)
+ added lastConnectAttempt to address db
+ added command to cause instant peer exchange
+ added connectCheck.txt for TODO connection testing
This commit is contained in:
Kevin Froman 2018-08-02 15:18:01 -05:00
parent 8bb5014d41
commit 032aa780ef
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
6 changed files with 24 additions and 6 deletions

View File

@ -260,6 +260,8 @@ class OnionrCommunicatorDaemon:
for i in range(needed): for i in range(needed):
if len(self.onlinePeers) == 0: if len(self.onlinePeers) == 0:
self.connectNewPeer(useBootstrap=True) self.connectNewPeer(useBootstrap=True)
else:
self.connectNewPeer()
if self.shutdown: if self.shutdown:
break break
else: else:
@ -338,6 +340,9 @@ class OnionrCommunicatorDaemon:
url = 'http://' + peer + '/public/?action=' + action url = 'http://' + peer + '/public/?action=' + action
if len(data) > 0: if len(data) > 0:
url += '&data=' + data url += '&data=' + data
self._core.setAddressInfo(peer, 'lastConnectAttempt', self._core._utils.getEpoch()) # mark the time we're trying to request this peer
retData = self._core._utils.doGetRequest(url, port=self.proxyPort) retData = self._core._utils.doGetRequest(url, port=self.proxyPort)
# if request failed, (error), mark peer offline # if request failed, (error), mark peer offline
if retData == False: if retData == False:
@ -390,6 +395,10 @@ class OnionrCommunicatorDaemon:
for i in self.timers: for i in self.timers:
if i.timerFunction.__name__ == 'lookupKeys': if i.timerFunction.__name__ == 'lookupKeys':
i.count = (i.frequency - 1) i.count = (i.frequency - 1)
elif cmd[0] == 'pex':
for i in self.timers:
if i.timerFunction.__name__ == 'lookupAdders':
i.count = (i.frequency - 1)
elif cmd[0] == 'uploadBlock': elif cmd[0] == 'uploadBlock':
self.blockToUpload = cmd[1] self.blockToUpload = cmd[1]
threading.Thread(target=self.uploadBlock).start() threading.Thread(target=self.uploadBlock).start()

View File

@ -196,6 +196,7 @@ class Onionr:
'introduce': self.onionrCore.introduceNode, 'introduce': self.onionrCore.introduceNode,
'connect': self.addAddress, 'connect': self.addAddress,
'kex': self.doKEX, 'kex': self.doKEX,
'pex': self.doPEX,
'getpassword': self.printWebPassword 'getpassword': self.printWebPassword
} }
@ -218,6 +219,7 @@ class Onionr:
'import-blocks': 'import blocks from the disk (Onionr is transport-agnostic!)', 'import-blocks': 'import blocks from the disk (Onionr is transport-agnostic!)',
'listconn': 'list connected peers', 'listconn': 'list connected peers',
'kex': 'exchange keys with peers (done automatically)', 'kex': 'exchange keys with peers (done automatically)',
'pex': 'exchange addresses with peers (done automatically)',
'introduce': 'Introduce your node to the public Onionr network', 'introduce': 'Introduce your node to the public Onionr network',
} }
@ -329,6 +331,11 @@ class Onionr:
logger.info('Sending kex to command queue...') logger.info('Sending kex to command queue...')
self.onionrCore.daemonQueueAdd('kex') self.onionrCore.daemonQueueAdd('kex')
def doPEX(self):
'''make communicator do pex'''
logger.info('Sending pex to command queue...')
self.onionrCore.daemonQueueAdd('pex')
def listKeys(self): def listKeys(self):
''' '''
Displays a list of keys (used to be called peers) (?) Displays a list of keys (used to be called peers) (?)

View File

@ -41,7 +41,7 @@ class PeerProfiles:
'''Load the node's score from the database''' '''Load the node's score from the database'''
try: try:
self.success = int(self.coreInst.getAddressInfo(self.address, 'success')) self.success = int(self.coreInst.getAddressInfo(self.address, 'success'))
except TypeError: except (TypeError, ValueError) as e:
self.success = 0 self.success = 0
self.score = self.success self.score = self.success

View File

@ -125,10 +125,9 @@ class OnionrUtils:
if newAdderList != False: if newAdderList != False:
for adder in newAdderList.split(','): for adder in newAdderList.split(','):
if not adder in self._core.listAdders(randomOrder = False) and adder.strip() != self.getMyAddress(): if not adder in self._core.listAdders(randomOrder = False) and adder.strip() != self.getMyAddress():
if adder[:4] == '0000': if self._core.addAddress(adder):
if self._core.addAddress(adder): logger.info('Added %s to db.' % adder, timestamp = True)
logger.info('Added %s to db.' % adder, timestamp = True) retVal = True
retVal = True
else: else:
pass pass
#logger.debug('%s is either our address or already in our DB' % adder) #logger.debug('%s is either our address or already in our DB' % adder)

View File

@ -0,0 +1 @@
https://3g2upl4pq6kufc4m.onion/robots.txt,http://expyuzz4wqqyqhjn.onion/robots.txt,https://onionr.voidnet.tech/

View File

@ -57,6 +57,8 @@
"blockCacheTotal" : 50000000 "blockCacheTotal" : 50000000
}, },
"peers":{ "peers":{
"minimumScore": 5 "minimumScore": 5,
"maxStoredPeers": 100,
"maxConnect": 3
} }
} }