work on new block system
This commit is contained in:
parent
9e9595b4ec
commit
8a16c972fd
@ -77,9 +77,6 @@ class API:
|
||||
with open('data/time-bypass.txt', 'w') as bypass:
|
||||
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:
|
||||
hostOctets = [127, random.randint(0x02, 0xFF), random.randint(0x02, 0xFF), random.randint(0x02, 0xFF)]
|
||||
self.host = '.'.join(hostOctets)
|
||||
@ -193,8 +190,6 @@ class API:
|
||||
pass
|
||||
elif action == 'ping':
|
||||
resp = Response("pong!")
|
||||
elif action == 'getHMAC':
|
||||
resp = Response(self._crypto.generateSymmetric())
|
||||
elif action == 'getSymmetric':
|
||||
resp = Response(self._crypto.generateSymmetric())
|
||||
elif action == 'getDBHash':
|
||||
@ -214,13 +209,15 @@ class API:
|
||||
resp = Response('')
|
||||
# setData should be something the communicator initiates, not this api
|
||||
elif action == 'getData':
|
||||
resp = ''
|
||||
if self._utils.validateHash(data):
|
||||
if not os.path.exists('data/blocks/' + data + '.db'):
|
||||
if os.path.exists('data/blocks/' + data + '.db'):
|
||||
try:
|
||||
resp = base64.b64encode(self._core.getData(data))
|
||||
block = Block(data, core=self._core)()
|
||||
resp = base64.b64encode(block.getRaw())
|
||||
except TypeError:
|
||||
resp = ""
|
||||
if resp == False:
|
||||
if len(resp) == 0:
|
||||
abort(404)
|
||||
resp = ""
|
||||
resp = Response(resp)
|
||||
|
@ -484,9 +484,9 @@ class OnionrCommunicate:
|
||||
lastDB = self._core.getAddressInfo(i, 'DBHash')
|
||||
|
||||
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:
|
||||
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)
|
||||
|
||||
|
@ -201,7 +201,9 @@ class Onionr:
|
||||
'importblocks': self.onionrUtils.importNewBlocks,
|
||||
|
||||
'introduce': self.onionrCore.introduceNode,
|
||||
'connect': self.addAddress
|
||||
'connect': self.addAddress,
|
||||
|
||||
'getpassword': self.getWebPassword
|
||||
}
|
||||
|
||||
self.cmdhelp = {
|
||||
@ -211,6 +213,7 @@ class Onionr:
|
||||
'start': 'Starts the Onionr daemon',
|
||||
'stop': 'Stops the Onionr daemon',
|
||||
'stats': 'Displays node statistics',
|
||||
'getpassword': 'Displays the web password',
|
||||
'enable-plugin': 'Enables and starts a plugin',
|
||||
'disable-plugin': 'Disables and stops a plugin',
|
||||
'reload-plugin': 'Reloads a plugin',
|
||||
@ -249,6 +252,9 @@ class Onionr:
|
||||
|
||||
def getCommands(self):
|
||||
return self.cmds
|
||||
|
||||
def getWebPassword(self):
|
||||
return config.get('client')['client_hmac']
|
||||
|
||||
def getHelp(self):
|
||||
return self.cmdhelp
|
||||
|
Loading…
Reference in New Issue
Block a user