From bf483ed95d3e874a73da53c421503545bf654e7a Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 30 Apr 2024 21:42:30 +1200 Subject: [PATCH] do not overwrite existing files, otherwise user could lose existing keys --- web.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web.py b/web.py index be750d2..c1169e4 100644 --- a/web.py +++ b/web.py @@ -428,9 +428,17 @@ async def main(): # util to generate reticulum identity and save to file without using rnid if args.generate_identity_file is not None: + + # do not overwrite existing files, otherwise user could lose existing keys + if os.path.exists(args.generate_identity_file): + print("DANGER: the provided identity file path already exists, not overwriting!") + return + + # generate a new identity and save to provided file path identity = RNS.Identity(create_keys=True) with open(args.generate_identity_file, "wb") as file: file.write(identity.get_private_key()) + print("A new Reticulum Identity has been saved to: {}".format(args.generate_identity_file)) return