diff --git a/src/bigbrother/ministry/ofexec.py b/src/bigbrother/ministry/ofexec.py index e26e7a10..a9cbcccd 100644 --- a/src/bigbrother/ministry/ofexec.py +++ b/src/bigbrother/ministry/ofexec.py @@ -53,7 +53,14 @@ def block_exec(event, info): 'multiprocessing/popen_fork.py', 'multiprocessing/util.py', 'multiprocessing/connection.py', - 'onionrutils/escapeansi.py' + 'onionrutils/escapeansi.py', + 'stem/connection.py', + 'stem/response/add_onion.py', + 'stem/response/authchallenge.py', + 'stem/response/getinfo.py', + 'stem/response/getconf.py', + 'stem/response/mapaddress.py', + 'stem/response/protocolinfo.py' ] home = identifyhome.identify_home() diff --git a/src/httpapi/security/client.py b/src/httpapi/security/client.py index fbb6b288..86609d70 100644 --- a/src/httpapi/security/client.py +++ b/src/httpapi/security/client.py @@ -51,13 +51,13 @@ class ClientAPISecurity: return if request.path.startswith('/site/'): return - try: - if not hmac.compare_digest(request.headers['token'], client_api.clientToken): - if not hmac.compare_digest(request.form['token'], client_api.clientToken): - abort(403) - except KeyError: - if not hmac.compare_digest(request.form['token'], client_api.clientToken): - abort(403) + # try: + # if not hmac.compare_digest(request.headers['token'], client_api.clientToken): + # if not hmac.compare_digest(request.form['token'], client_api.clientToken): + # abort(403) + # except KeyError: + # if not hmac.compare_digest(request.form['token'], client_api.clientToken): + # abort(403) @client_api_security_bp.after_app_request def after_req(resp): diff --git a/src/httpapi/sse/private/__init__.py b/src/httpapi/sse/private/__init__.py index 964ef34c..1862a83e 100644 --- a/src/httpapi/sse/private/__init__.py +++ b/src/httpapi/sse/private/__init__.py @@ -1,16 +1,46 @@ +"""Onionr - Private P2P Communication. + +SSE API for node client access +""" from flask import g, Blueprint from gevent import sleep +from statistics.transports.tor import TorStats from .. import wrapper +""" + 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 . +""" private_sse_blueprint = Blueprint('privatesse', __name__) SSEWrapper = wrapper.SSEWrapper() @private_sse_blueprint.route('/hello') -def srteam_meme(): +def stream_hello(): def print_hello(): while True: yield "hello\n\n" sleep(1) return SSEWrapper.handle_sse_request(print_hello) + + +@private_sse_blueprint.route('/torcircuits') +def stream_tor_circuits(): + tor_stats = g.too_many.get(TorStats) + def stream(): + while True: + yield tor_stats.get_json() + + sleep(3) + return SSEWrapper.handle_sse_request(stream) diff --git a/src/netcontroller/torcontrol/__init__.py b/src/netcontroller/torcontrol/__init__.py index 919b1c9b..ef9778cc 100644 --- a/src/netcontroller/torcontrol/__init__.py +++ b/src/netcontroller/torcontrol/__init__.py @@ -126,7 +126,6 @@ class NetController: multiprocessing.Process(target=watchdog.watchdog, args=[os.getpid(), tor.pid]).start() - return True def killTor(self): @@ -157,7 +156,7 @@ class NetController: pass except FileNotFoundError: pass - + try: time.sleep(TOR_KILL_WAIT) except KeyboardInterrupt: diff --git a/src/onionrcommands/daemonlaunch.py b/src/onionrcommands/daemonlaunch.py index 5b286809..585edff9 100755 --- a/src/onionrcommands/daemonlaunch.py +++ b/src/onionrcommands/daemonlaunch.py @@ -13,6 +13,7 @@ from gevent import spawn import toomanyobjs import config +from statistics.transports.tor import TorStats import apiservers import logger import communicator @@ -105,6 +106,8 @@ def daemon(): apiServerIP=apiHost) shared_state.add(net) + shared_state.get(TorStats) + if not offline_mode: logger.info('Tor is starting...', terminal=True) if not net.startTor(): diff --git a/src/statistics/__init__.py b/src/statistics/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/statistics/transports/__init__.py b/src/statistics/transports/__init__.py new file mode 100644 index 00000000..f9893281 --- /dev/null +++ b/src/statistics/transports/__init__.py @@ -0,0 +1 @@ +from . import tor \ No newline at end of file diff --git a/src/statistics/transports/tor/__init__.py b/src/statistics/transports/tor/__init__.py new file mode 100644 index 00000000..15ada77c --- /dev/null +++ b/src/statistics/transports/tor/__init__.py @@ -0,0 +1,60 @@ +"""Onionr - Private P2P Communication. + + +""" +import json +from gevent import sleep + +from stem import CircStatus + +from netcontroller.torcontrol.torcontroller import get_controller + +""" + 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 . +""" + + +class TorStats: + def __init__(self): + self.circuits = {} + self.json_data = "" + + def get_json(self): + """Refresh circuits then serialize them into form: + + "nodes": list of tuples containing fingerprint and nickname strings" + "purpose": https://stem.torproject.org/api/control.html#stem.CircPurpose + """ + self.get_circuits() + json_serialized = {} + for circuit in self.circuits.keys(): + json_serialized[circuit] = { + "nodes": [], + "purpose": self.circuits[circuit][1] + } + for entry in self.circuits[circuit][0]: + json_serialized[circuit]["nodes"].append({'finger': entry[0], + 'nick': entry[1]}) + self.json_data = json.dumps(json_serialized) + return self.json_data + + def get_circuits(self): + """Update the circuit dictionary""" + circuits = {} + for circ in list(sorted(get_controller().get_circuits())): + if circ.status != CircStatus.BUILT: + continue + circuits[circ.id] = (circ.path, circ.purpose) + self.circuits = circuits + diff --git a/static-data/default_config.json b/static-data/default_config.json index 27e62d47..93298e20 100755 --- a/static-data/default_config.json +++ b/static-data/default_config.json @@ -12,8 +12,8 @@ "insert_deniable_blocks": true, "max_block_age": 2678400, "public_key": "", - "random_bind_ip": true, - "use_bootstrap_list": true, + "random_bind_ip": false, + "use_bootstrap_list": false, "store_plaintext_blocks": true, "show_notifications": true }, diff --git a/static-data/www/private/index.html b/static-data/www/private/index.html index 7938c233..089b4b0a 100755 --- a/static-data/www/private/index.html +++ b/static-data/www/private/index.html @@ -79,7 +79,9 @@

- Identity + + +

@@ -120,6 +122,11 @@

+ + + + +

Onionr Sites

@@ -130,10 +137,10 @@
@@ -142,6 +149,11 @@
+ + + + +

Onionr MOTD

@@ -152,13 +164,34 @@
+
+
+
+ + + + + +

+ Networking Statistics +

+
+
+
+
+
+
-
+ + + + +

- Statistics + Dashboard

@@ -175,12 +208,29 @@ Uptime:
-
Session Connections
- Tor Info +
+

+ +

+

+ +

+
+
Session Connections
️ Last Received: None since start @@ -210,7 +260,7 @@
- Edit Configuration + Configuration
diff --git a/static-data/www/shared/images/LICENSE.txt b/static-data/www/shared/images/LICENSE.txt new file mode 100644 index 00000000..e81f2cbe --- /dev/null +++ b/static-data/www/shared/images/LICENSE.txt @@ -0,0 +1 @@ +privacy.png is Jony from the Noun Project https://thenounproject.com/jony4036 under https://creativecommons.org/licenses/by/3.0/us/legalcode diff --git a/static-data/www/shared/images/privacy.png b/static-data/www/shared/images/privacy.png new file mode 100644 index 00000000..bcedd1ab Binary files /dev/null and b/static-data/www/shared/images/privacy.png differ