work on new block system

This commit is contained in:
Kevin Froman 2018-06-07 03:15:01 -05:00
parent 9e9595b4ec
commit 8a16c972fd
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 14 additions and 11 deletions

View File

@ -77,9 +77,6 @@ class API:
with open('data/time-bypass.txt', 'w') as bypass: with open('data/time-bypass.txt', 'w') as bypass:
bypass.write(self.timeBypassToken) bypass.write(self.timeBypassToken)
if not os.environ.get("WERKZEUG_RUN_MAIN") == "true":
logger.debug('Your web password (KEEP SECRET): ' + logger.colors.underline + self.clientToken)
if not debug and not self._developmentMode: if not debug and not self._developmentMode:
hostOctets = [127, random.randint(0x02, 0xFF), random.randint(0x02, 0xFF), random.randint(0x02, 0xFF)] hostOctets = [127, random.randint(0x02, 0xFF), random.randint(0x02, 0xFF), random.randint(0x02, 0xFF)]
self.host = '.'.join(hostOctets) self.host = '.'.join(hostOctets)
@ -193,8 +190,6 @@ class API:
pass pass
elif action == 'ping': elif action == 'ping':
resp = Response("pong!") resp = Response("pong!")
elif action == 'getHMAC':
resp = Response(self._crypto.generateSymmetric())
elif action == 'getSymmetric': elif action == 'getSymmetric':
resp = Response(self._crypto.generateSymmetric()) resp = Response(self._crypto.generateSymmetric())
elif action == 'getDBHash': elif action == 'getDBHash':
@ -214,13 +209,15 @@ class API:
resp = Response('') resp = Response('')
# setData should be something the communicator initiates, not this api # setData should be something the communicator initiates, not this api
elif action == 'getData': elif action == 'getData':
resp = ''
if self._utils.validateHash(data): if self._utils.validateHash(data):
if not os.path.exists('data/blocks/' + data + '.db'): if os.path.exists('data/blocks/' + data + '.db'):
try: try:
resp = base64.b64encode(self._core.getData(data)) block = Block(data, core=self._core)()
resp = base64.b64encode(block.getRaw())
except TypeError: except TypeError:
resp = "" resp = ""
if resp == False: if len(resp) == 0:
abort(404) abort(404)
resp = "" resp = ""
resp = Response(resp) resp = Response(resp)

View File

@ -484,9 +484,9 @@ class OnionrCommunicate:
lastDB = self._core.getAddressInfo(i, 'DBHash') lastDB = self._core.getAddressInfo(i, 'DBHash')
if lastDB == None: if lastDB == None:
logger.debug('Fetching hash from %s, no previous known.' % str(i)) logger.debug('Fetching db hash from %s, no previous known.' % str(i))
else: else:
logger.debug('Fetching hash from %s, %s last known' % (str(i), str(lastDB))) logger.debug('Fetching db hash from %s, %s last known' % (str(i), str(lastDB)))
currentDB = self.performGet('getDBHash', i) currentDB = self.performGet('getDBHash', i)

View File

@ -201,7 +201,9 @@ class Onionr:
'importblocks': self.onionrUtils.importNewBlocks, 'importblocks': self.onionrUtils.importNewBlocks,
'introduce': self.onionrCore.introduceNode, 'introduce': self.onionrCore.introduceNode,
'connect': self.addAddress 'connect': self.addAddress,
'getpassword': self.getWebPassword
} }
self.cmdhelp = { self.cmdhelp = {
@ -211,6 +213,7 @@ class Onionr:
'start': 'Starts the Onionr daemon', 'start': 'Starts the Onionr daemon',
'stop': 'Stops the Onionr daemon', 'stop': 'Stops the Onionr daemon',
'stats': 'Displays node statistics', 'stats': 'Displays node statistics',
'getpassword': 'Displays the web password',
'enable-plugin': 'Enables and starts a plugin', 'enable-plugin': 'Enables and starts a plugin',
'disable-plugin': 'Disables and stops a plugin', 'disable-plugin': 'Disables and stops a plugin',
'reload-plugin': 'Reloads a plugin', 'reload-plugin': 'Reloads a plugin',
@ -250,6 +253,9 @@ class Onionr:
def getCommands(self): def getCommands(self):
return self.cmds return self.cmds
def getWebPassword(self):
return config.get('client')['client_hmac']
def getHelp(self): def getHelp(self):
return self.cmdhelp return self.cmdhelp