work on new block system
parent
9e9595b4ec
commit
8a16c972fd
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue