Improved formatting and removed unnecessary imports in torcontrol

This commit is contained in:
Kevin Froman 2020-08-08 20:44:11 -05:00
parent 504c53edb3
commit e14955cb6b
8 changed files with 49 additions and 23 deletions

View File

@ -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

View File

@ -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:

View File

@ -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
"""

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
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)

View File

@ -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:

View File

@ -2,8 +2,6 @@
Send Tor restart command
"""
import time
from gevent import spawn
from onionrutils import localcommand

View File

@ -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

View File

@ -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 <https://www.gnu.org/licenses/>.
"""
config.reload()