Merge branch 'new-ui-refactorinsert' of github.com:EgosOwn/onionr into new-ui-refactorinsert
commit
cf0d27e85b
|
@ -18,6 +18,9 @@ core
|
||||||
venv/*
|
venv/*
|
||||||
onionr/fs*
|
onionr/fs*
|
||||||
|
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
|
||||||
# log files
|
# log files
|
||||||
output.log
|
output.log
|
||||||
*.log
|
*.log
|
||||||
|
|
|
@ -105,96 +105,11 @@ class API:
|
||||||
app.register_blueprint(insertblock.ib)
|
app.register_blueprint(insertblock.ib)
|
||||||
app.register_blueprint(miscclientapi.getblocks.client_get_blocks)
|
app.register_blueprint(miscclientapi.getblocks.client_get_blocks)
|
||||||
app.register_blueprint(miscclientapi.staticfiles.static_files_bp)
|
app.register_blueprint(miscclientapi.staticfiles.static_files_bp)
|
||||||
|
app.register_blueprint(miscclientapi.endpoints.PrivateEndpoints(self).private_endpoints_bp)
|
||||||
app.register_blueprint(onionrsitesapi.site_api)
|
app.register_blueprint(onionrsitesapi.site_api)
|
||||||
app.register_blueprint(apiutils.shutdown.shutdown_bp)
|
app.register_blueprint(apiutils.shutdown.shutdown_bp)
|
||||||
httpapi.load_plugin_blueprints(app)
|
httpapi.load_plugin_blueprints(app)
|
||||||
self.get_block_data = apiutils.GetBlockData(self)
|
self.get_block_data = apiutils.GetBlockData(self)
|
||||||
|
|
||||||
@app.route('/serviceactive/<pubkey>')
|
|
||||||
def serviceActive(pubkey):
|
|
||||||
try:
|
|
||||||
if pubkey in self._core.onionrInst.communicatorInst.active_services:
|
|
||||||
return Response('true')
|
|
||||||
except AttributeError as e:
|
|
||||||
pass
|
|
||||||
return Response('false')
|
|
||||||
|
|
||||||
@app.route('/www/<path:path>', endpoint='www')
|
|
||||||
def wwwPublic(path):
|
|
||||||
if not config.get("www.private.run", True):
|
|
||||||
abort(403)
|
|
||||||
return send_from_directory(config.get('www.private.path', 'static-data/www/private/'), path)
|
|
||||||
|
|
||||||
@app.route('/hitcount')
|
|
||||||
def get_hit_count():
|
|
||||||
return Response(str(self.publicAPI.hitCount))
|
|
||||||
|
|
||||||
@app.route('/queueResponseAdd/<name>', methods=['post'])
|
|
||||||
def queueResponseAdd(name):
|
|
||||||
# Responses from the daemon. TODO: change to direct var access instead of http endpoint
|
|
||||||
self.queueResponse[name] = request.form['data']
|
|
||||||
return Response('success')
|
|
||||||
|
|
||||||
@app.route('/queueResponse/<name>')
|
|
||||||
def queueResponse(name):
|
|
||||||
# Fetch a daemon queue response
|
|
||||||
resp = 'failure'
|
|
||||||
try:
|
|
||||||
resp = self.queueResponse[name]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
del self.queueResponse[name]
|
|
||||||
if resp == 'failure':
|
|
||||||
return resp, 404
|
|
||||||
else:
|
|
||||||
return resp
|
|
||||||
|
|
||||||
@app.route('/ping')
|
|
||||||
def ping():
|
|
||||||
# Used to check if client api is working
|
|
||||||
return Response("pong!")
|
|
||||||
|
|
||||||
@app.route('/lastconnect')
|
|
||||||
def lastConnect():
|
|
||||||
return Response(str(self.publicAPI.lastRequest))
|
|
||||||
|
|
||||||
@app.route('/waitforshare/<name>', methods=['post'])
|
|
||||||
def waitforshare(name):
|
|
||||||
'''Used to prevent the **public** api from sharing blocks we just created'''
|
|
||||||
assert name.isalnum()
|
|
||||||
if name in self.publicAPI.hideBlocks:
|
|
||||||
self.publicAPI.hideBlocks.remove(name)
|
|
||||||
return Response("removed")
|
|
||||||
else:
|
|
||||||
self.publicAPI.hideBlocks.append(name)
|
|
||||||
return Response("added")
|
|
||||||
|
|
||||||
@app.route('/shutdown')
|
|
||||||
def shutdown():
|
|
||||||
return apiutils.shutdown.shutdown(self)
|
|
||||||
|
|
||||||
@app.route('/getstats')
|
|
||||||
def getStats():
|
|
||||||
# returns node stats
|
|
||||||
#return Response("disabled")
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
return Response(self._core.serializer.getStats())
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@app.route('/getuptime')
|
|
||||||
def showUptime():
|
|
||||||
return Response(str(self.getUptime()))
|
|
||||||
|
|
||||||
@app.route('/getActivePubkey')
|
|
||||||
def getActivePubkey():
|
|
||||||
return Response(self._core._crypto.pubKey)
|
|
||||||
|
|
||||||
@app.route('/getHumanReadable/<name>')
|
|
||||||
def getHumanReadable(name):
|
|
||||||
return Response(mnemonickeys.get_human_readable_ID(name))
|
|
||||||
|
|
||||||
self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=fdsafehandler.FDSafeHandler)
|
self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=fdsafehandler.FDSafeHandler)
|
||||||
self.httpServer.serve_forever()
|
self.httpServer.serve_forever()
|
||||||
|
@ -227,4 +142,4 @@ class API:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getBlockData(self, bHash, decrypt=False, raw=False, headerOnly=False):
|
def getBlockData(self, bHash, decrypt=False, raw=False, headerOnly=False):
|
||||||
return self.get_block_data.get_block_data(self, bHash, decrypt, raw, headerOnly)
|
return self.get_block_data.get_block_data(bHash, decrypt=decrypt, raw=raw, headerOnly=headerOnly)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
from . import getblocks, staticfiles
|
from . import getblocks, staticfiles, endpoints
|
|
@ -0,0 +1,112 @@
|
||||||
|
'''
|
||||||
|
Onionr - Private P2P Communication
|
||||||
|
|
||||||
|
Misc client API endpoints too small to need their own file and that need access to the client api inst
|
||||||
|
'''
|
||||||
|
'''
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
'''
|
||||||
|
from flask import Response, Blueprint, request, send_from_directory, abort
|
||||||
|
from httpapi import apiutils
|
||||||
|
class PrivateEndpoints:
|
||||||
|
def __init__(self, client_api):
|
||||||
|
private_endpoints_bp = Blueprint('privateendpoints', __name__)
|
||||||
|
self.private_endpoints_bp = private_endpoints_bp
|
||||||
|
config = client_api._core.config
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/serviceactive/<pubkey>')
|
||||||
|
def serviceActive(pubkey):
|
||||||
|
try:
|
||||||
|
if pubkey in client_api._core.onionrInst.communicatorInst.active_services:
|
||||||
|
return Response('true')
|
||||||
|
except AttributeError as e:
|
||||||
|
pass
|
||||||
|
return Response('false')
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/www/<path:path>', endpoint='www')
|
||||||
|
def wwwPublic(path):
|
||||||
|
if not config.get("www.private.run", True):
|
||||||
|
abort(403)
|
||||||
|
return send_from_directory(config.get('www.private.path', 'static-data/www/private/'), path)
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/hitcount')
|
||||||
|
def get_hit_count():
|
||||||
|
return Response(str(client_api.publicAPI.hitCount))
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/queueResponseAdd/<name>', methods=['post'])
|
||||||
|
def queueResponseAdd(name):
|
||||||
|
# Responses from the daemon. TODO: change to direct var access instead of http endpoint
|
||||||
|
client_api.queueResponse[name] = request.form['data']
|
||||||
|
return Response('success')
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/queueResponse/<name>')
|
||||||
|
def queueResponse(name):
|
||||||
|
# Fetch a daemon queue response
|
||||||
|
resp = 'failure'
|
||||||
|
try:
|
||||||
|
resp = client_api.queueResponse[name]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
del client_api.queueResponse[name]
|
||||||
|
if resp == 'failure':
|
||||||
|
return resp, 404
|
||||||
|
else:
|
||||||
|
return resp
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/ping')
|
||||||
|
def ping():
|
||||||
|
# Used to check if client api is working
|
||||||
|
return Response("pong!")
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/lastconnect')
|
||||||
|
def lastConnect():
|
||||||
|
return Response(str(client_api.publicAPI.lastRequest))
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/waitforshare/<name>', methods=['post'])
|
||||||
|
def waitforshare(name):
|
||||||
|
'''Used to prevent the **public** api from sharing blocks we just created'''
|
||||||
|
assert name.isalnum()
|
||||||
|
if name in client_api.publicAPI.hideBlocks:
|
||||||
|
client_api.publicAPI.hideBlocks.remove(name)
|
||||||
|
return Response("removed")
|
||||||
|
else:
|
||||||
|
client_api.publicAPI.hideBlocks.private_endpoints_bpend(name)
|
||||||
|
return Response("added")
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/shutdown')
|
||||||
|
def shutdown():
|
||||||
|
return apiutils.shutdown.shutdown(client_api)
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/getstats')
|
||||||
|
def getStats():
|
||||||
|
# returns node stats
|
||||||
|
#return Response("disabled")
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return Response(client_api._core.serializer.getStats())
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/getuptime')
|
||||||
|
def showUptime():
|
||||||
|
return Response(str(client_api.getUptime()))
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/getActivePubkey')
|
||||||
|
def getActivePubkey():
|
||||||
|
return Response(client_api._core._crypto.pubKey)
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/getHumanReadable/<name>')
|
||||||
|
def getHumanReadable(name):
|
||||||
|
return Response(mnemonickeys.get_human_readable_ID(name))
|
|
@ -38,12 +38,12 @@ class PublicEndpoints:
|
||||||
|
|
||||||
@public_endpoints_bp.route('/getblocklist')
|
@public_endpoints_bp.route('/getblocklist')
|
||||||
def get_block_list():
|
def get_block_list():
|
||||||
return getblocks.public_block_list(client_API, public_api, request)
|
return getblocks.get_public_block_list(client_API, public_api, request)
|
||||||
|
|
||||||
@public_endpoints_bp.route('/getdata/<name>')
|
@public_endpoints_bp.route('/getdata/<name>')
|
||||||
def get_block_data(name):
|
def get_block_data(name):
|
||||||
# Share data for a block if we have it
|
# Share data for a block if we have it
|
||||||
return getblocks.public_get_block_data(client_API, public_api, name)
|
return getblocks.get_block_data(client_API, public_api, name)
|
||||||
|
|
||||||
@public_endpoints_bp.route('/www/<path:path>')
|
@public_endpoints_bp.route('/www/<path:path>')
|
||||||
def www_public(path):
|
def www_public(path):
|
||||||
|
@ -66,7 +66,7 @@ class PublicEndpoints:
|
||||||
|
|
||||||
@public_endpoints_bp.route('/announce', methods=['post'])
|
@public_endpoints_bp.route('/announce', methods=['post'])
|
||||||
def accept_announce():
|
def accept_announce():
|
||||||
resp = httpapi.miscpublicapi.announce(client_API, request)
|
resp = announce.handle_announce(client_API, request)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@public_endpoints_bp.route('/upload', methods=['post'])
|
@public_endpoints_bp.route('/upload', methods=['post'])
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item idLink" href="/">
|
<a class="navbar-item idLink" href="/">
|
||||||
<img src="/shared/images/favicon.ico" class="navabarLogo"> Onionr
|
<img src="/shared/images/favicon.ico" class="navbarLogo"> Onionr
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item idLink" href="/">
|
<a class="navbar-item idLink" href="/">
|
||||||
<img src="/shared/images/favicon.ico" class="navabarLogo"> Onionr
|
<img src="/shared/images/favicon.ico" class="navbarLogo"> Onionr
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
<nav class="navbar is-dark" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item idLink" href="/">
|
<a class="navbar-item idLink" href="/">
|
||||||
<img src="/shared/images/favicon.ico" class="navabarLogo"> Onionr
|
<img src="/shared/images/favicon.ico" class="navbarLogo"> Onionr
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
<!--Start of content-->
|
<!--Start of content-->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="tabs">
|
<div class="tabs" id="tabBtns">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="is-active">
|
<li class="is-active">
|
||||||
<a>
|
<a>
|
||||||
|
@ -112,9 +112,6 @@
|
||||||
<div class='mailPing'>
|
<div class='mailPing'>
|
||||||
API server either shutdown, has disabled mail, or has experienced a bug.
|
API server either shutdown, has disabled mail, or has experienced a bug.
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" id='tabBtns'>
|
|
||||||
<button class='activeTab'>Inbox</button><button>Sentbox</button><button>Send Message</button>
|
|
||||||
</div>
|
|
||||||
<div id='threads' class='threads'>
|
<div id='threads' class='threads'>
|
||||||
<div id='threadPlaceholder'>Nothing here yet 😞</div>
|
<div id='threadPlaceholder'>Nothing here yet 😞</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,7 +156,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src='/shared/misc.js'></script>
|
<script src='/shared/misc.js'></script>
|
||||||
<script src='/shared/tabs.js'></script>
|
|
||||||
<script src='/mail/mail.js'></script>
|
<script src='/mail/mail.js'></script>
|
||||||
<script src='/mail/sendmail.js'></script>
|
<script src='/mail/sendmail.js'></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -110,10 +110,10 @@ function setActiveTab(tabName){
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
refreshPms()
|
refreshPms()
|
||||||
break
|
break
|
||||||
case 'sentbox':
|
case 'sent':
|
||||||
getSentbox()
|
getSentbox()
|
||||||
break
|
break
|
||||||
case 'send message':
|
case 'compose':
|
||||||
overlay('sendMessage')
|
overlay('sendMessage')
|
||||||
setActiveTab('inbox')
|
setActiveTab('inbox')
|
||||||
break
|
break
|
||||||
|
@ -320,12 +320,12 @@ fetch('/mail/getinbox', {
|
||||||
}
|
}
|
||||||
|
|
||||||
tabBtns.onclick = function(event){
|
tabBtns.onclick = function(event){
|
||||||
var children = tabBtns.children
|
var children = tabBtns.children[0].children
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
var btn = children[i]
|
var btn = children[i]
|
||||||
btn.classList.remove('activeTab')
|
btn.classList.remove('is-active')
|
||||||
}
|
}
|
||||||
event.target.classList.add('activeTab')
|
event.target.parentElement.parentElement.classList.add('is-active')
|
||||||
setActiveTab(event.target.innerText.toLowerCase())
|
setActiveTab(event.target.innerText.toLowerCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,13 +109,15 @@ for (var i = 0; i < idStrings.length; i++){
|
||||||
myPubCopy.onclick = function() {
|
myPubCopy.onclick = function() {
|
||||||
var copyText = document.getElementById("myPub");
|
var copyText = document.getElementById("myPub");
|
||||||
copyText.select();
|
copyText.select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For Config toggle on homepage */
|
/* For Config toggle on homepage */
|
||||||
var toggle = document.getElementById("configToggle");
|
var toggle = document.getElementById("configToggle");
|
||||||
var content = document.getElementById("configContent");
|
var content = document.getElementById("configContent");
|
||||||
|
|
||||||
toggle.addEventListener("click", function() {
|
if(typeof toggle !== 'undefined' && toggle !== null) {
|
||||||
content.classList.toggle("show");
|
toggle.addEventListener("click", function() {
|
||||||
});
|
content.classList.toggle("show");
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue