Guest User

dns

a guest
May 18th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. rednet.open("bottom")
  2. id, msg = rednet.receive()
  3. local testcom = 99
  4. local pedrocom = 100
  5. local coelhocom = 102
  6. local browsercom = 105
  7. local calccom = 106
  8. local renameorg = 109
  9. local rednetcom = 115
  10. local computerId = id
  11. local banedId = 107
  12. function dns()
  13.   print("computer connected")
  14.   if id == banedId then
  15.     rednet.send(id, "Acess denied")
  16.     clear()
  17.   else end
  18.   if msg == "test.com" then
  19.     print("computer #"..id.." want to acess "..msg)
  20.     if not rednet.send(testcom, id) then
  21.       error404()
  22.     else end
  23.     print("computer #"..id.." acess "..msg)
  24.   elseif msg == "pedro.com" then
  25.     print("computer #"..id.." want to acess "..msg)
  26.     if not rednet.send(pedrocom, id) then
  27.       error404()
  28.     else end
  29.     print("computer #"..id.." acess "..msg)
  30.   elseif msg == "coelho.com" then
  31.     connection()
  32.     if not rednet.send(coelhocom, id) then
  33.       error404()
  34.     else end
  35.     ok()
  36.   elseif msg == "browser.com" then
  37.     connection()
  38.     if not rednet.send(browsercom, id) then
  39.       error404()
  40.     else end
  41.     ok()
  42.   elseif msg == "calc.com" then
  43.     connection()
  44.     if not rednet.send(calccom, id) then
  45.       error404()
  46.     else end
  47.     ok()
  48.   elseif msg == "rename.org" then
  49.     connection()
  50.     if not rednet.send(renameorg, id) then
  51.       error404()
  52.     else end
  53.     ok()
  54.   elseif msg == "rednet.com" then
  55.     connection()
  56.     if not rednet.send(rednetcom, id) then
  57.       error404()
  58.     else end
  59.     ok()
  60.   else
  61.     print("computer #"..id.." give a unknow hostname")
  62.     rednet.send(id, "unknow host name")
  63.   end
  64. end
  65. function clear()
  66.   sleep(2)
  67.   id, msg = rednet.receive()
  68. end
  69. function error404()
  70.   print("computer #"..id.."failed to acess "..msg)
  71.   rednet.send(id, "DNS failed to reply to the server, please check your provider")
  72. end
  73. function ok()
  74.   print("computer #"..id.." acess "..msg)
  75. end
  76. function unknow()
  77.   print("computer #"..id.." give a unknow hostname")
  78.   rednet.send(id, "unknow host name")
  79. end
  80. function connection()
  81.   print("computer #"..id.." want to acess "..msg)
  82. end
  83. while true do
  84.   clear()
  85.   dns()
  86. end
Advertisement
Add Comment
Please, Sign In to add comment