improved formatting in miscclient endpoints
This commit is contained in:
parent
b17834d814
commit
ef25377e15
@ -1,9 +1,23 @@
|
|||||||
'''
|
"""Onionr - Private P2P Communication.
|
||||||
Onionr - Private P2P Communication
|
|
||||||
|
|
||||||
Misc client API endpoints too small to need their own file and that need access to the client api inst
|
Misc client API endpoints too small to need their own file and that need access to the client api inst
|
||||||
'''
|
"""
|
||||||
'''
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from flask import Response, Blueprint, request, send_from_directory, abort
|
||||||
|
import unpaddedbase32
|
||||||
|
|
||||||
|
from httpapi import apiutils
|
||||||
|
import onionrcrypto
|
||||||
|
import config
|
||||||
|
from netcontroller import NetController
|
||||||
|
from onionrstatistics.serializeddata import SerializedData
|
||||||
|
from onionrutils import mnemonickeys
|
||||||
|
from onionrutils import bytesconverter
|
||||||
|
from etc import onionrvalues
|
||||||
|
from utils import reconstructhash
|
||||||
|
"""
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -16,26 +30,12 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
"""
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from flask import Response, Blueprint, request, send_from_directory, abort
|
|
||||||
import unpaddedbase32
|
|
||||||
|
|
||||||
from httpapi import apiutils
|
|
||||||
import onionrcrypto, config
|
|
||||||
from netcontroller import NetController
|
|
||||||
from onionrstatistics.serializeddata import SerializedData
|
|
||||||
from onionrutils import mnemonickeys
|
|
||||||
from onionrutils import bytesconverter
|
|
||||||
from etc import onionrvalues
|
|
||||||
from utils import reconstructhash
|
|
||||||
from onionrcommands import restartonionr
|
|
||||||
|
|
||||||
pub_key = onionrcrypto.pub_key.replace('=', '')
|
pub_key = onionrcrypto.pub_key.replace('=', '')
|
||||||
|
|
||||||
SCRIPT_NAME = os.path.dirname(os.path.realpath(__file__)) + f'/../../../{onionrvalues.SCRIPT_NAME}'
|
SCRIPT_NAME = os.path.dirname(os.path.realpath(__file__)) + \
|
||||||
|
f'/../../../{onionrvalues.SCRIPT_NAME}'
|
||||||
|
|
||||||
class PrivateEndpoints:
|
class PrivateEndpoints:
|
||||||
def __init__(self, client_api):
|
def __init__(self, client_api):
|
||||||
@ -62,9 +62,13 @@ class PrivateEndpoints:
|
|||||||
return Response(str(client_api.publicAPI.lastRequest))
|
return Response(str(client_api.publicAPI.lastRequest))
|
||||||
|
|
||||||
@private_endpoints_bp.route('/waitforshare/<name>', methods=['post'])
|
@private_endpoints_bp.route('/waitforshare/<name>', methods=['post'])
|
||||||
def waitforshare(name):
|
def wait_for_share(name):
|
||||||
'''Used to prevent the **public** api from sharing blocks we just created'''
|
"""Prevent the **public** api from sharing blocks.
|
||||||
if not name.isalnum(): raise ValueError('block hash needs to be alpha numeric')
|
|
||||||
|
Used for blocks we created usually
|
||||||
|
"""
|
||||||
|
if not name.isalnum():
|
||||||
|
raise ValueError('block hash needs to be alpha numeric')
|
||||||
name = reconstructhash.reconstruct_hash(name)
|
name = reconstructhash.reconstruct_hash(name)
|
||||||
if name in client_api.publicAPI.hideBlocks:
|
if name in client_api.publicAPI.hideBlocks:
|
||||||
client_api.publicAPI.hideBlocks.remove(name)
|
client_api.publicAPI.hideBlocks.remove(name)
|
||||||
@ -87,12 +91,13 @@ class PrivateEndpoints:
|
|||||||
return Response('\n'.join(client_api.publicAPI.hideBlocks))
|
return Response('\n'.join(client_api.publicAPI.hideBlocks))
|
||||||
|
|
||||||
@private_endpoints_bp.route('/getstats')
|
@private_endpoints_bp.route('/getstats')
|
||||||
def getStats():
|
def get_stats():
|
||||||
# returns node stats
|
"""Return serialized node statistics."""
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return Response(client_api._too_many.get(SerializedData).get_stats())
|
return Response(client_api._too_many.get(
|
||||||
except AttributeError as e:
|
SerializedData).get_stats())
|
||||||
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@private_endpoints_bp.route('/getuptime')
|
@private_endpoints_bp.route('/getuptime')
|
||||||
|
Loading…
Reference in New Issue
Block a user