Posted 09 August 2013 - 01:47 PM
Title: ComputerCraft RCon - Remote Shell/Monitor - Rednet
I'm relitivly new to ComputerCraft, but not to lua and other scripting languages. I tried for a few days now to find a solution myself but being inexperienced with the ComputerCraft API I failed to find a solution. From what I've read on the forum, this is a faily advanced task that I'm asking, and I'm not asking for the code because I feel that would be too tedious for people to need to reply with. I'm looking for the concept of how to get a Remote Shell/Monitor system setup.
Essentially in it's simplest form I would like to be able to pass the instance of shell and/or monitor through rednet and use those variables on the connecting computer to control the remote computer, however I know that that is not possible to do normally. I tried to use textutils.serialize and unserialize to pass the instances as a string, however as you know textutils.serialize() can not serialize functions, and both monitor and shell are essentially a collection of functions in a table. I wrote my own serializer using string.dump() and loadstring() and I was able to parse the objects again, however in the process of reconstructing the data the new instance of shell was just that, a new instance, not linked, different address. To the most extreme I could think there might be a way to implement assembly code to use array-of-byte scans and mov opcodes to change the address of the new instance, but that would just be useless waste of time to even think of attempting.
I know RCon is feasible with a server/client program server sends user input, client recieves user input and processes it, and then sends the results back to server. However that would not work well in my case. I would like to be able to remotely connect to multiple of my computers and have full remote access to them, example, if I run the program "paint" I want to be able to paint on the remote computer and see the painting on the connected computer, which I guess it might be possible to literally gather the screen information and send it over, granted the fact that a program is running and I can't run other code alongwide that program (unless ComputerCraft has some form of Multithreading that I don't know of). If I type in lua on the connected computer, I want the lua prompt to show up and allow me to use the lua prompt, which a program cannot be running on the computer at the same time, so I can't just be using a client program to interpret the input and send the output. There are only two ways to achieve this from what I'm seeing:
1) Somehow send the connecting computer a string which is the serialized version of a pointer pointing to the remote computer's specific instance of shell/monitor
2) Find a way to multithread the operations so that the client program can run in the background controlling the computer while the computer is free to perform any operation it normally would with no programs running.
Neither of those methods I've had any luck with and was hoping someone could point me in the right direction (If this is possible at all).
I'm relitivly new to ComputerCraft, but not to lua and other scripting languages. I tried for a few days now to find a solution myself but being inexperienced with the ComputerCraft API I failed to find a solution. From what I've read on the forum, this is a faily advanced task that I'm asking, and I'm not asking for the code because I feel that would be too tedious for people to need to reply with. I'm looking for the concept of how to get a Remote Shell/Monitor system setup.
Essentially in it's simplest form I would like to be able to pass the instance of shell and/or monitor through rednet and use those variables on the connecting computer to control the remote computer, however I know that that is not possible to do normally. I tried to use textutils.serialize and unserialize to pass the instances as a string, however as you know textutils.serialize() can not serialize functions, and both monitor and shell are essentially a collection of functions in a table. I wrote my own serializer using string.dump() and loadstring() and I was able to parse the objects again, however in the process of reconstructing the data the new instance of shell was just that, a new instance, not linked, different address. To the most extreme I could think there might be a way to implement assembly code to use array-of-byte scans and mov opcodes to change the address of the new instance, but that would just be useless waste of time to even think of attempting.
I know RCon is feasible with a server/client program server sends user input, client recieves user input and processes it, and then sends the results back to server. However that would not work well in my case. I would like to be able to remotely connect to multiple of my computers and have full remote access to them, example, if I run the program "paint" I want to be able to paint on the remote computer and see the painting on the connected computer, which I guess it might be possible to literally gather the screen information and send it over, granted the fact that a program is running and I can't run other code alongwide that program (unless ComputerCraft has some form of Multithreading that I don't know of). If I type in lua on the connected computer, I want the lua prompt to show up and allow me to use the lua prompt, which a program cannot be running on the computer at the same time, so I can't just be using a client program to interpret the input and send the output. There are only two ways to achieve this from what I'm seeing:
1) Somehow send the connecting computer a string which is the serialized version of a pointer pointing to the remote computer's specific instance of shell/monitor
2) Find a way to multithread the operations so that the client program can run in the background controlling the computer while the computer is free to perform any operation it normally would with no programs running.
Neither of those methods I've had any luck with and was hoping someone could point me in the right direction (If this is possible at all).