turtle5204

Amethyst Server

Oct 31st, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. if not fs.exists("secure") then
  2. shell.run("pastebin get r8AFFkbV secure")
  3. end
  4.  
  5. if not secure then
  6. os.loadAPI("secure")
  7. end
  8.  
  9. local mo = {}
  10. local ver = "1.0"
  11. local website = ""
  12.  
  13. local function readf(file)
  14. local fl = fs.open(file, "r")
  15. local d = fl.readAll()
  16. fl.close()
  17. return d
  18. end
  19.  
  20. for k,v in pairs(peripheral.getNames()) do
  21. if peripheral.getType(v) == "modem" and peripheral.call(v, "isWireless") == true then
  22. mo = peripheral.wrap(v)
  23. end
  24. end
  25.  
  26. assert(mo ~= {}, "A wireless modem is needed!")
  27.  
  28. mo.open(337) --Amethyst DNS channel
  29.  
  30. parallel.waitForAll(function()
  31. secure.connectionHandler(mo)
  32. end, function()
  33. while true do
  34. local _, s, sen, rep, msg = os.pullEvent("modem_message")
  35. if msg == "DNSAMETHYST" then
  36. print("DNS ping from ID "..tostring(rep.." (this may be spoofed, no way of verifying!)"))
  37. mo.transmit(338, os.getComputerID(), "DNS::"..tostring(website))
  38. elseif msg:sub(1, 7) == "WHOIS::" then
  39. mo.transmit(338, os.getComputerID(), "IAM::"..tostring(website))
  40. end
  41. end
  42. end,
  43. function()
  44. while true do
  45. local _, id, cid, msg = os.pullEvent("secure_receive")
  46. msg = tostring(msg)
  47. sendTunnel(mo, cid, readf(msg))
  48. end
  49. end)
Advertisement
Add Comment
Please, Sign In to add comment