You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Comrad/komrade/backend/callers.py

51 lines
1.8 KiB
Python

4 years ago
import os,sys; sys.path.append(os.path.abspath(os.path.join(os.path.abspath(os.path.join(os.path.dirname(__file__),'..')),'..')))
from komrade import *
from komrade.backend import *
4 years ago
# from komrade.backend.the_telephone import *
# from komrade.backend.the_telephone import *
4 years ago
class Caller(Operator):
"""
Variant of an Operator which handles local keys and keymaking.
"""
@property
def phone(self):
4 years ago
global TELEPHONE
4 years ago
from komrade.backend.the_telephone import TheTelephone
4 years ago
if not TELEPHONE: TELEPHONE=TheTelephone()
4 years ago
return TELEPHONE
@property
4 years ago
def op(self):
global OPERATOR
4 years ago
from komrade.backend.the_operator import TheOperator
if not OPERATOR: OPERATOR=TheOperator()
4 years ago
return OPERATOR
4 years ago
async def get_new_keys(self, name = None, passphrase = None, is_group=None):
4 years ago
if not name: name=self.name
if name is None:
name = input('\nWhat is the name for this account? ')
if passphrase is None:
passphrase = getpass.getpass('\nEnter a memborable password: ')
# if is_group is None:
# is_group = input('\nIs this a group account? [y/N]').strip().lower() == 'y'
req_json = {
'_route':'forge_new_keys',
'name':name,
'passphrase':hashish(passphrase.encode())
}
req_json['key_types'] = {**KEYMAKER_DEFAULT_KEY_TYPES}
4 years ago
req_json['keys_to_save']=['pubkey_encr','privkey_encr','adminkey_encr']
req_json['keys_to_return']=['pubkey_decr',
'privkey_decr_encr', 'privkey_decr_decr',
'adminkey_decr_encr', 'adminkey_decr_decr']
try:
4 years ago
return await self.phone.req(json_coming_from_phone = req_json, caller=self)
4 years ago
except TypeError:
return None