Skip to content

Commit 95cea24

Browse files
committed
Ported rncp allow files to rnx
1 parent d002a75 commit 95cea24

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
@@ -83,7 +83,25 @@ def listen(configdir, identitypath = None, verbosity = 0, quietness = 0, allowed
8383
except Exception as e:
8484
print(str(e))
8585
exit(1)
86-
86+
try:
87+
allowed_file_name = "allowed_identities"
88+
allowed_file = None
89+
if os.path.isfile(os.path.expanduser("/etc/rnx/"+allowed_file_name)):
90+
allowed_file = os.path.expanduser("/etc/rnx/"+allowed_file_name)
91+
elif os.path.isfile(os.path.expanduser("~/.config/rnx/"+allowed_file_name)):
92+
allowed_file = os.path.expanduser("~/.config/rnx/"+allowed_file_name)
93+
elif os.path.isfile(os.path.expanduser("~/.rnx/"+allowed_file_name)):
94+
allowed_file = os.path.expanduser("~/.rnx/"+allowed_file_name)
95+
if allowed_file != None:
96+
with open(allowed_file, "r") as af_handle:
97+
allowed_by_file = af_handle.read().replace("\r", "").split("\n")
98+
for allowed_ID in allowed_by_file:
99+
if len(allowed_ID) == (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2:
100+
allowed_identity_hashes.append(bytes.fromhex(allowed_ID))
101+
except Exception as e:
102+
print(str(e))
103+
exit(1)
104+
87105
if len(allowed_identity_hashes) < 1 and not disable_auth:
88106
print("Warning: No allowed identities configured, rncx will not accept any commands!")
89107

0 commit comments

Comments
 (0)