local t ={} --引入相关包local socket = require("socket") functiont.main() local a,b=pcall(t.execute); if a==false then logerror(a,b); end end functiont.execute() logdebug("start"); --local m = os.execute("ifconfig"); --logdebug(m); --local s= io.popen('ifconfig') --local b = s:read("*all") --logdebug(b); --local t=os.execute(ip addr|grep inet|grep -v inet6|grep eth0|awk '{print $2}'|awk -F "/" '{print $1}' >> /log/app/localhost.tmp); --local t=os.execute("ifconfig eth0 |grep 'inet addr'| cut -f 2 -d ':'|cut -f 1 -d ' ' >> /log/app/localhost.tmp "); logdebug(os.time()); local ip,resolved =socket.dns.toip(socket.dns.gethostname()); logdebug(ip); logdebug(resolved); logdebug(t.GetAdd(socket.dns.gethostname())); end functiont.GetAdd(hostname) local ip, resolved =socket.dns.toip(hostname) local ListTab ={} for k, v in ipairs(resolved.ip) do logdebug(k.."|"..v); table.insert(ListTab, v) end returnListTab end return t
LUA中获得服务器IP
免责声明:文章转载自《LUA中获得服务器IP》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=