• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Resolve IP

olav1ar

New Member
Joined
Aug 1, 2008
Messages
55
Reaction score
0
Is there a bether way of resolving ip on Linux (Ubuntu) ?

Code:
<globalevent name="resolve_ip" interval="60" event="script" value="resolve_ip.lua"/>

Code:
require("socket")

function onThink(interval, lastExecution, thinkInterval)

	local begin_time=socket.gettime()
	local master= socket.dns.toip(getConfigInfo('ip'))
	local page_retrieve_time=(socket.gettime()-begin_time)

	
	local row = db.getResult("SELECT `id`, timestamp, ip, count FROM z_resolve_ip order by id desc limit 1;")

	if(row:getID() == -1) then
		db.executeQuery("INSERT z_resolve_ip (timestamp, ip, count) VALUES (" .. os.time() .. ", '" .. master .. "', 1, " .. os.time() .. ");")
		return true
	end
	
	local ID = row:getDataString("id")
	local ip = row:getDataString("ip")
	local count = row:getDataString("count")

	if(ip == master) then
		db.executeQuery("update z_resolve_ip set count = count+1, lasttime = " .. os.time() .. " where id = " .. ID .. ";")
	else
		doSetGameState(GAMESTATE_CLOSED)
		db.executeQuery("INSERT z_resolve_ip (timestamp, ip, count, lasttime) VALUES (" .. os.time() .. ", '" .. master .. "', 1, " .. os.time() .. ");")
		doSetGameState(GAMESTATE_SHUTDOWN)
	end
	
	return true

end
 
Since TFS dont alowe new connections, after my ip adresses changes, i needed to make this script so the server auto shutsown, and starts again in the .sh loop ;)
 
Back
Top