Advertisement
trapcodien

oc_libdns.lua

Aug 22nd, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local fs = require "filesystem"
  2. local text = require "text"
  3.  
  4. local path = "/etc/hosts"
  5.  
  6. local dns = {}
  7.  
  8. function dns.get(name)
  9.   if not fs.exists(path) then return nil end
  10.   local file = io.open(path, "r")
  11.   for line in file:lines() do
  12.     line = text.tokenize(line)
  13.     if line[2] == name then return line[1] end
  14.   end
  15.   io.close(file)
  16.   return nil
  17. end
  18.  
  19. return dns
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement