no longer use b64 transport (was a crutch/temp fix), mail work, dont name all files 'txt'

This commit is contained in:
Kevin Froman 2019-02-06 19:03:31 -06:00
parent 06048fe442
commit 0e3fb41912
9 changed files with 45 additions and 18 deletions

View File

@ -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/<path:path>')
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

View File

@ -222,6 +222,7 @@ class OnionrCommunicatorDaemon:
self.blockQueue[i] = [peer] # add blocks to download queue
else:
if peer not in self.blockQueue[i]:
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:

View File

@ -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
'''

View File

@ -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

View File

@ -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):
'''

View File

@ -1 +0,0 @@
i7dgbnouzyl7gv75b3eaqfz7x236abkn6nkjdpun273sydkbwcoidrid.onion

View File

@ -28,7 +28,7 @@
<div class='overlayContent'>
<span class='closeOverlay' overlay='messageDisplay'></span>
<div>
From: <input type='text' id='fromUser' readonly>
From: <input type='text' id='fromUser' readonly> Signature: <span id='sigValid'></span>
</div>
<div id='signatureValidity'></div>
<div id='threadDisplay'>

View File

@ -2,7 +2,7 @@
padding-top: 1em;
}
.threads div span{
padding-left: 0.1em;
padding-left: 0.2em;
padding-right: 0.2em;
}
@ -53,3 +53,15 @@ input{
padding: 1em;
margin: 1em;
}
.danger{
color: red;
}
.warn{
color: orange;
}
.good{
color: greenyellow;
}

View File

@ -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))