Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verze = "22.0222.R3"
- logs = false
- term.clear()
- term.setCursorPos(1,1)
- local idPC = os.getComputerID()
- local ADmode = false
- local IsAdmin = false
- if fs.exists("/C/system/server/rules/AD/") and fs.exists("/C/service/AD.lua") then
- ADmode = true
- end
- 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)
- print("DNS server, ID serveru: "..idPC)
- if ADmode then print"AD is active!" end
- else
- term.setTextColor(colors.red)
- print("Error, you must configure the modem first")
- modem.open("Error")
- end
- function logy(Zlog)
- cas = (textutils.formatTime(os.time(), true))
- local l = fs.open("/C/system/server/rules/AD/log","a")
- l.writeLine(cas..": "..Zlog)
- l.close()
- end
- function bar(styl, text)
- if (styl == "OK") then -- Uspech
- term.setTextColor(colors.green)
- elseif (styl == "FAIL") then -- Neuspesne
- term.setTextColor(colors.red)
- elseif (styl == "INFO") then -- Informativni
- term.setTextColor(colors.lightBlue)
- elseif (styl == "def") then -- defaultni
- term.setTextColor(colors.white)
- elseif (styl == "PRO") then -- Progress
- term.setTextColor(colors.yellow)
- else
- styl = "def"
- term.setTextColor(colors.white)
- end
- if not (styl == "def") then
- zprava = ("["..textutils.formatTime(os.time(), true).."] ["..styl.."] "..text)
- else
- zprava = text
- end
- if logs then
- logy(zprava)
- end
- print (zprava)
- end
- local function defaultV()
- idComp = nil
- d2p = ""
- domain2 = ""
- domain3 = ""
- SrvID = nil
- bar("OK", "Default values set.")
- end
- function prijmout ()
- local _, side, freq, rfreq, message = os.pullEvent('modem_message')
- if (rfreq == 53) then
- bar("INFO", "Data processing request.")
- idComp = message
- bar("PRO", "Computer ID: "..idComp)
- end
- if (rfreq == 54) then
- vyhledat(message)
- end
- prijmout()
- end
- function vyhledat(domain)
- bar("PRO", "I'm looking for a domain: "..domain)
- local q = #domain
- repeat
- q = q-1
- hledej = string.sub(domain,q,q);
- if (hledej==".") then
- domain2 = string.sub(domain,0,q-1);
- domain = string.sub(domain,q+1,#domain)
- q = 0
- end
- until q == 0
- if domain2 ~= "" then
- q = #domain2
- repeat
- q = q-1
- hledej = string.sub(domain2,q,q);
- if (hledej==".") then
- domain3 = string.sub(domain2,0,q-1);
- domain2 = string.sub(domain2,q+1,#domain2)
- q = 0
- end
- until q == 0
- end
- local d1p = ("/C/system/server/rules/DNS/List/"..domain.."/"..domain..".A")
- if fs.exists ("/C/system/server/rules/DNS/List/"..domain.."/") then
- if fs.exists (d1p) then
- local data= fs.open(d1p, "r")
- SrvID = data.readLine()
- data.close()
- else
- SrvID = os.getComputerID()
- end
- bar("INFO", "1st order domain: "..domain.." ID: "..SrvID)
- local d2p = ("/C/system/server/rules/DNS/List/"..domain.."/"..domain2.."/"..domain2..".A")
- if domain2 ~= "" then
- if fs.exists (d2p) then
- local data= fs.open(d2p, "r")
- SrvID = data.readLine()
- data.close()
- bar("INFO", "2nd order domain: "..domain2.." ID: "..SrvID)
- local d3p = ("/C/system/server/rules/DNS/List/"..domain.."/"..domain2.."/"..domain3.."/"..domain3..".A")
- if domain3 ~= "" then
- if fs.exists (d3p) then
- local data= fs.open(d3p, "r")
- SrvID = data.readLine()
- data.close()
- bar("INFO", "3rd order domain: "..domain3.." ID: "..SrvID)
- else
- SrvID = os.getComputerID()
- end
- end
- else SrvID = os.getComputerID()
- end
- end
- end
- if (SrvID == nil) then bar("FAIL", "Domain not found!") end
- modem.transmit(tonumber(idComp),55,SrvID)
- defaultV()
- end
- defaultV()
- prijmout()
Add Comment
Please, Sign In to add comment