(BTW, I know that the Rednet API has a small DNS inside of it. Don't mention it. Please.)
Browser (or is it so far?):
rednet.open("top") print("DNS ID:") local dns = tonumber(read()) print("URL:") local url = read() rednet.send(dns, url, "REQUEST_ID") local event, id, msg, protocol = os.pullEvent("rednet_message") if protocol == "ID" then print(url.." resolved to "..msg) end
DNS:
local tArgs = {...} if #tArgs < 1 then error("dns <wireless modem side>", 0) end local mSide = tArgs[1] local modem = nil if peripheral.getType(mSide) ~= "modem" then error("No modem detected on the "..mSide.." side of the computer...", 0) else modem = peripheral.wrap(mSide) if not modem.isWireless() then error("The modem on the "..mSide.." side of the computer is wired!", 0) end end local ids = { ["cabbage.com"] = 3 } rednet.open(mSide) while true do local event, id, msg, protocol = os.pullEvent("rednet_message") if protocol == "REQUEST_ID" then print("Computer #"..id.." requested ID of "..msg) for i=1, #ids do if ids[msg] then rednet.send(id, ids[msg], "ID") print("Replied with "..ids[msg].." to computer #"..id) end end end end