fix existing tor daemon not having closed ephemeral onions and work on mail test

This commit is contained in:
Kevin Froman 2020-03-07 18:51:39 -06:00
parent dfc42953f7
commit 04133035ba
8 changed files with 74 additions and 3 deletions

View file

@ -3,6 +3,8 @@
Create an ephemeral onion service
"""
from .torcontroller import get_controller
from filepaths import ephemeral_services_file
"""
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
@ -19,7 +21,7 @@ from .torcontroller import get_controller
"""
def create_onion_service(port=80):
def create_onion_service(port=80, record_to_service_removal_file=True):
controller = get_controller()
hs = controller.create_ephemeral_hidden_service(
{80: port},
@ -27,4 +29,7 @@ def create_onion_service(port=80):
key_content = 'ED25519-V3',
await_publication=True,
detached=True)
if record_to_service_removal_file:
with open(ephemeral_services_file, 'a') as service_file:
service_file.write(hs.service_id + '\n')
return (hs.service_id, hs.private_key)