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

Rednet problem?

Started by epa1337, 30 November 2013 - 10:32 AM
epa1337 #1
Posted 30 November 2013 - 11:32 AM
Hello. I'm creating a small internet network with rednet. The problem is if you put up a spammer, no one can use the network..

Ive been trying a while to solve this. I need to block incoming data from a certain id.. Any suggestions?

The id will be blocked if its spamming the server.


Thanks.
epa1337
Lyqyd #2
Posted 30 November 2013 - 12:02 PM
I suggest you post the code.
epa1337 #3
Posted 30 November 2013 - 12:30 PM
http://pastebin.com/KvWPf59x

After the "while true do" is the receiving part. Here it should stop ids from spamming us, because other computers can't connect to send requests.

Thanks
Edited on 30 November 2013 - 12:29 PM
Bomb Bloke #4
Posted 30 November 2013 - 04:27 PM
The short answer is that you cannot "block" an "id".

The reasons for this are that it's trivial to change your computer's id (just place a new computer and start spamming from that), and it's also trivial to spoof the id of someone else's computer (should you decide to make a "white list"). That, and your server will always receive all messages addressed to it anyway - best you can hope for is to manually check and discard unwanted messages.

That leaves the idea of implementing a form of flood control, and maybe even slap some encryption on top of that.

On the other hand: Your real problems here are the sleep statements (as while idling, the program discards any messages received due to the way sleeping makes use of the event queue (which the rednet API relies on)). Even with a decent flood control setup, if two different systems innocently message the server at once only one will be heeded.

You may consider using the parallel API in a fashion similar to this. The idea is that you can define two functions and run them more or less side by side - each gets its own copy of the event queue, so one function can dump received messages in a table, the other function can process those as it sees them (while sleeping if it wants to), and no messages will be missed.