parent
092233027c
commit
45940b2dba
5 changed files with 66 additions and 2 deletions
14
src/httpapi/miscclientapi/addpeer.py
Normal file
14
src/httpapi/miscclientapi/addpeer.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from onionrutils.stringvalidators import validate_transport
|
||||
from coredb.keydb.addkeys import add_address
|
||||
from coredb.keydb.listkeys import list_adders
|
||||
|
||||
|
||||
def add_peer(peer):
|
||||
# this is ok for security since add_address does this manually
|
||||
assert validate_transport(peer)
|
||||
if peer in list_adders():
|
||||
return "already added"
|
||||
if add_address(peer):
|
||||
return "success"
|
||||
else:
|
||||
return "failure, invalid address"
|
|
@ -20,6 +20,7 @@ from onionrutils import bytesconverter
|
|||
from etc import onionrvalues
|
||||
from utils import reconstructhash
|
||||
from utils.gettransports import get as get_tor
|
||||
from .addpeer import add_peer
|
||||
"""
|
||||
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
|
||||
|
@ -46,6 +47,14 @@ class PrivateEndpoints:
|
|||
private_endpoints_bp = Blueprint('privateendpoints', __name__)
|
||||
self.private_endpoints_bp = private_endpoints_bp
|
||||
|
||||
@private_endpoints_bp.route('/addpeer/<name>', methods=['post'])
|
||||
def add_peer_endpoint(name):
|
||||
result = add_peer(name)
|
||||
if result == "success":
|
||||
return Response("success")
|
||||
else:
|
||||
return Response(result, 409)
|
||||
|
||||
@private_endpoints_bp.route('/www/<path:path>', endpoint='www')
|
||||
def wwwPublic(path):
|
||||
if not config.get("www.private.run", True):
|
||||
|
|
|
@ -205,7 +205,7 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
|
|||
|
||||
# send block data (and metadata) to POW module to get tokenized block data
|
||||
payload = subprocesspow.SubprocessPOW(data, metadata).start()
|
||||
print(payload)
|
||||
|
||||
if payload != False: # noqa
|
||||
try:
|
||||
retData = onionrstorage.set_data(payload)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue