turtle5204

Amethyst Client

Oct 31st, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 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.  
  11. for k,v in pairs(peripheral.getNames()) do
  12. if peripheral.getType(v) == "modem" and peripheral.call(v, "isWireless") == true then
  13. mo = peripheral.wrap(v)
  14. end
  15. end
  16.  
  17. mo.open(338)
  18.  
  19. assert(mo ~= {}, "A wireless modem is needed!")
  20.  
  21. local function n()
  22. print("Amethyst test browser (early dev)")
  23. write("Enter website: ")
  24. local m = read()
  25. mo.transmit(337, os.getComputerID(), "WHOIS::"..tostring(read))
  26. local id = 0
  27. while true do
  28. local _, s, sen, rep, msg = os.pullEvent("modem_message")
  29. if msg == "IAM::"..tostring(m) then
  30. local id = rep
  31. break
  32. end
  33. end
  34. write("Enter page: ")
  35. local p = read()
  36. local cid = secure.openTunnel(mo, id)
  37. secure.sendTunnel(mo, cid, tostring(p))
  38. local code = secure.listenTunnel(cid)
  39. if not code then
  40. secure.closeTunnel(mo, cid)
  41. error("Code not received!", 0)
  42. else
  43. loadstring(code)
  44. secure.closeTunnel(mo, cid)
  45. end
  46. end
  47.  
  48. parallel.waitForAll(function()
  49. secure.connectionHandler(mo)
  50. end, n)
Advertisement
Add Comment
Please, Sign In to add comment