From 8024d0e3544655326b4b675ede62ae1c19b3c0aa Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 18 Apr 2018 21:56:25 -0500 Subject: [PATCH] added introduce command --- onionr/communicator.py | 17 +++++++++++------ onionr/core.py | 11 +++++++++-- onionr/onionr.py | 4 +++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index 86665264..1a6ceb64 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -91,13 +91,18 @@ class OnionrCommunicate: if command[0] == 'shutdown': logger.info('Daemon recieved exit command.', timestamp=True) break - elif command[0] == 'anounceNode': - announceAmount = 1 + elif command[0] == 'announceNode': + announceAttempts = 3 + announceAttemptCount = 0 announceVal = False - for i in command[1]: - logger.info('Announcing our node to ' + command[1][i], timestamp=True) - while not announceVal: - announceVal = self.performGet('announce', command[1][i], data=self._core.hsAdder, skipHighFailureAddress=True) + logger.info('Announcing our node to ' + command[1], timestamp=True) + while not announceVal: + 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) diff --git a/onionr/core.py b/onionr/core.py index 9e901ff9..3b1bde67 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -555,6 +555,13 @@ class Core: ''' Introduces our node into the network by telling X many nodes our HS address ''' - nodeList = self.listAdders().split('\n') - self.daemonQueueAdd('announceNode', nodeList) + announceAmount = 2 + 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 diff --git a/onionr/onionr.py b/onionr/onionr.py index 699af257..df20e3af 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -149,6 +149,7 @@ class Onionr: 'add-msg': self.addMessage, 'add-message': self.addMessage, 'pm': self.sendEncrypt, + 'introduce': self.onionrCore.introduceNode, 'getpms': self.getPMs, 'get-pms': self.getPMs, @@ -168,6 +169,7 @@ class Onionr: self.cmdhelp = { 'help': 'Displays this Onionr help menu', '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', 'start': 'Starts the Onionr daemon', 'stop': 'Stops the Onionr daemon', @@ -178,7 +180,7 @@ class Onionr: 'add-peer': 'Adds a peer (?)', 'list-peers': 'Displays a list of peers', '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', 'gui': 'Opens a graphical interface for Onionr' }