Do not save hidden service parameters if onionhostname is set

This commit is contained in:
Dmitri Bogomolov 2019-07-28 13:16:34 +03:00
parent 53d77ce911
commit 97366ede73
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
1 changed files with 9 additions and 10 deletions

View File

@ -87,7 +87,7 @@ def connect_plugin(config):
response = controller.create_ephemeral_hidden_service( response = controller.create_ephemeral_hidden_service(
config.safeGetInt('bitmessagesettings', 'onionport', 8444), config.safeGetInt('bitmessagesettings', 'onionport', 8444),
key_type=(onionkeytype or 'NEW'), key_type=(onionkeytype or 'NEW'),
key_content=(onionkey or 'BEST') key_content=(onionkey or onionhostname and 'ED25519-V3' or 'BEST')
) )
if not response.is_ok(): if not response.is_ok():
@ -95,17 +95,16 @@ def connect_plugin(config):
return return
if not onionkey: if not onionkey:
logwrite('Started hidden service %s.onion' % response.service_id)
# only save new service keys if onionhostname was not set previously
if not onionhostname: if not onionhostname:
onionhostname = response.service_id + '.onion' onionhostname = response.service_id + '.onion'
config.set( config.set(
'bitmessagesettings', 'onionhostname', onionhostname) 'bitmessagesettings', 'onionhostname', onionhostname)
else: config.add_section(onionhostname)
onionhostname = response.service_id + '.onion' config.set(
logwrite('Started hidden service %s' % onionhostname) onionhostname, 'privsigningkey', response.private_key)
config.add_section(onionhostname) config.set(
config.set( onionhostname, 'keytype', response.private_key_type)
onionhostname, 'privsigningkey', response.private_key) config.save()
config.set(
onionhostname, 'keytype', response.private_key_type)
config.save()
config.set('bitmessagesettings', 'socksproxytype', 'SOCKS5') config.set('bitmessagesettings', 'socksproxytype', 'SOCKS5')