added mixmate to improve base routing
This commit is contained in:
parent
f71f2f6246
commit
9329b07e3b
15 changed files with 273 additions and 67 deletions
|
@ -57,7 +57,7 @@ class PrivateEndpoints:
|
|||
# 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
|
||||
|
@ -72,7 +72,7 @@ class PrivateEndpoints:
|
|||
return resp, 404
|
||||
else:
|
||||
return resp
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/ping')
|
||||
def ping():
|
||||
# Used to check if client api is working
|
||||
|
@ -102,24 +102,24 @@ class PrivateEndpoints:
|
|||
def restart_clean():
|
||||
subprocess.Popen([SCRIPT_NAME, 'restart'])
|
||||
return Response("bye")
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/gethidden')
|
||||
def get_hidden_blocks():
|
||||
return Response('\n'.join(client_api.publicAPI.hideBlocks))
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/getstats')
|
||||
def getStats():
|
||||
# returns node stats
|
||||
while True:
|
||||
try:
|
||||
try:
|
||||
return Response(client_api._too_many.get(SerializedData).get_stats())
|
||||
except AttributeError as e:
|
||||
pass
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/getuptime')
|
||||
def showUptime():
|
||||
return Response(str(client_api.getUptime()))
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/getActivePubkey')
|
||||
def getActivePubkey():
|
||||
return Response(pub_key)
|
||||
|
@ -132,7 +132,7 @@ class PrivateEndpoints:
|
|||
def getHumanReadable(name):
|
||||
name = unpaddedbase32.repad(bytesconverter.str_to_bytes(name))
|
||||
return Response(mnemonickeys.get_human_readable_ID(name))
|
||||
|
||||
|
||||
@private_endpoints_bp.route('/getBase32FromHumanReadable/<words>')
|
||||
def get_base32_from_human_readable(words):
|
||||
return Response(bytesconverter.bytes_to_str(mnemonickeys.get_base32(words)))
|
||||
|
@ -144,3 +144,4 @@ class PrivateEndpoints:
|
|||
@private_endpoints_bp.route('/setonboarding', methods=['POST'])
|
||||
def set_onboarding():
|
||||
return Response(config.onboarding.set_config_from_onboarding(request.get_json()))
|
||||
|
||||
|
|
|
@ -3,10 +3,14 @@
|
|||
|
||||
Accept block uploads to the public API server
|
||||
'''
|
||||
from gevent import threading
|
||||
|
||||
import sys
|
||||
from flask import Response
|
||||
from flask import abort
|
||||
|
||||
from onionrutils import localcommand
|
||||
from coredb import daemonqueue
|
||||
from onionrblocks import blockimporter
|
||||
import onionrexceptions
|
||||
import logger
|
||||
|
@ -31,9 +35,12 @@ def accept_upload(request):
|
|||
"""Accept uploaded blocks to our public Onionr protocol API server"""
|
||||
resp = 'failure'
|
||||
data = request.get_data()
|
||||
b_hash = ''
|
||||
if sys.getsizeof(data) < 100000000:
|
||||
try:
|
||||
if blockimporter.import_block_from_data(data):
|
||||
b_hash = blockimporter.import_block_from_data(data)
|
||||
if b_hash:
|
||||
daemonqueue.daemon_queue_add('uploadEvent', b_hash)
|
||||
resp = 'success'
|
||||
else:
|
||||
resp = 'failure'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue