Есть такой код, он выдает имя сервера
function obj.get_hostname()
local ffi = require 'ffi'
if not (pcall(function() return not not ffi.C.gethostname end)) then
ffi.cdef[[ int gethostname(char *name, size_t len); ]]
end
if not (pcall(function() return not not ffi.C.strerror end)) then
ffi.cdef[[ char *strerror(int errnum); ]]
end
local size = 256
local buf =
ffi.new('char[?]',size)
local ret = ffi.C.gethostname(buf,size)
if ret == 0 then
return (string.gsub(ffi.string(buf), "%z+$", ""))
else
return ffi.string(ffi.C.strerror(ffi.errno()))
end
end
А как бы получить IP сервера?