Improved formatting and removed unnecessary imports in torcontrol
This commit is contained in:
parent
504c53edb3
commit
e14955cb6b
@ -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 os
|
||||||
import base64
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
@ -20,7 +18,6 @@ from . import gentorrc
|
|||||||
from . import addbridges
|
from . import addbridges
|
||||||
from . import torbinary
|
from . import torbinary
|
||||||
from utils import identifyhome
|
from utils import identifyhome
|
||||||
from utils import box_print
|
|
||||||
"""
|
"""
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -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 config
|
||||||
import logger
|
import logger
|
||||||
@ -22,7 +21,7 @@ import logger
|
|||||||
|
|
||||||
|
|
||||||
def add_bridges(torrc: str) -> str:
|
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:
|
if config.get('tor.use_bridge', False) is True:
|
||||||
bridge = config.get('tor.bridge_ip', None)
|
bridge = config.get('tor.bridge_ip', None)
|
||||||
if bridge is not None:
|
if bridge is not None:
|
||||||
|
@ -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
|
from utils import identifyhome
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
"""Onionr - Private P2P Communication.
|
||||||
|
|
||||||
|
Generate a generate a torrc file for our Onionr instance
|
||||||
|
"""
|
||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -8,14 +12,26 @@ from . import addbridges
|
|||||||
from . import torbinary
|
from . import torbinary
|
||||||
from utils import identifyhome
|
from utils import identifyhome
|
||||||
import config
|
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
|
add_bridges = addbridges.add_bridges
|
||||||
|
|
||||||
|
|
||||||
def generate_torrc(net_controller, api_server_ip):
|
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
|
socks_port = net_controller.socksPort
|
||||||
hs_port = net_controller.hsPort
|
hs_port = net_controller.hsPort
|
||||||
home_dir = identifyhome.identify_home()
|
home_dir = identifyhome.identify_home()
|
||||||
@ -27,7 +43,7 @@ def generate_torrc(net_controller, api_server_ip):
|
|||||||
Set the Tor control password.
|
Set the Tor control password.
|
||||||
Meant to make it harder to manipulate our Tor instance
|
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.controlpassword', plaintext, savefile=True)
|
||||||
config.set('tor.socksport', socks_port, savefile=True)
|
config.set('tor.socksport', socks_port, savefile=True)
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ def create_onion_service(port=80, record_to_service_removal_file=True):
|
|||||||
controller = get_controller()
|
controller = get_controller()
|
||||||
hs = controller.create_ephemeral_hidden_service(
|
hs = controller.create_ephemeral_hidden_service(
|
||||||
{80: port},
|
{80: port},
|
||||||
key_type = 'NEW',
|
key_type='NEW',
|
||||||
key_content = 'ED25519-V3',
|
key_content='ED25519-V3',
|
||||||
await_publication=True,
|
await_publication=True,
|
||||||
detached=True)
|
detached=True)
|
||||||
if record_to_service_removal_file:
|
if record_to_service_removal_file:
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Send Tor restart command
|
Send Tor restart command
|
||||||
"""
|
"""
|
||||||
import time
|
|
||||||
|
|
||||||
from gevent import spawn
|
from gevent import spawn
|
||||||
|
|
||||||
from onionrutils import localcommand
|
from onionrutils import localcommand
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""
|
"""Onionr - Private P2P Communication.
|
||||||
Onionr - Private P2P Communication
|
|
||||||
|
|
||||||
get the tor binary path
|
get the tor binary path
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from shutil import which
|
from shutil import which
|
||||||
|
@ -1,6 +1,24 @@
|
|||||||
|
"""Onionr - P2P Anonymous Storage Network.
|
||||||
|
|
||||||
|
Return stem Tor controller instance
|
||||||
|
"""
|
||||||
from stem.control import Controller
|
from stem.control import Controller
|
||||||
|
|
||||||
import config
|
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()
|
config.reload()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user