only generate a new identity on the first run, from then on, use the existing identity if another is not provided
This commit is contained in:
21
README.md
21
README.md
@@ -91,20 +91,29 @@ options:
|
||||
|
||||
## Using an existing Reticulum Identity
|
||||
|
||||
By default, a random identity is generated every time you run the script.
|
||||
The first time you run this application, a new Reticulum identity is generated and saved to `storage/identity`.
|
||||
|
||||
This is handy for quickly testing out the web ui, however you may want to use an existing identity when chatting with others.
|
||||
If you want to use an existing identity;
|
||||
|
||||
To generate a new identity, you can use the [rnid](https://reticulum.network/manual/using.html#the-rnid-utility) utility provided by Reticulum.
|
||||
- You can overwrite `storage/identity` with another identity file.
|
||||
- Or, you can pass in a custom identity file path as a command line argument.
|
||||
|
||||
To use a custom identity file, provide the `--identity-file` argument followed by the path to your custom identity file.
|
||||
|
||||
```
|
||||
rnid --generate ./new_identity
|
||||
python web.py --identity-file ./custom_identity_file
|
||||
```
|
||||
|
||||
You can then use the following to run the web ui with your new identity file;
|
||||
If you would like to generate a new identity, you can use the [rnid](https://reticulum.network/manual/using.html#the-rnid-utility) utility provided by Reticulum.
|
||||
|
||||
```
|
||||
python web.py --identity-file ./new_identity
|
||||
rnid --generate ./new_identity_file
|
||||
```
|
||||
|
||||
If you don't have access to the `rnid` command, you can use the following:
|
||||
|
||||
```
|
||||
python web.py --generate-identity-file ./new_identity_file
|
||||
```
|
||||
|
||||
Alternatively, you can provide a base64 encoded private key, like so;
|
||||
|
||||
19
web.py
19
web.py
@@ -1366,14 +1366,27 @@ def main():
|
||||
if args.identity_file is not None:
|
||||
identity = RNS.Identity(create_keys=False)
|
||||
identity.load(args.identity_file)
|
||||
print("Reticulum Identity <{}> has been loaded from file.".format(identity.hash.hex()))
|
||||
print("Reticulum Identity <{}> has been loaded from file {}.".format(identity.hash.hex(), args.identity_file))
|
||||
elif args.identity_base64 is not None:
|
||||
identity = RNS.Identity(create_keys=False)
|
||||
identity.load_private_key(base64.b64decode(args.identity_base64))
|
||||
print("Reticulum Identity <{}> has been loaded from base64.".format(identity.hash.hex()))
|
||||
else:
|
||||
identity = RNS.Identity(create_keys=True)
|
||||
print("Reticulum Identity <{}> has been randomly generated.".format(identity.hash.hex()))
|
||||
|
||||
# configure path to default identity file
|
||||
default_identity_file = os.path.join("storage", "identity")
|
||||
|
||||
# if default identity file does not exist, generate a new identity and save it
|
||||
if not os.path.exists(default_identity_file):
|
||||
identity = RNS.Identity(create_keys=True)
|
||||
with open(default_identity_file, "wb") as file:
|
||||
file.write(identity.get_private_key())
|
||||
print("Reticulum Identity <{}> has been randomly generated and saved to {}.".format(identity.hash.hex(), default_identity_file))
|
||||
|
||||
# default identity file exists, load it
|
||||
identity = RNS.Identity(create_keys=False)
|
||||
identity.load(default_identity_file)
|
||||
print("Reticulum Identity <{}> has been loaded from file.".format(identity.hash.hex()))
|
||||
|
||||
# init app
|
||||
reticulum_webchat = ReticulumWebChat(identity, args.storage_dir, args.reticulum_config_dir)
|
||||
|
||||
Reference in New Issue
Block a user