* fixed addpeer command to work with pow
* improved stats screen to show pow token for your keymaster
parent
f8657deaa3
commit
77a847a0b7
|
@ -214,7 +214,6 @@ class API:
|
||||||
if not os.path.exists('data/blocks/' + data + '.db'):
|
if not os.path.exists('data/blocks/' + data + '.db'):
|
||||||
block = Block(data.encode(), core=self._core)
|
block = Block(data.encode(), core=self._core)
|
||||||
resp = base64.b64encode(block.getRaw().encode()).decode()
|
resp = base64.b64encode(block.getRaw().encode()).decode()
|
||||||
|
|
||||||
if len(resp) == 0:
|
if len(resp) == 0:
|
||||||
abort(404)
|
abort(404)
|
||||||
resp = ""
|
resp = ""
|
||||||
|
|
|
@ -32,6 +32,7 @@ import onionrutils
|
||||||
from onionrutils import OnionrUtils
|
from onionrutils import OnionrUtils
|
||||||
from netcontroller import NetController
|
from netcontroller import NetController
|
||||||
from onionrblockapi import Block
|
from onionrblockapi import Block
|
||||||
|
import onionrproofs
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib3.contrib.socks import SOCKSProxyManager
|
from urllib3.contrib.socks import SOCKSProxyManager
|
||||||
|
@ -359,14 +360,31 @@ class Onionr:
|
||||||
'''
|
'''
|
||||||
Adds a peer (?)
|
Adds a peer (?)
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
newPeer = sys.argv[2]
|
newPeer = sys.argv[2]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
if self.onionrUtils.hasKey(newPeer):
|
||||||
|
logger.info('We already have that key')
|
||||||
|
return
|
||||||
|
if not '-' in newPeer:
|
||||||
|
logger.info('Since no POW token was supplied for that key, one is being generated')
|
||||||
|
proof = onionrproofs.POW(newPeer)
|
||||||
|
while True:
|
||||||
|
result = proof.getResult()
|
||||||
|
if result == False:
|
||||||
|
time.sleep(0.5)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
newPeer += '-' + base64.b64encode(result[1]).decode()
|
||||||
|
logger.info(newPeer)
|
||||||
|
|
||||||
logger.info("Adding peer: " + logger.colors.underline + newPeer)
|
logger.info("Adding peer: " + logger.colors.underline + newPeer)
|
||||||
self.onionrCore.addPeer(newPeer)
|
if self.onionrUtils.mergeKeys(newPeer):
|
||||||
|
logger.info('Successfully added key')
|
||||||
|
else:
|
||||||
|
logger.error('Failed to add key')
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -578,12 +596,14 @@ class Onionr:
|
||||||
# define stats messages here
|
# define stats messages here
|
||||||
totalBlocks = len(Block.getBlocks())
|
totalBlocks = len(Block.getBlocks())
|
||||||
signedBlocks = len(Block.getBlocks(signed = True))
|
signedBlocks = len(Block.getBlocks(signed = True))
|
||||||
|
powToken = self.onionrCore._crypto.pubKeyPowToken
|
||||||
messages = {
|
messages = {
|
||||||
# info about local client
|
# info about local client
|
||||||
'Onionr Daemon Status' : ((logger.colors.fg.green + 'Online') if self.onionrUtils.isCommunicatorRunning(timeout = 2) else logger.colors.fg.red + 'Offline'),
|
'Onionr Daemon Status' : ((logger.colors.fg.green + 'Online') if self.onionrUtils.isCommunicatorRunning(timeout = 2) else logger.colors.fg.red + 'Offline'),
|
||||||
'Public Key' : self.onionrCore._crypto.pubKey,
|
'Public Key' : self.onionrCore._crypto.pubKey,
|
||||||
'Address' : self.get_hostname(),
|
'POW Token' : powToken,
|
||||||
|
'Combined' : self.onionrCore._crypto.pubKey + '-' + powToken,
|
||||||
|
'Node Address' : self.get_hostname(),
|
||||||
|
|
||||||
# file and folder size stats
|
# file and folder size stats
|
||||||
'div1' : True, # this creates a solid line across the screen, a div
|
'div1' : True, # this creates a solid line across the screen, a div
|
||||||
|
|
|
@ -122,8 +122,9 @@ class OnionrUtils:
|
||||||
if not key[0] in self._core.listPeers(randomOrder=False) and type(key) != None and key[0] != self._core._crypto.pubKey:
|
if not key[0] in self._core.listPeers(randomOrder=False) and type(key) != None and key[0] != self._core._crypto.pubKey:
|
||||||
if self._core.addPeer(key[0], key[1]):
|
if self._core.addPeer(key[0], key[1]):
|
||||||
retVal = True
|
retVal = True
|
||||||
|
else:
|
||||||
|
logger.warn("Failed to add key")
|
||||||
else:
|
else:
|
||||||
logger.warn(powHash)
|
|
||||||
logger.warn('%s pow failed' % key[0])
|
logger.warn('%s pow failed' % key[0])
|
||||||
return retVal
|
return retVal
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|
Loading…
Reference in New Issue