From 0e3fb419127d3c05bffbd9f8d3a9f3103b9ddacf Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Wed, 6 Feb 2019 19:03:31 -0600 Subject: [PATCH] no longer use b64 transport (was a crutch/temp fix), mail work, dont name all files 'txt' --- onionr/api.py | 8 +++++--- onionr/communicator.py | 7 ++++--- onionr/onionr.py | 4 ++-- onionr/onionrblockapi.py | 3 ++- onionr/onionrutils.py | 3 ++- onionr/static-data/bootstrap-nodes.txt | 1 - onionr/static-data/www/mail/index.html | 2 +- onionr/static-data/www/mail/mail.css | 16 ++++++++++++++-- onionr/static-data/www/mail/mail.js | 19 +++++++++++++++---- 9 files changed, 45 insertions(+), 18 deletions(-) diff --git a/onionr/api.py b/onionr/api.py index 54adbc47..d9b9e920 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -138,11 +138,13 @@ class PublicAPI: if data not in self.hideBlocks: if data in clientAPI._core.getBlockList(): block = clientAPI.getBlockData(data, raw=True).encode() - resp = base64.b64encode(block).decode() + block = clientAPI._core._utils.strToBytes(block) + resp = block + #resp = base64.b64encode(block).decode() if len(resp) == 0: abort(404) resp = "" - return Response(resp) + return Response(resp, mimetype='application/octet-stream') @app.route('/www/') def wwwPublic(path): @@ -500,7 +502,7 @@ class API: else: validSig = False signer = self._core._utils.bytesToStr(bl.signer) - print(signer, bl.isSigned(), self._core._utils.validatePubKey(signer), bl.isSigner(signer)) + #print(signer, bl.isSigned(), self._core._utils.validatePubKey(signer), bl.isSigner(signer)) if bl.isSigned() and self._core._utils.validatePubKey(signer) and bl.isSigner(signer): validSig = True bl.bheader['validSig'] = validSig diff --git a/onionr/communicator.py b/onionr/communicator.py index 1b8dc7fd..6104fd2c 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -222,7 +222,8 @@ class OnionrCommunicatorDaemon: self.blockQueue[i] = [peer] # add blocks to download queue else: if peer not in self.blockQueue[i]: - self.blockQueue[i].append(peer) + if len(self.blockQueue[i]) < 10: + self.blockQueue[i].append(peer) self.decrementThreadCount('lookupBlocks') return @@ -240,10 +241,10 @@ class OnionrCommunicatorDaemon: break # Do not download blocks being downloaded or that are already saved (edge cases) if blockHash in self.currentDownloading: - logger.debug('Already downloading block %s...' % blockHash) + #logger.debug('Already downloading block %s...' % blockHash) continue if blockHash in self._core.getBlockList(): - logger.debug('Block %s is already saved.' % (blockHash,)) + #logger.debug('Block %s is already saved.' % (blockHash,)) try: del self.blockQueue[blockHash] except KeyError: diff --git a/onionr/onionr.py b/onionr/onionr.py index 89215dc5..06aaa694 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -40,7 +40,7 @@ try: except ImportError: raise Exception("You need the PySocks module (for use with socks5 proxy to use Tor)") -ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.VoidNet.Tech' +ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.net' ONIONR_VERSION = '0.5.0' # for debugging and stuff ONIONR_VERSION_TUPLE = tuple(ONIONR_VERSION.split('.')) # (MAJOR, MINOR, VERSION) API_VERSION = '5' # increments of 1; only change when something fundemental about how the API works changes. This way other nodes know how to communicate without learning too much information about you. @@ -986,7 +986,7 @@ class Onionr: ''' self.addFile(singleBlock=True, blockType='html') - def addFile(self, singleBlock=False, blockType='txt'): + def addFile(self, singleBlock=False, blockType='bin'): ''' Adds a file to the onionr network ''' diff --git a/onionr/onionrblockapi.py b/onionr/onionrblockapi.py index 09dd77ea..9f38b785 100755 --- a/onionr/onionrblockapi.py +++ b/onionr/onionrblockapi.py @@ -94,7 +94,8 @@ class Block: logger.error(str(e)) pass except nacl.exceptions.CryptoError: - logger.debug('Could not decrypt block. Either invalid key or corrupted data') + pass + #logger.debug('Could not decrypt block. Either invalid key or corrupted data') else: retData = True self.decrypted = True diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index 1929a398..85cfc441 100755 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -309,7 +309,8 @@ class OnionrUtils: else: self._core.updateBlockInfo(blockHash, 'expire', expireTime) else: - logger.debug('Not processing metadata on encrypted block we cannot decrypt.') + pass + #logger.debug('Not processing metadata on encrypted block we cannot decrypt.') def escapeAnsi(self, line): ''' diff --git a/onionr/static-data/bootstrap-nodes.txt b/onionr/static-data/bootstrap-nodes.txt index 6fb8319b..e69de29b 100755 --- a/onionr/static-data/bootstrap-nodes.txt +++ b/onionr/static-data/bootstrap-nodes.txt @@ -1 +0,0 @@ -i7dgbnouzyl7gv75b3eaqfz7x236abkn6nkjdpun273sydkbwcoidrid.onion \ No newline at end of file diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index 18b2ddfc..051e280b 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -28,7 +28,7 @@
- From: + From: Signature:
diff --git a/onionr/static-data/www/mail/mail.css b/onionr/static-data/www/mail/mail.css index c3da2296..c7bd8ed8 100755 --- a/onionr/static-data/www/mail/mail.css +++ b/onionr/static-data/www/mail/mail.css @@ -2,7 +2,7 @@ padding-top: 1em; } .threads div span{ - padding-left: 0.1em; + padding-left: 0.2em; padding-right: 0.2em; } @@ -52,4 +52,16 @@ input{ min-height: 100%; padding: 1em; margin: 1em; - } \ No newline at end of file + } + +.danger{ + color: red; +} + +.warn{ + color: orange; +} + +.good{ + color: greenyellow; +} \ No newline at end of file diff --git a/onionr/static-data/www/mail/mail.js b/onionr/static-data/www/mail/mail.js index fa6a87f0..71e592e9 100755 --- a/onionr/static-data/www/mail/mail.js +++ b/onionr/static-data/www/mail/mail.js @@ -24,11 +24,23 @@ tabBtns = document.getElementById('tabBtns') threadContent = {} myPub = httpGet('/getActivePubkey') -function openThread(bHash, sender, date){ +function openThread(bHash, sender, date, sigBool){ var messageDisplay = document.getElementById('threadDisplay') - blockContent = httpGet('/getblockbody/' + bHash) + var blockContent = httpGet('/getblockbody/' + bHash) document.getElementById('fromUser').value = sender messageDisplay.innerText = blockContent + var sigEl = document.getElementById('sigValid') + var sigMsg = 'signature' + + if (sigBool){ + sigMsg = 'Good ' + sigMsg + sigEl.classList.remove('danger') + } + else{ + sigMsg = 'Bad/no ' + sigMsg + ' (message could be fake)' + sigEl.classList.add('danger') + } + sigEl.innerText = sigMsg overlay('messageDisplay') } @@ -68,7 +80,6 @@ function loadInboxEntrys(bHash){ var metadata = resp['metadata'] humanDate.setUTCSeconds(resp['meta']['time']) senderInput.value = httpGet('/getHumanReadable/' + resp['meta']['signer']) - alert(resp['meta']['validSig']) if (resp['meta']['validSig']){ validSig.innerText = 'Signature Validity: Good' } @@ -99,7 +110,7 @@ function loadInboxEntrys(bHash){ entry.classList.add('threadEntry') entry.onclick = function(){ - openThread(entry.getAttribute('hash'), senderInput.value, dateStr.innerText) + openThread(entry.getAttribute('hash'), senderInput.value, dateStr.innerText, resp['meta']['validSig']) } }.bind(bHash))