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

Rednet Programs

Started by Hydrotronics, 16 August 2015 - 02:07 PM
Hydrotronics #1
Posted 16 August 2015 - 04:07 PM
So I have a shop on this Tekkit server, and I don't know how to send my prgrams down rednet. This is a bit of a trouble as I'm trying to get prepared for when I get customers. What I would like to do is create a program on my computer and send it down to another computer for them to use it. Please answer this as I am confused and I do not understand rednet too well.
COOLGAMETUBE #2
Posted 16 August 2015 - 08:19 PM
thats easy.

Receiver: Receive–>OpenFile–>WriteFile–>CloseFile
Sender: OpenFile–>ReadFile–>CloseFile–> Send

Run Receive code first!
To Receive use

local SenderID, content = rednet.receive()

Then Run Sender Code
To Send use

rednet.send(YourReceiveComputerID, FileContent)

Dont forget to open Rednet on the Computers by using

rednet.open(SideOfYourModem)
LuckyLuke #3
Posted 18 August 2015 - 07:22 AM
I got a question about you anwser: You can only send a (one) string, in fact, how can i send a complete programm?
HPWebcamAble #4
Posted 18 August 2015 - 08:12 AM
how can i send a complete program?

Since you can't send functions using modems, you need to use the FS API to read the file, then send the (rather large) string of the entire file, like so:

rednet.open("top")
local fileToSend = "/rom/programs/shell" --# The path of the file you want to send

local f = fs.open( fileToSend , "r") --# Open the file in read mode
rednet.send( 1 , f.readAll() ) --# Send Computer ID 1 the contense of the file
f.close()

Receiving the file would look something like this:

rednet.open("top")
local pathToSaveTo = "/temp" --# Path the program should be saved to

local senderID , message = rednet.recieve() --# Wait for a message

local f = fs.open( pathToSaveTo , "w" ) --# Open the file
f.write( message ) --# Write the content of the rednet message
f.close()

Read more about the FS API here:
http://www.computercraft.info/wiki/Fs_(API)


Note that this is extremely insecure!
Anyone can send a program to the receiving computer!
LuckyLuke #5
Posted 18 August 2015 - 11:14 AM
I do know the risk of using rednet, thanks for your information! :)/>
I will make sure to check the senderId bevor writing the programm.
Edited on 18 August 2015 - 09:15 AM
flaghacker #6
Posted 18 August 2015 - 11:19 AM
I do know the risk of using rednet, thanks for your information! :)/>/>
I will make sure to check the senderId bevor writing the programm.

Sender ids can be faked quite easily by overwriting os.getID or by using the modem api. Don't trust the id, use some other authentication method.
Hydrotronics #7
Posted 18 August 2015 - 12:45 PM
Thank you, I think i get it, thx!! This will help me alot!
LuckyLuke #8
Posted 18 August 2015 - 12:52 PM
I do know the risk of using rednet, thanks for your information! :)/>/>
I will make sure to check the senderId bevor writing the programm.

Sender ids can be faked quite easily by overwriting os.getID or by using the modem api. Don't trust the id, use some other authentication method.

Really?! What kind of security are you using, how do you authorize a connection? :)/>
flaghacker #9
Posted 18 August 2015 - 02:52 PM
Sender ids can be faked quite easily by overwriting os.getID or by using the modem api. Don't trust the id, use some other authentication method.

Really?! What kind of security are you using, how do you authorize a connection? :)/>/>

Real security is nearly impossible to archieve in computercraft, but you can get somewhat secure by switching the modem channel you communicate on regularly. The channel could eg. be (os.getTime() / 2) + 5 or something more complicated. You can also encrypt any data you send, search for an encryption api in programs/apis and utilities.