From 151b12424cd33fb6788c5fe1dcc479414bf8e501 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 9 Sep 2018 00:12:41 -0500 Subject: [PATCH] work on block processing module --- onionr/core.py | 2 ++ onionr/netcontroller.py | 3 ++- onionr/onionrutils.py | 16 +++------------- onionr/static-data/default-plugins/cliui/main.py | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/onionr/core.py b/onionr/core.py index ab8b640b..97b822af 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -102,6 +102,8 @@ class Core: logger.warn("POW token for pubkey base64 representation exceeded 120 bytes, is " + str(sys.getsizeof(powID))) return False + events.event('pubkey_add', data = {'key': peerID}, onionr = None) + conn = sqlite3.connect(self.peerDB) hashID = self._crypto.pubKeyHashID(peerID) c = conn.cursor() diff --git a/onionr/netcontroller.py b/onionr/netcontroller.py index 74430bee..b3691956 100644 --- a/onionr/netcontroller.py +++ b/onionr/netcontroller.py @@ -74,7 +74,8 @@ class NetController: hashedPassword = subprocess.Popen([self.torBinary, '--hash-password', plaintext], stdout=subprocess.PIPE, stderr=subprocess.PIPE) for line in iter(hashedPassword.stdout.readline, b''): password = line.decode() - break + if 'warn' not in password: + break torrcData = '''SocksPort ''' + str(self.socksPort) + ''' HiddenServiceDir data/hs/ diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index a383684c..470dc125 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -23,6 +23,7 @@ import nacl.signing, nacl.encoding from onionrblockapi import Block import onionrexceptions from defusedxml import minidom +import onionrevents import pgpwords, onionrusers, storagecounter if sys.version_info < (3, 6): try: @@ -276,19 +277,8 @@ class OnionrUtils: if len(blockType) <= 10: self._core.updateBlockInfo(blockHash, 'dataType', blockType) - if blockType == 'userInfo': - if myBlock.verifySig(): - peerName = myBlock.getMetadata('name') - try: - if len(peerName) > 20: - raise onionrexceptions.InvalidMetdata('Peer name specified is too large') - except TypeError: - pass - except onionrexceptions.InvalidMetadata: - pass - else: - self._core.setPeerInfo(signer, 'name', peerName) - logger.info('%s is now using the name %s.' % (signer, self.escapeAnsi(peerName))) + onionrevents.event('processBlocks', data = {'block': myBlock, 'type': blockType}, onionr = None) + except TypeError: pass diff --git a/onionr/static-data/default-plugins/cliui/main.py b/onionr/static-data/default-plugins/cliui/main.py index e56f39df..5fc24385 100644 --- a/onionr/static-data/default-plugins/cliui/main.py +++ b/onionr/static-data/default-plugins/cliui/main.py @@ -54,7 +54,7 @@ class OnionrCLIUI: while showMenu: if firstRun: print("please wait while Onionr starts...") - daemon = subprocess.Popen(["./onionr.py", "start"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) + daemon = subprocess.Popen(["./onionr.py", "start"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL) time.sleep(30) firstRun = False