This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wouto1997's profile picture

Only Allow Pre-Made Programs To Use Peripheral Api?

Started by Wouto1997, 23 January 2013 - 08:55 PM
Wouto1997 #1
Posted 23 January 2013 - 09:55 PM
Hello crafters,

I'm currently working on a peripheral block for a server I'm on, and I have figured out how to give it functions ( like… 5 hours after I started trying lol ),
but now I actually want to do something, which as far as I know is quite complicated, I'd like to make the peripheral have a private API, which I can access from a custom program which I could include in the mod or even in the rom dir if needed ( this is just on our own server so not a big deal if that would be needed ), but since the functions are quite hacky, I don't want anyone to mess with it.

Can anyone help me out with tips on how to make it private, or how to secure such things?

Tyvm :)/>
Xfel #2
Posted 24 January 2013 - 04:16 AM
making peripheral functions private? not possible. you can always do peripheral.call
D3matt #3
Posted 25 January 2013 - 03:19 PM
You could maybe get the currently running program, and if it's one of the "approved" programs, allow it.
Orwell #4
Posted 25 January 2013 - 03:36 PM
You could maybe get the currently running program, and if it's one of the "approved" programs, allow it.
You can't really do that through the CC API… And even if you could, is a program name or path a valid criteria to filter access on?

Edit: A path in the rom might be a good criteria. But the only way to get the current running program (aka coroutine) is through the call to shell.getRunningProgram() and that's easily circumventable.