diff --git a/src/netcontroller/torcontrol/__init__.py b/src/netcontroller/torcontrol/__init__.py index b29d75f3..7f0777e8 100644 --- a/src/netcontroller/torcontrol/__init__.py +++ b/src/netcontroller/torcontrol/__init__.py @@ -1,10 +1,8 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - Netcontroller library, used to control/work with Tor and send requests through them +Netcontroller library, used to control/work with Tor and send requests through """ import os -import base64 import subprocess import signal import time @@ -20,7 +18,6 @@ from . import gentorrc from . import addbridges from . import torbinary from utils import identifyhome -from utils import box_print """ 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 diff --git a/src/netcontroller/torcontrol/addbridges.py b/src/netcontroller/torcontrol/addbridges.py index 4ac69cc1..33740fb1 100644 --- a/src/netcontroller/torcontrol/addbridges.py +++ b/src/netcontroller/torcontrol/addbridges.py @@ -1,7 +1,6 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - Add bridge info to torrc configuration string +Add bridge info to torrc configuration string """ import config import logger @@ -22,7 +21,7 @@ import logger def add_bridges(torrc: str) -> str: - """Configure tor to use a bridge using Onionr config keys""" + """Configure tor to use a bridge using Onionr config keys.""" if config.get('tor.use_bridge', False) is True: bridge = config.get('tor.bridge_ip', None) if bridge is not None: diff --git a/src/netcontroller/torcontrol/customtorrc.py b/src/netcontroller/torcontrol/customtorrc.py index f12c9d3d..b49ef090 100644 --- a/src/netcontroller/torcontrol/customtorrc.py +++ b/src/netcontroller/torcontrol/customtorrc.py @@ -1,7 +1,6 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - Load or set custom torrc +Load or set custom torrc """ from utils import identifyhome """ diff --git a/src/netcontroller/torcontrol/gentorrc.py b/src/netcontroller/torcontrol/gentorrc.py index cb79c991..59a76596 100644 --- a/src/netcontroller/torcontrol/gentorrc.py +++ b/src/netcontroller/torcontrol/gentorrc.py @@ -1,3 +1,7 @@ +"""Onionr - Private P2P Communication. + +Generate a generate a torrc file for our Onionr instance +""" import base64 import os import subprocess @@ -8,14 +12,26 @@ from . import addbridges from . import torbinary from utils import identifyhome import config +""" + 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 . +""" add_bridges = addbridges.add_bridges def generate_torrc(net_controller, api_server_ip): - """ - Generate a torrc file for our tor instance - """ + """Generate a torrc file for our tor instance.""" socks_port = net_controller.socksPort hs_port = net_controller.hsPort home_dir = identifyhome.identify_home() @@ -27,7 +43,7 @@ def generate_torrc(net_controller, api_server_ip): Set the Tor control password. Meant to make it harder to manipulate our Tor instance """ - plaintext = base64.b64encode(os.urandom(50)).decode() + plaintext = base64.b85encode(os.urandom(50)).decode() config.set('tor.controlpassword', plaintext, savefile=True) config.set('tor.socksport', socks_port, savefile=True) diff --git a/src/netcontroller/torcontrol/onionservicecreator.py b/src/netcontroller/torcontrol/onionservicecreator.py index 2c2a0ea2..ddb814bd 100644 --- a/src/netcontroller/torcontrol/onionservicecreator.py +++ b/src/netcontroller/torcontrol/onionservicecreator.py @@ -25,8 +25,8 @@ def create_onion_service(port=80, record_to_service_removal_file=True): controller = get_controller() hs = controller.create_ephemeral_hidden_service( {80: port}, - key_type = 'NEW', - key_content = 'ED25519-V3', + key_type='NEW', + key_content='ED25519-V3', await_publication=True, detached=True) if record_to_service_removal_file: diff --git a/src/netcontroller/torcontrol/rebuildtor.py b/src/netcontroller/torcontrol/rebuildtor.py index 77d91a91..8e366ae0 100644 --- a/src/netcontroller/torcontrol/rebuildtor.py +++ b/src/netcontroller/torcontrol/rebuildtor.py @@ -2,8 +2,6 @@ Send Tor restart command """ -import time - from gevent import spawn from onionrutils import localcommand diff --git a/src/netcontroller/torcontrol/torbinary.py b/src/netcontroller/torcontrol/torbinary.py index c3b7d0bf..e1908a3c 100644 --- a/src/netcontroller/torcontrol/torbinary.py +++ b/src/netcontroller/torcontrol/torbinary.py @@ -1,7 +1,6 @@ -""" - Onionr - Private P2P Communication +"""Onionr - Private P2P Communication. - get the tor binary path +get the tor binary path """ import os from shutil import which diff --git a/src/netcontroller/torcontrol/torcontroller.py b/src/netcontroller/torcontrol/torcontroller.py index 46149f4d..5678ce18 100644 --- a/src/netcontroller/torcontrol/torcontroller.py +++ b/src/netcontroller/torcontrol/torcontroller.py @@ -1,6 +1,24 @@ +"""Onionr - P2P Anonymous Storage Network. + +Return stem Tor controller instance +""" from stem.control import Controller import config +""" + 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 . +""" config.reload()