Verbose tor output, colorful integration

This commit is contained in:
BarsTiger
2023-06-27 23:41:28 +03:00
parent 914f48a92b
commit ffb4569509
3 changed files with 30 additions and 55 deletions

View File

@@ -1,18 +1,32 @@
import sys
from dragonion_server.utils.onion import Onion
from dragonion_server.utils.generated_auth.db import AuthFile
from dragonion_server.utils.config.db import services
from rich import print
def integrate_onion(port: int, name: str) -> Onion:
onion = Onion()
onion.connect()
onion.write_onion_service(name, port)
print(f'Available on {(onion_host := onion.start_onion_service(name))}')
try:
onion.connect()
onion.write_onion_service(name, port)
finally:
if not onion.connected_to_tor:
onion.cleanup()
sys.exit(1)
print(f'[green]Available on[/] '
f'{(onion_host := onion.start_onion_service(name))}.onion')
auth = AuthFile(name)
auth['host'] = onion_host
auth['host'] = f'{onion_host}.onion'
auth['auth'] = onion.auth_string
print(f'To connect to server share .onion host and auth string (next line), '
f'also you can just share {auth.filename} file')
print(onion.auth_string)
print(f'Raw url auth string: {services[name].client_auth_priv_key}')
print(f'To connect to server just share [green]{auth.filename}[/] file')
print(f'Or use [#ff901b]service id[/] and [#564ec3]auth string[/]: \n'
f'[#ff901b]{onion_host}[/] \n'
f'[#564ec3]{services[name].client_auth_priv_key}[/]')
return onion