diff --git a/onionr/apiservers/private/__init__.py b/onionr/apiservers/private/__init__.py index 9b9ca66e..7154c9f6 100644 --- a/onionr/apiservers/private/__init__.py +++ b/onionr/apiservers/private/__init__.py @@ -59,7 +59,7 @@ class PrivateAPI: self.queueResponse = {} onionrInst.setClientAPIInst(self) - + register_private_blueprints.register_private_blueprints(self, app) httpapi.load_plugin_blueprints(self, app) self.get_block_data = httpapi.apiutils.GetBlockData(self) diff --git a/onionr/apiservers/private/register_private_blueprints.py b/onionr/apiservers/private/register_private_blueprints.py index b9fa3f3b..c9960b88 100644 --- a/onionr/apiservers/private/register_private_blueprints.py +++ b/onionr/apiservers/private/register_private_blueprints.py @@ -17,15 +17,17 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' +import os from httpapi import security, friendsapi, profilesapi, configapi, insertblock, miscclientapi, onionrsitesapi, apiutils def register_private_blueprints(private_api, app): - app.register_blueprint(security.client.ClientAPISecurity(self).client_api_security_bp) + app.register_blueprint(security.client.ClientAPISecurity(private_api).client_api_security_bp) app.register_blueprint(friendsapi.friends) app.register_blueprint(profilesapi.profile_BP) app.register_blueprint(configapi.config_BP) app.register_blueprint(insertblock.ib) app.register_blueprint(miscclientapi.getblocks.client_get_blocks) - app.register_blueprint(miscclientapi.staticfiles.static_files_bp) - app.register_blueprint(miscclientapi.endpoints.PrivateEndpoints(self).private_endpoints_bp) + app.register_blueprint(miscclientapi.endpoints.PrivateEndpoints(private_api).private_endpoints_bp) app.register_blueprint(onionrsitesapi.site_api) - app.register_blueprint(apiutils.shutdown.shutdown_bp) \ No newline at end of file + app.register_blueprint(apiutils.shutdown.shutdown_bp) + app.register_blueprint(miscclientapi.staticfiles.static_files_bp) + return app \ No newline at end of file diff --git a/onionr/httpapi/miscclientapi/staticfiles.py b/onionr/httpapi/miscclientapi/staticfiles.py index f943d6f1..a89f0cc1 100644 --- a/onionr/httpapi/miscclientapi/staticfiles.py +++ b/onionr/httpapi/miscclientapi/staticfiles.py @@ -17,59 +17,54 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . ''' +import os from flask import Blueprint, send_from_directory static_files_bp = Blueprint('staticfiles', __name__) +root = os.getcwd() + '/static-data/www/' # should be set to onionr install directory from onionr startup + @static_files_bp.route('/board/', endpoint='board') def loadBoard(): - return send_from_directory('static-data/www/board/', "index.html") + return send_from_directory(root + 'board/', "index.html") @static_files_bp.route('/mail/', endpoint='mail') def loadMail(path): - return send_from_directory('static-data/www/mail/', path) + return send_from_directory(root + 'mail/', path) @static_files_bp.route('/mail/', endpoint='mailindex') def loadMailIndex(): - return send_from_directory('static-data/www/mail/', 'index.html') - -@static_files_bp.route('/clandestine/', endpoint='clandestine') -def loadClandestine(path): - return send_from_directory('static-data/www/clandestine/', path) - -@static_files_bp.route('/clandestine/', endpoint='clandestineIndex') -def loadClandestineIndex(): - return send_from_directory('static-data/www/clandestine/', 'index.html') + return send_from_directory(root + 'mail/', 'index.html') @static_files_bp.route('/friends/', endpoint='friends') def loadContacts(path): - return send_from_directory('static-data/www/friends/', path) + return send_from_directory(root + 'friends/', path) @static_files_bp.route('/friends/', endpoint='friendsindex') def loadContacts(): - return send_from_directory('static-data/www/friends/', 'index.html') + return send_from_directory(root + 'friends/', 'index.html') @static_files_bp.route('/profiles/', endpoint='profiles') def loadContacts(path): - return send_from_directory('static-data/www/profiles/', path) + return send_from_directory(root + 'profiles/', path) @static_files_bp.route('/profiles/', endpoint='profilesindex') def loadContacts(): - return send_from_directory('static-data/www/profiles/', 'index.html') + return send_from_directory(root + 'profiles/', 'index.html') @static_files_bp.route('/board/', endpoint='boardContent') def boardContent(path): - return send_from_directory('static-data/www/board/', path) + return send_from_directory(root + 'board/', path) @static_files_bp.route('/shared/', endpoint='sharedContent') def sharedContent(path): - return send_from_directory('static-data/www/shared/', path) + return send_from_directory(root + 'shared/', path) @static_files_bp.route('/', endpoint='onionrhome') def hello(): # ui home - return send_from_directory('static-data/www/private/', 'index.html') + return send_from_directory(root + 'private/', 'index.html') @static_files_bp.route('/private/', endpoint='homedata') def homedata(path): - return send_from_directory('static-data/www/private/', path) \ No newline at end of file + return send_from_directory(root + 'private/', path) \ No newline at end of file diff --git a/onionr/onionrpeers/peercleanup.py b/onionr/onionrpeers/peercleanup.py index 0ac9e033..2624ac86 100644 --- a/onionr/onionrpeers/peercleanup.py +++ b/onionr/onionrpeers/peercleanup.py @@ -19,12 +19,13 @@ ''' import sqlite3 import logger +from . import scoresortedpeerlist, peerprofiles def peer_cleanup(core_inst): '''Removes peers who have been offline too long or score too low''' config = core_inst.config logger.info('Cleaning peers...') - adders = get_score_sorted_peer_list(core_inst) + adders = scoresortedpeerlist.get_score_sorted_peer_list(core_inst) adders.reverse() if len(adders) > 1: @@ -34,7 +35,7 @@ def peer_cleanup(core_inst): for address in adders: # Remove peers that go below the negative score - if PeerProfiles(address, core_inst).score < min_score: + if peerprofiles.PeerProfiles(address, core_inst).score < min_score: core_inst.removeAddress(address) try: if (int(epoch.get_epoch()) - int(core_inst.getPeerInfo(address, 'dateSeen'))) >= 600: