From 89b8c238486e6f79105bcfe167537b60148cad3b Mon Sep 17 00:00:00 2001 From: quadrismegistus Date: Wed, 9 Sep 2020 16:30:34 +0100 Subject: [PATCH] updates --- komrade/backend/people.py | 107 +++++++++++++++++++++++--------- komrade/backend/the_operator.py | 10 ++- 2 files changed, 85 insertions(+), 32 deletions(-) diff --git a/komrade/backend/people.py b/komrade/backend/people.py index e35f98f..b592926 100644 --- a/komrade/backend/people.py +++ b/komrade/backend/people.py @@ -71,35 +71,9 @@ class Person(Caller): get_resp_from=super().ring_ring ) - def register(self,name=None,passphrase=DEBUG_DEFAULT_PASSPHRASE, is_group=None): - # get needed metadata - 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' - - # form request to operator - msg_to_op = {'_please':'forge_new_keys'} - - msg_response = self.phone.ring_ring( - msg_to_op, - self.op - ) - - # call and ask operator to register us - - # for only this one! we skip straight to phone, - # since I don't have any public keys yet - - resp = self.phone.ring_ring(msg_to_op) - - return resp - def get_new_keys(self, name = None, passphrase = DEBUG_DEFAULT_PASSPHRASE, is_group=None): + def register(self, name = None, passphrase = DEBUG_DEFAULT_PASSPHRASE, is_group=None): # get needed metadata if not name: name=self.name if name is None: @@ -109,10 +83,19 @@ class Person(Caller): # if is_group is None: # is_group = input('\nIs this a group account? [y/N]').strip().lower() == 'y' - + # form request + msg_to_op = { + '_please':'forge_new_keys', + 'name':name, + 'passphrase':hashish(passphrase.encode()) + } - phone_res = self.phone.ring(msg_to_op) + # get message back + msg_obj = self.phone.ring_ring(msg_to_op) + print('GOT BACK!!!',msg_obj) + + # URI id uri_id = phone_res.get('uri_id') returned_keys = phone_res.get('_keychain') @@ -136,6 +119,72 @@ class Person(Caller): return saved_keys + + # def register(self,name=None,passphrase=DEBUG_DEFAULT_PASSPHRASE, is_group=None): + # # get needed metadata + # 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' + + # # form request to operator + # msg_to_op = {'_please':'forge_new_keys'} + + # msg_response = self.phone.ring_ring( + # msg_to_op, + # self.op + # ) + + # # call and ask operator to register us + + # # for only this one! we skip straight to phone, + # # since I don't have any public keys yet + + # resp = self.phone.ring_ring(msg_to_op) + + # return resp + + + # def get_new_keys(self, name = None, passphrase = DEBUG_DEFAULT_PASSPHRASE, is_group=None): + # # get needed metadata + # 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' + + + + # phone_res = self.phone.ring(msg_to_op) + + # # URI id + # uri_id = phone_res.get('uri_id') + # returned_keys = phone_res.get('_keychain') + # self.log('got URI from Op:',uri_id) + # self.log('got returnd keys from Op:',returned_keys) + + # stop + + # # better have the right keys + # assert set(KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_CLIENT) == set(returned_keys.keys()) + + # # now save these keys! + # saved_keys = self.save_keychain(name,returned_keys,uri_id=uri_id) + # self.log('saved keys!',saved_keys) + + # # better have the right keys + # # assert set(KEYMAKER_DEFAULT_KEYS_TO_SAVE) == set(saved_keys.keys()) + + # # success! + # self.log('yay!!!!') + # return saved_keys + + if __name__=='__main__': person = Person('marx') diff --git a/komrade/backend/the_operator.py b/komrade/backend/the_operator.py index c89d117..091ae50 100644 --- a/komrade/backend/the_operator.py +++ b/komrade/backend/the_operator.py @@ -97,15 +97,19 @@ class TheOperator(Operator): # what we working with? self.log(f'route() got incoming msg = {msg_obj} and route = {route}') + # pass on data + data = msg_obj.msg + if type(data)==dict and ROUTE_KEYNAME in data: + del data[ROUTE_KEYNAME] + # hard code the acceptable routes if route == 'forge_new_keys': - return self.forge_new_keys(msg_obj) + return self.forge_new_keys(data) # otherwise, hang up and try again return OPERATOR_INTERCEPT_MESSAGE - def forge_new_keys(self,msg_obj): - data = msg_obj.msg + def forge_new_keys(self,data): self.log('about to make some new keys!',data) # return {'_please':'well_hello_to_you_too'}