Autoformat

This commit is contained in:
hhh
2024-05-27 17:12:21 +03:00
parent 0afca0dd67
commit 918d5af851
25 changed files with 358 additions and 378 deletions

View File

@@ -1,60 +1,63 @@
import sys
import click
from dragonion_server.modules.server import run, run_without_onion, integrate_onion
from dragonion_server.common import console
from dragonion_server.modules.server import integrate_onion, run, run_without_onion
class ServiceRunCommand(click.Command):
def __init__(self):
super().__init__(
name='run',
name="run",
callback=self.callback,
params=[
click.Option(
('--name', '-n'),
("--name", "-n"),
required=True,
prompt=True,
type=str,
help='Name of service to write to'
help="Name of service to write to",
),
click.Option(
('--port', '-p'),
("--port", "-p"),
required=False,
prompt=True,
prompt_required=False,
type=int,
help='Port to start service on'
help="Port to start service on",
),
click.Option(
('--without-tor', '-wt'),
("--without-tor", "-wt"),
is_flag=True,
help='Run service without tor'
help="Run service without tor",
),
click.Option(
('--only-tor', '-ot'),
("--only-tor", "-ot"),
is_flag=True,
help='Run only tor proxy to service'
)
]
help="Run only tor proxy to service",
),
],
)
@staticmethod
def callback(name: str, port: int | None, without_tor: bool, only_tor: bool):
try:
if without_tor and only_tor:
print('Cannot run only tor without tor, exiting')
print("Cannot run only tor without tor, exiting")
sys.exit(1)
elif without_tor:
run_without_onion(name, port)
elif only_tor:
if port is None:
print('For this mode, you need to specify port, '
'to which requests will be redirected. Cannot start '
'tor service, exiting')
print(
"For this mode, you need to specify port, "
"to which requests will be redirected. Cannot start "
"tor service, exiting"
)
sys.exit(1)
onion = integrate_onion(port, name)
input('Press Enter to stop onion and service...')
input("Press Enter to stop onion and service...")
onion.cleanup()
else:
run(name, port)