switch to onion v3 ids
This commit is contained in:
parent
e175c72a40
commit
71634c9ed1
10 changed files with 212 additions and 120 deletions
17
oml/tor.py
17
oml/tor.py
|
|
@ -22,6 +22,7 @@ import logging
|
|||
logging.getLogger('stem').setLevel(logging.ERROR)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TorDaemon(Thread):
|
||||
installing = False
|
||||
running = True
|
||||
|
|
@ -201,18 +202,20 @@ class Tor(object):
|
|||
return False
|
||||
controller = self.controller
|
||||
if controller.get_version() >= stem.version.Requirement.ADD_ONION:
|
||||
with open(settings.ssl_key_path, 'rb') as fd:
|
||||
private_key = fd.read()
|
||||
key_content = RSA.importKey(private_key).exportKey().decode()
|
||||
key_content = ''.join(key_content.strip().split('\n')[1:-1])
|
||||
private_key, public_key = utils.load_pem_key(settings.ca_key_path)
|
||||
key_type, key_content = utils.get_onion_key(private_key)
|
||||
ports = {9851: settings.server['node_port']}
|
||||
if settings.preferences.get('enableReadOnlyService'):
|
||||
ports[80] = settings.server['public_port']
|
||||
controller.remove_ephemeral_hidden_service(settings.USER_ID)
|
||||
response = controller.create_ephemeral_hidden_service(ports,
|
||||
key_type='RSA1024', key_content=key_content,
|
||||
detached=True)
|
||||
response = controller.create_ephemeral_hidden_service(
|
||||
ports,
|
||||
key_type=key_type, key_content=key_content,
|
||||
detached=True
|
||||
)
|
||||
if response.is_ok():
|
||||
if response.service_id != settings.USER_ID:
|
||||
logger.error("Something is wrong with tor id %s vs %s", response.service_id, settings.USER_ID)
|
||||
logger.debug('published node as https://%s.onion:%s',
|
||||
settings.USER_ID, settings.server_defaults['node_port'])
|
||||
if settings.preferences.get('enableReadOnlyService'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue