progress removing onionr.py

This commit is contained in:
Kevin Froman 2019-08-02 18:00:04 -05:00
parent 6e526bf629
commit a6fec9eefb
13 changed files with 47 additions and 43 deletions

View file

@ -23,7 +23,7 @@ from gevent.pywsgi import WSGIServer
from onionrutils import epoch
import httpapi, filepaths, logger
from . import register_private_blueprints
import serializeddata
import serializeddata, config
class PrivateAPI:
'''
Client HTTP api
@ -31,17 +31,15 @@ class PrivateAPI:
callbacks = {'public' : {}, 'private' : {}}
def __init__(self, onionrInst, debug, API_VERSION):
def __init__(self):
'''
Initialize the api server, preping variables for later use
This initialization defines all of the API entry points and handlers for the endpoints and errors
This also saves the used host (random localhost IP address) to the data folder in host.txt
'''
config = onionrInst.config
self.config = config
self.debug = debug
self.serializer = serializeddata.SerializedData(onionrInst)
self.serializer = serializeddata.SerializedData()
self.startTime = epoch.get_epoch()
app = flask.Flask(__name__)
bindPort = int(config.get('client.client.port', 59496))
@ -55,13 +53,11 @@ class PrivateAPI:
self.host = httpapi.apiutils.setbindip.set_bind_IP(filepaths.private_API_host_file)
logger.info('Running api on %s:%s' % (self.host, self.bindPort))
self.httpServer = ''
onionrInst.setClientAPIInst(self)
self.queueResponse = {}
self.get_block_data = httpapi.apiutils.GetBlockData(self)
register_private_blueprints.register_private_blueprints(self, app)
httpapi.load_plugin_blueprints(app)
self.onionrInst = onionrInst
self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=httpapi.fdsafehandler.FDSafeHandler)
self.httpServer.serve_forever()

View file

@ -21,14 +21,14 @@ import time
import flask
from gevent.pywsgi import WSGIServer
from httpapi import apiutils, security, fdsafehandler, miscpublicapi
import logger, onionr, filepaths
import logger, config, filepaths
from utils import gettransports
from etc import onionrvalues
class PublicAPI:
'''
The new client api server, isolated from the public api
'''
def __init__(self, clientAPI):
config = clientAPI.config
def __init__(self):
app = flask.Flask('PublicAPI')
app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024
self.i2pEnabled = config.get('i2p.host', False)
@ -43,12 +43,9 @@ class PublicAPI:
self.lastRequest = 0
self.hitCount = 0 # total rec requests to public api since server started
self.config = config
self.clientAPI = clientAPI
self.API_VERSION = onionr.API_VERSION
self.API_VERSION = onionrvalues.API_VERSION
logger.info('Running public api on %s:%s' % (self.host, self.bindPort))
# Set instances, then startup our public api server
clientAPI.setPublicAPIInstance(self)
app.register_blueprint(security.public.PublicAPISecurity(self).public_api_security_bp)
app.register_blueprint(miscpublicapi.endpoints.PublicEndpoints(self).public_endpoints_bp)