2019-12-20 08:34:52 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-07-12 07:07:30 +00:00
|
|
|
|
2019-12-20 08:34:52 +00:00
|
|
|
This file registers blueprints for the private api server
|
|
|
|
"""
|
2020-02-01 04:57:53 +00:00
|
|
|
from threading import Thread
|
2020-01-02 02:07:34 +00:00
|
|
|
from gevent import sleep
|
|
|
|
|
2020-11-13 08:17:48 +00:00
|
|
|
from httpapi import security, friendsapi, configapi, insertblock
|
2019-12-20 08:34:52 +00:00
|
|
|
from httpapi import miscclientapi, onionrsitesapi, apiutils
|
|
|
|
from httpapi import themeapi
|
2020-10-17 07:51:28 +00:00
|
|
|
from httpapi import fileoffsetreader
|
2020-01-14 08:29:42 +00:00
|
|
|
from httpapi.sse.private import private_sse_blueprint
|
2021-01-27 18:15:06 +00:00
|
|
|
from httpapi.serializedapi import serialized_api_bp
|
2019-12-20 08:34:52 +00:00
|
|
|
"""
|
2021-01-27 18:15:06 +00:00
|
|
|
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/>.
|
2019-12-20 08:34:52 +00:00
|
|
|
"""
|
|
|
|
|
2019-10-05 23:35:40 +00:00
|
|
|
|
2019-07-12 07:07:30 +00:00
|
|
|
def register_private_blueprints(private_api, app):
|
2019-12-20 08:34:52 +00:00
|
|
|
"""Register private API plask blueprints."""
|
|
|
|
app.register_blueprint(security.client.ClientAPISecurity(
|
|
|
|
private_api).client_api_security_bp)
|
2019-07-12 07:07:30 +00:00
|
|
|
app.register_blueprint(friendsapi.friends)
|
|
|
|
app.register_blueprint(configapi.config_BP)
|
|
|
|
app.register_blueprint(insertblock.ib)
|
|
|
|
app.register_blueprint(miscclientapi.getblocks.client_get_blocks)
|
2019-12-20 08:34:52 +00:00
|
|
|
app.register_blueprint(miscclientapi.endpoints.PrivateEndpoints(
|
|
|
|
private_api).private_endpoints_bp)
|
2019-10-08 02:32:33 +00:00
|
|
|
app.register_blueprint(miscclientapi.motd.bp)
|
2019-07-12 07:07:30 +00:00
|
|
|
app.register_blueprint(onionrsitesapi.site_api)
|
2019-07-12 18:47:50 +00:00
|
|
|
app.register_blueprint(apiutils.shutdown.shutdown_bp)
|
|
|
|
app.register_blueprint(miscclientapi.staticfiles.static_files_bp)
|
2019-10-05 23:35:40 +00:00
|
|
|
app.register_blueprint(themeapi.theme_blueprint)
|
2020-01-14 08:29:42 +00:00
|
|
|
app.register_blueprint(private_sse_blueprint)
|
2020-10-17 07:51:28 +00:00
|
|
|
app.register_blueprint(fileoffsetreader.offset_reader_api)
|
2021-01-27 18:15:06 +00:00
|
|
|
app.register_blueprint(serialized_api_bp)
|
2020-01-02 02:07:34 +00:00
|
|
|
|
|
|
|
def _add_events_bp():
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
private_api._too_many
|
|
|
|
break
|
|
|
|
except AttributeError:
|
|
|
|
sleep(0.2)
|
|
|
|
app.register_blueprint(
|
|
|
|
private_api._too_many.get_by_string('DaemonEventsBP').flask_bp)
|
|
|
|
|
2020-02-01 04:57:53 +00:00
|
|
|
Thread(target=_add_events_bp).start()
|
|
|
|
|
2019-12-20 08:34:52 +00:00
|
|
|
return app
|