Skip to content

Commit f1c4bba

Browse files
authored
Merge pull request #599 from faragher/master
Ported rncp allow files to rnx
2 parents 704019d + 95cea24 commit f1c4bba

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

RNS/Utilities/rnx.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,25 @@ def listen(configdir, identitypath = None, verbosity = 0, quietness = 0, allowed
9191
except Exception as e:
9292
print(str(e))
9393
exit(1)
94-
94+
try:
95+
allowed_file_name = "allowed_identities"
96+
allowed_file = None
97+
if os.path.isfile(os.path.expanduser("/etc/rnx/"+allowed_file_name)):
98+
allowed_file = os.path.expanduser("/etc/rnx/"+allowed_file_name)
99+
elif os.path.isfile(os.path.expanduser("~/.config/rnx/"+allowed_file_name)):
100+
allowed_file = os.path.expanduser("~/.config/rnx/"+allowed_file_name)
101+
elif os.path.isfile(os.path.expanduser("~/.rnx/"+allowed_file_name)):
102+
allowed_file = os.path.expanduser("~/.rnx/"+allowed_file_name)
103+
if allowed_file != None:
104+
with open(allowed_file, "r") as af_handle:
105+
allowed_by_file = af_handle.read().replace("\r", "").split("\n")
106+
for allowed_ID in allowed_by_file:
107+
if len(allowed_ID) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
108+
allowed_identity_hashes.append(bytes.fromhex(allowed_ID))
109+
except Exception as e:
110+
print(str(e))
111+
exit(1)
112+
95113
if len(allowed_identity_hashes) < 1 and not disable_auth:
96114
print("Warning: No allowed identities configured, rncx will not accept any commands!")
97115

0 commit comments

Comments
 (0)