improved api-communicator integration, panel
This commit is contained in:
parent
d2e7ced776
commit
a9e61e2827
@ -256,7 +256,7 @@ class API:
|
|||||||
|
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self._privateDelayTime = 3
|
self._privateDelayTime = 3
|
||||||
self._core = core.Core()
|
self._core = onionrInst.onionrCore
|
||||||
self.startTime = self._core._utils.getEpoch()
|
self.startTime = self._core._utils.getEpoch()
|
||||||
self._crypto = onionrcrypto.OnionrCrypto(self._core)
|
self._crypto = onionrcrypto.OnionrCrypto(self._core)
|
||||||
self._utils = onionrutils.OnionrUtils(self._core)
|
self._utils = onionrutils.OnionrUtils(self._core)
|
||||||
|
@ -40,7 +40,7 @@ class OnionrCommunicatorDaemon:
|
|||||||
|
|
||||||
# initalize core with Tor socks port being 3rd argument
|
# initalize core with Tor socks port being 3rd argument
|
||||||
self.proxyPort = proxyPort
|
self.proxyPort = proxyPort
|
||||||
self._core = core.Core(torPort=self.proxyPort)
|
self._core = onionrInst.onionrCore
|
||||||
|
|
||||||
# intalize NIST beacon salt and time
|
# intalize NIST beacon salt and time
|
||||||
self.nistSaltTimestamp = 0
|
self.nistSaltTimestamp = 0
|
||||||
@ -93,7 +93,6 @@ class OnionrCommunicatorDaemon:
|
|||||||
self.startTime = self._core._utils.getEpoch()
|
self.startTime = self._core._utils.getEpoch()
|
||||||
|
|
||||||
if developmentMode:
|
if developmentMode:
|
||||||
print('enabling heartbeat')
|
|
||||||
OnionrCommunicatorTimers(self, self.heartbeat, 30)
|
OnionrCommunicatorTimers(self, self.heartbeat, 30)
|
||||||
|
|
||||||
# Set timers, function reference, seconds
|
# Set timers, function reference, seconds
|
||||||
@ -485,10 +484,12 @@ class OnionrCommunicatorDaemon:
|
|||||||
retData = onionrpeers.PeerProfiles(peer, self._core)
|
retData = onionrpeers.PeerProfiles(peer, self._core)
|
||||||
return retData
|
return retData
|
||||||
|
|
||||||
|
def getUptime(self):
|
||||||
|
return self._core._utils.getEpoch() - self.startTime
|
||||||
|
|
||||||
def heartbeat(self):
|
def heartbeat(self):
|
||||||
'''Show a heartbeat debug message'''
|
'''Show a heartbeat debug message'''
|
||||||
currentTime = self._core._utils.getEpoch() - self.startTime
|
logger.debug('Heartbeat. Node running for %s.' % self.daemonTools.humanReadableTime(self.getUptime()))
|
||||||
logger.debug('Heartbeat. Node running for %s.' % self.daemonTools.humanReadableTime(currentTime))
|
|
||||||
self.decrementThreadCount('heartbeat')
|
self.decrementThreadCount('heartbeat')
|
||||||
|
|
||||||
def daemonCommands(self):
|
def daemonCommands(self):
|
||||||
|
@ -45,6 +45,7 @@ class Core:
|
|||||||
self.dataDir = 'data/'
|
self.dataDir = 'data/'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
self.onionrInst = None
|
||||||
self.queueDB = self.dataDir + 'queue.db'
|
self.queueDB = self.dataDir + 'queue.db'
|
||||||
self.peerDB = self.dataDir + 'peers.db'
|
self.peerDB = self.dataDir + 'peers.db'
|
||||||
self.blockDB = self.dataDir + 'blocks.db'
|
self.blockDB = self.dataDir + 'blocks.db'
|
||||||
|
@ -74,6 +74,7 @@ class Onionr:
|
|||||||
|
|
||||||
self.communicatorInst = None
|
self.communicatorInst = None
|
||||||
self.onionrCore = core.Core()
|
self.onionrCore = core.Core()
|
||||||
|
self.onionrCore.onionrInst = self
|
||||||
#self.deleteRunFiles()
|
#self.deleteRunFiles()
|
||||||
self.onionrUtils = onionrutils.OnionrUtils(self.onionrCore)
|
self.onionrUtils = onionrutils.OnionrUtils(self.onionrCore)
|
||||||
|
|
||||||
@ -751,7 +752,7 @@ class Onionr:
|
|||||||
|
|
||||||
# TODO: make runable on windows
|
# TODO: make runable on windows
|
||||||
#communicatorProc = subprocess.Popen([communicatorDaemon, 'run', str(net.socksPort)])
|
#communicatorProc = subprocess.Popen([communicatorDaemon, 'run', str(net.socksPort)])
|
||||||
|
self.onionrCore.torPort = net.socksPort
|
||||||
communicatorThread = Thread(target=communicator2.startCommunicator, args=(self, str(net.socksPort)))
|
communicatorThread = Thread(target=communicator2.startCommunicator, args=(self, str(net.socksPort)))
|
||||||
communicatorThread.start()
|
communicatorThread.start()
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class SerializedData:
|
|||||||
def getStats(self):
|
def getStats(self):
|
||||||
'''Return statistics about our node'''
|
'''Return statistics about our node'''
|
||||||
stats = {}
|
stats = {}
|
||||||
stats['uptime'] = int(self._core.daemonQueueSimple('localCommand', 'getuptime'))
|
stats['uptime'] = self._core.onionrInst.communicatorInst.getUptime()
|
||||||
stats['connectedNodes'] = self._core.daemonQueueSimple('connectedPeers')
|
stats['connectedNodes'] = '\n'.join(self._core.onionrInst.communicatorInst.onlinePeers)
|
||||||
stats['blockCount'] = len(self._core.getBlockList())
|
stats['blockCount'] = len(self._core.getBlockList())
|
||||||
return json.dumps(stats)
|
return json.dumps(stats)
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
|
<img class='logo' src='/shared/onionr-icon.png' alt='onionr logo'>
|
||||||
<span class='logoText'>Onionr Web Control Panel</span>
|
<span class='logoText'>Onionr Web Control Panel</span>
|
||||||
<div class='content'>
|
<div class='content'>
|
||||||
<button id='shutdownNode'>Shutdown Node</button>
|
<button id='shutdownNode'>Shutdown Node</button> <button id='refreshStats'>Refresh Stats</button>
|
||||||
<h2>Stats</h2>
|
<h2>Stats</h2>
|
||||||
<p>Uptime: <span id='uptime'></span></p>
|
<p>Uptime: <span id='uptime'></span></p>
|
||||||
<p>Stored Blocks: <span id='storedBlocks'></span></p>
|
<p>Stored Blocks: <span id='storedBlocks'></span></p>
|
||||||
|
@ -21,7 +21,10 @@ uptimeDisplay = document.getElementById('uptime')
|
|||||||
connectedDisplay = document.getElementById('connectedNodes')
|
connectedDisplay = document.getElementById('connectedNodes')
|
||||||
storedBlockDisplay = document.getElementById('storedBlocks')
|
storedBlockDisplay = document.getElementById('storedBlocks')
|
||||||
|
|
||||||
stats = JSON.parse(httpGet('getstats', webpass))
|
function getStats(){
|
||||||
uptimeDisplay.innerText = stats['uptime'] + ' seconds'
|
stats = JSON.parse(httpGet('getstats', webpass))
|
||||||
connectedDisplay.innerText = stats['connectedNodes']
|
uptimeDisplay.innerText = stats['uptime'] + ' seconds'
|
||||||
storedBlockDisplay.innerText = stats['blockCount']
|
connectedDisplay.innerText = stats['connectedNodes']
|
||||||
|
storedBlockDisplay.innerText = stats['blockCount']
|
||||||
|
}
|
||||||
|
getStats()
|
@ -1,8 +1,12 @@
|
|||||||
shutdownBtn = document.getElementById('shutdownNode')
|
shutdownBtn = document.getElementById('shutdownNode')
|
||||||
|
refreshStatsBtn = document.getElementById('refreshStats')
|
||||||
shutdownBtn.onclick = function(){
|
shutdownBtn.onclick = function(){
|
||||||
if (! nowebpass){
|
if (! nowebpass){
|
||||||
httpGet('shutdownclean')
|
httpGet('shutdownclean')
|
||||||
overlay('shutdownNotice')
|
overlay('shutdownNotice')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshStatsBtn.onclick = function(){
|
||||||
|
getStats()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user