Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local verze = "22.0223.R2"
- local tArgs = { ... }
- local idPC = os.getComputerID()
- local RamCesta = ("/C/system/RAM/dns_check.tmp")
- if fs.exists("/C/system/.core/defmodem") then
- local data = fs.open ("/C/system/.core/defmodem","r")
- modemPos = data.readLine()
- data.close()
- if not modemPos then
- modemPos = "offline"
- end
- else
- modemPos = "offline"
- end
- if not (modemPos == "offline") then
- modem = peripheral.wrap(modemPos)
- modem.open(idPC)
- function zadat()
- term.write("DNSserver ID: ")
- srv_dns = tonumber(read())
- term.write("Domain: ")
- vyhledat(read())
- zadat()
- end
- function vyhledat(domain)
- modem.transmit(tonumber(srv_dns),53,idPC)
- modem.transmit(tonumber(srv_dns),54,domain)
- local a = prijmout()
- local data = fs.open(RamCesta, "w") data.writeLine(a) data.close()
- return a
- end
- function prijmout ()
- timerRX = os.startTimer(5)
- while true do
- local event,p1,p2,p3,p4 = os.pullEvent()
- if event == ("modem_message") then
- if (p3 == 55) then
- if p4 == false then
- return false
- else
- return p4
- end
- end
- elseif event == "timer" then
- error("Connection timed out!")
- print()
- return
- end
- end
- end
- if #tArgs > 0 then
- if (tArgs[1] == "get") then
- srv_dns = tonumber (tArgs[2])
- local a = vyhledat(tArgs[3])
- if (tArgs[4] == "write") then print(a) end
- return a
- else
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.yellow)
- term.clear()
- term.setCursorPos(1,1)
- zadat()
- end
- else
- zadat()
- end
- else
- error("You must configure modem first")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement