Skip to content

Commit

Permalink
several bug fixes (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
vesellov authored Nov 12, 2023
1 parent 039aa08 commit 215cf67
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 107 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Change Log
==========

2023-11-12 Veselin Penev [[email protected]](mailto:[email protected])

* bug fix in bitdust/system/deploy.py related to python3.11
* IDURL fix in bitdust/supplier/customer_space.py
* bug fix in butdust/userid/id_url.py
* disabled un-used Bismuth crypto methods
* Bump twisted from 22.4.0 to 23.8.0



2023-10-24 Veselin Penev [[email protected]](mailto:[email protected])

* removed bitdust_forks/Bismuth/wallet/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ regress_run:
PYTHON_VERSION=$(REGRESSION_PY_VER) _PAUSE_BEFORE=0 make --no-print-directory -C regress/ run_all

regress_run_parallel:
PYTHON_VERSION=$(REGRESSION_PY_VER) _PAUSE_BEFORE=0 make --no-print-directory -j 3 -C regress/ run_parallel
PYTHON_VERSION=$(REGRESSION_PY_VER) _PAUSE_BEFORE=0 make --no-print-directory -j 1 -C regress/ run_parallel

regress_run_log:
PYTHON_VERSION=$(REGRESSION_PY_VER) make --no-print-directory -C regress/ run_all_log
Expand Down
2 changes: 1 addition & 1 deletion bitdust/stream/message_peddler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ def _on_queue_keeper_connect_failed(self, err, consumer_id, producer_id, group_k
try:
evt, args, kwargs = err.value.args
except:
lg.exc()
lg.exc(msg=repr(err))
return None
if _Debug:
lg.args(_DebugLevel, event=evt, args=args, kwargs=kwargs)
Expand Down
2 changes: 1 addition & 1 deletion bitdust/supplier/customer_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def verify_ownership(newpacket, raise_exception=False):
if _Debug:
lg.args(_DebugLevel, owner_id=owner_id, creator_id=creator_id, customer_id=packet_owner_id, key_registered=packet_key_id_registered)
if newpacket.Command == commands.Data():
if owner_idurl == creator_idurl:
if id_url.is_the_same(owner_idurl, creator_idurl):
if contactsdb.is_customer(creator_idurl):
if _Debug:
lg.dbg(_DebugLevel, 'OK, scenario 1: customer is sending own data to own supplier')
Expand Down
5 changes: 4 additions & 1 deletion bitdust/system/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ def run(args):
python_exe = current_python
make_venv_cmd = '{} -m virtualenv --system-site-packages {}'.format(python_exe, venv_path)
if on_mac:
make_venv_cmd = '{} -m virtualenv --clear --always-copy {}'.format(current_python, venv_path)
if sys.version_info >= (3, 11):
make_venv_cmd = '{} -m venv --clear --copies {}'.format(current_python, venv_path)
else:
make_venv_cmd = '{} -m virtualenv --clear --always-copy {}'.format(current_python, venv_path)

print_text('\n***** Executing "{}"'.format(make_venv_cmd))
status = os.system(make_venv_cmd)
Expand Down
6 changes: 5 additions & 1 deletion bitdust/userid/id_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,14 @@ def _save_identity(self, inputfilename):
lg.warn('input file too small - ignoring')
tmpfile.erase('idsrv', inputfilename, 'input file too small')
return
if not newxml.startswith('<?xml version="1.0" encoding="utf-8"?>'):
lg.warn('input file is not an XML - ignoring')
tmpfile.erase('idsrv', inputfilename, 'input file is not an XML')
return
try:
newidentity = identity.identity(xmlsrc=newxml)
except:
lg.warn('input file is wrong - ignoring ')
lg.warn('input file is wrong - ignoring')
tmpfile.erase('idsrv', inputfilename, 'input file is wrong')
return
tmpfile.erase('idsrv', inputfilename, 'id received')
Expand Down
2 changes: 2 additions & 0 deletions bitdust/userid/id_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def init():
for_cleanup = []
for one_user_dir in os.listdir(_IdentityHistoryDir):
one_user_dir_path = os.path.join(_IdentityHistoryDir, one_user_dir)
if not os.path.isdir(one_user_dir_path):
continue
one_user_identity_files = []
for one_filename in os.listdir(one_user_dir_path):
try:
Expand Down
36 changes: 18 additions & 18 deletions bitdust_forks/Bismuth/bismuthclient/bismuthclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,24 +429,24 @@ def load_wallet(self, wallet_file='wallet.der'):
self.clear_cache()
self.address = self._wallet.address

def load_multi_wallet(self, wallet_file='wallet.json'):
"""
Tries to load the wallet file
:param wallet_file: string, a wallet.json file
"""
# TODO: Refactor
self.wallet_file = None
self.address = None
self._wallet = None
self._wallet = BismuthMultiWallet(wallet_file, verbose=self.verbose)
if len(self._wallet._data["addresses"]) == 0:
# Create a first address by default
self._wallet.new_address(label="default")
self.wallet_file = wallet_file
if self.address != self._wallet.address:
self.clear_cache()
self.address = self._wallet.address
# def load_multi_wallet(self, wallet_file='wallet.json'):
# """
# Tries to load the wallet file
#
# :param wallet_file: string, a wallet.json file
# """
# # TODO: Refactor
# self.wallet_file = None
# self.address = None
# self._wallet = None
# self._wallet = BismuthMultiWallet(wallet_file, verbose=self.verbose)
# if len(self._wallet._data["addresses"]) == 0:
# # Create a first address by default
# self._wallet.new_address(label="default")
# self.wallet_file = wallet_file
# if self.address != self._wallet.address:
# self.clear_cache()
# self.address = self._wallet.address

def set_address(self, address: str=''):
if not type(self._wallet) == BismuthMultiWallet:
Expand Down
62 changes: 31 additions & 31 deletions bitdust_forks/Bismuth/bismuthclient/bismuthcrypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,37 +199,37 @@ def keys_new(keyfile):
return True


def keys_gen(password: str='', salt: str='', count=10000, verbose=False):
"""
Optionnally deterministic RSA Key generation from password and salt. To be used by tests only atm.
:param password:
:param salt:
:param count:
:param verbose:
:return:
"""
if password:
def my_rand(n):
# kluge: use PBKDF2 with count=1 and incrementing salt as deterministic PRNG
my_rand.counter += 1
return PBKDF2(master_key, "my_rand:%d" % my_rand.counter, dkLen=n, count=1)
if verbose:
print("Generating master key")
master_key = PBKDF2(password, salt, count=count)
my_rand.counter = 0
if verbose:
print("Generating RSA key")
key = RSA.generate(4096, randfunc=my_rand)
else:
if verbose:
print("Generating RSA key")
key = RSA.generate(4096)
# public_key = key.publickey()
private_key_readable = key.exportKey().decode("utf-8")
public_key_readable = key.publickey().exportKey().decode("utf-8")
address = hashlib.sha224(public_key_readable.encode("utf-8")).hexdigest() # hashed public key
# export to single file
return {'private_key': private_key_readable, 'public_key': public_key_readable, 'address': address}
# def keys_gen(password: str='', salt: str='', count=10000, verbose=False):
# """
# Optionnally deterministic RSA Key generation from password and salt. To be used by tests only atm.
# :param password:
# :param salt:
# :param count:
# :param verbose:
# :return:
# """
# if password:
# def my_rand(n):
# # kluge: use PBKDF2 with count=1 and incrementing salt as deterministic PRNG
# my_rand.counter += 1
# return PBKDF2(master_key, "my_rand:%d" % my_rand.counter, dkLen=n, count=1)
# if verbose:
# print("Generating master key")
# master_key = PBKDF2(password, salt, count=count)
# my_rand.counter = 0
# if verbose:
# print("Generating RSA key")
# key = RSA.generate(4096, randfunc=my_rand)
# else:
# if verbose:
# print("Generating RSA key")
# key = RSA.generate(4096)
# # public_key = key.publickey()
# private_key_readable = key.exportKey().decode("utf-8")
# public_key_readable = key.publickey().exportKey().decode("utf-8")
# address = hashlib.sha224(public_key_readable.encode("utf-8")).hexdigest() # hashed public key
# # export to single file
# return {'private_key': private_key_readable, 'public_key': public_key_readable, 'address': address}


def keys_save(private_key_readable, public_key_readable, address, file):
Expand Down
40 changes: 20 additions & 20 deletions bitdust_forks/Bismuth/bismuthclient/bismuthmultiwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,26 @@ def new(self, wallet_file='wallet.der'):
return True
"""

def new_address(self, label: str='', password: str='', salt: str='', type="RSA"):
"""
Add a new address to the wallet (and save it)
"""
if type != "RSA":
raise RuntimeError("Only RSA is available for now")
if self._infos['encrypted'] and self._locked:
raise RuntimeError("Wallet must be unlocked")
keys = bismuthcrypto.keys_gen(password=password, salt=salt)
keys['label'] = label
keys['timestamp'] = int(time())
self._addresses.append(keys)
if self._infos['encrypted']:
content = json.dumps(keys)
encrypted = b64encode(encrypt(self._master_password, content, level=1)).decode('utf-8')
self._data['addresses'].append(encrypted)
else:
print('1')
self._data['addresses'].append(keys)
self.save()
# def new_address(self, label: str='', password: str='', salt: str='', type="RSA"):
# """
# Add a new address to the wallet (and save it)
# """
# if type != "RSA":
# raise RuntimeError("Only RSA is available for now")
# if self._infos['encrypted'] and self._locked:
# raise RuntimeError("Wallet must be unlocked")
# keys = bismuthcrypto.keys_gen(password=password, salt=salt)
# keys['label'] = label
# keys['timestamp'] = int(time())
# self._addresses.append(keys)
# if self._infos['encrypted']:
# content = json.dumps(keys)
# encrypted = b64encode(encrypt(self._master_password, content, level=1)).decode('utf-8')
# self._data['addresses'].append(encrypted)
# else:
# print('1')
# self._data['addresses'].append(keys)
# self.save()

def set_label(self, address:str ='', label: str=''):
"""
Expand Down
33 changes: 0 additions & 33 deletions bitdust_forks/Bismuth/config.txt

This file was deleted.

0 comments on commit 215cf67

Please sign in to comment.