added introduce command

master
Kevin Froman 2018-04-18 21:56:25 -05:00
parent d8d29b7c28
commit 8024d0e354
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 23 additions and 9 deletions

View File

@ -91,13 +91,18 @@ class OnionrCommunicate:
if command[0] == 'shutdown': if command[0] == 'shutdown':
logger.info('Daemon recieved exit command.', timestamp=True) logger.info('Daemon recieved exit command.', timestamp=True)
break break
elif command[0] == 'anounceNode': elif command[0] == 'announceNode':
announceAmount = 1 announceAttempts = 3
announceAttemptCount = 0
announceVal = False announceVal = False
for i in command[1]: logger.info('Announcing our node to ' + command[1], timestamp=True)
logger.info('Announcing our node to ' + command[1][i], timestamp=True)
while not announceVal: while not announceVal:
announceVal = self.performGet('announce', command[1][i], data=self._core.hsAdder, skipHighFailureAddress=True) announceAttemptCount += 1
announceVal = self.performGet('announce', command[1], data=self._core.hsAdder.replace('\n', ''), skipHighFailureAddress=True)
logger.info(announceVal)
if announceAttemptCount >= announceAttempts:
logger.warn('Unable to announce to ' + command[1])
break
time.sleep(1) time.sleep(1)

View File

@ -555,6 +555,13 @@ class Core:
''' '''
Introduces our node into the network by telling X many nodes our HS address Introduces our node into the network by telling X many nodes our HS address
''' '''
nodeList = self.listAdders().split('\n') announceAmount = 2
self.daemonQueueAdd('announceNode', nodeList) nodeList = self.listAdders()
if len(nodeList) == 0:
self.addAddress('onionragxuddecmg.onion')
nodeList.append('onionragxuddecmg.onion')
if announceAmount > len(nodeList):
announceAmount = len(nodeList)
for i in range(announceAmount):
self.daemonQueueAdd('announceNode', nodeList[i])
return return

View File

@ -149,6 +149,7 @@ class Onionr:
'add-msg': self.addMessage, 'add-msg': self.addMessage,
'add-message': self.addMessage, 'add-message': self.addMessage,
'pm': self.sendEncrypt, 'pm': self.sendEncrypt,
'introduce': self.onionrCore.introduceNode,
'getpms': self.getPMs, 'getpms': self.getPMs,
'get-pms': self.getPMs, 'get-pms': self.getPMs,
@ -168,6 +169,7 @@ class Onionr:
self.cmdhelp = { self.cmdhelp = {
'help': 'Displays this Onionr help menu', 'help': 'Displays this Onionr help menu',
'version': 'Displays the Onionr version', 'version': 'Displays the Onionr version',
'introduce': 'Introduce your node to the public Onionr network. (DAEMON MUST BE RUNNING)',
'config': 'Configures something and adds it to the file', 'config': 'Configures something and adds it to the file',
'start': 'Starts the Onionr daemon', 'start': 'Starts the Onionr daemon',
'stop': 'Stops the Onionr daemon', 'stop': 'Stops the Onionr daemon',
@ -178,7 +180,7 @@ class Onionr:
'add-peer': 'Adds a peer (?)', 'add-peer': 'Adds a peer (?)',
'list-peers': 'Displays a list of peers', 'list-peers': 'Displays a list of peers',
'add-msg': 'Broadcasts a message to the Onionr network', 'add-msg': 'Broadcasts a message to the Onionr network',
'pm': 'Adds a private message to block', 'pm': 'Sends a private message to a user as an Onionr block',
'get-pms': 'Shows private messages sent to you', 'get-pms': 'Shows private messages sent to you',
'gui': 'Opens a graphical interface for Onionr' 'gui': 'Opens a graphical interface for Onionr'
} }