АМ
Size: a a a
АМ
EM
AH
DB
АП
АП
АП
DN
DN
DB
АП
АП
DB
АП
DB
limit = 3
ip_list = {}
function on_stop(client_id, ip)
local client_id_list = ip_list[ip]
for i,v in ipairs(client_id_list) do
if v == client_id then
table.remove(client_id_list, i)
break
end
end
if #client_id_list == 0 then
ip_list[ip] = nil
end
end
function on_start(client_id, ip)
local client_id_list = ip_list[ip]
if not client_id_list then
client_id_list = {}
ip_list[ip] = client_id_list
end
table.insert(client_id_list, client_id)
if #client_id_list > limit then
local first_client_id = client_id_list[1]
local c = http_output_client_list[first_client_id]
c.server:close(c.client)
end
end
function auth_request(client_id, request, callback)
if not request then
local c = http_output_client_list[client_id]
on_stop(client_id, c.request.addr)
return nil
end
on_start(client_id, request.addr)
callback(true)
DB