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

[rednet question] 'Spam Security'

Started by Goof, 07 November 2012 - 07:00 AM
Goof #1
Posted 07 November 2012 - 08:00 AM
Hello everyone..

i was trying to program a Email server… and now that worked out fine… but is there any ways to make a SPAM FILTER… that if the receiver/server receives 5 messages within 5 seconds, then shutdown/ do something?

i did try something with os.startTimer(0) but that seems like, not to work out.

my current code:

Spoiler



local running = true
local SM = 0
local Timer = 0

while running do
Timer = os.startTimer(0)
rednet.open("right")
if SM < 5 then
id, msg = rednet.receive()

print(msg)

IDToRe = tonumber(msg)

a1, ms1 = rednet.receive()

print("msg from - "..a1.." - "..ms1)

print(IDToRe)

print("------------------------------------------")

if Timer > 5 then
SM = SM + 1
else
Timer = Timer + 1
end
if Timer < 5 then
if SM < 5 then
SM = 0
end
end

else
running = false
print("EMAIL SPAMMING! STOPPING SERVER IN 10 seconds!")
sleep(10)
Timer = 0
SM = 0
running = true
os.reboot()
end
end





if anyone could figure out how to help me, making that Spam filter, i would be really happy!


Thanks.


______________________________________________________________________

- mikk809h
Sammich Lord #2
Posted 07 November 2012 - 08:35 AM
AfterLifeLochie has re-written the BIOS file on the server I play on and added a very good anti-rednet-spam. You may want to ask him how he did it.
Goof #3
Posted 07 November 2012 - 08:42 AM
Thanks. But do you now how to prevent the spam. As you should see in my code, i tried alot with the timer, but im not sure if it is coded wrong.
Sammich Lord #4
Posted 07 November 2012 - 09:17 AM
The way the timer works is: You pass the number of seconds it should wait like this:
time = os.startTimer(numberOfSecondsToWait)
Once it is done waiting that amount of time is queues a event for os.pullEvent(). So for example:

time = os.startTimer(5)
while true do
  event, p1 = os.pullEvent("timer")
  if p1 == "time" then
    print("Timer has gone off!")
    break
   end
end
That is the basics.
Goof #5
Posted 07 November 2012 - 09:19 AM
Thank you. I will try that out soon :-)
KaoS #6
Posted 07 November 2012 - 10:16 AM
take a look here, it is another post just like this where I helped someone input spam protection