mirror of
https://github.com/TangentFoxy/lovebird.git
synced 2025-07-28 11:02:19 +00:00
Changed callback funcs to be lowercase to match everything else
This commit is contained in:
14
lovebird.lua
14
lovebird.lua
@@ -30,7 +30,7 @@ lovebird.pages["index"] = [[
|
|||||||
-- Handle console input
|
-- Handle console input
|
||||||
if req.parsedbody.input then
|
if req.parsedbody.input then
|
||||||
local str = req.parsedbody.input
|
local str = req.parsedbody.input
|
||||||
xpcall(function() assert(loadstring(str))() end, lovebird.onError)
|
xpcall(function() assert(loadstring(str))() end, lovebird.onerror)
|
||||||
end
|
end
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -410,12 +410,12 @@ function lovebird.print(...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lovebird.onError(err)
|
function lovebird.onerror(err)
|
||||||
trace("ERROR:", err)
|
trace("ERROR:", err)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lovebird.onRequest(req, client)
|
function lovebird.onrequest(req, client)
|
||||||
local page = req.parsedurl.path
|
local page = req.parsedurl.path
|
||||||
page = page ~= "" and page or "index"
|
page = page ~= "" and page or "index"
|
||||||
-- Handle "page not found"
|
-- Handle "page not found"
|
||||||
@@ -428,12 +428,12 @@ function lovebird.onRequest(req, client)
|
|||||||
str = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" ..
|
str = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" ..
|
||||||
lovebird.template(lovebird.pages[page],
|
lovebird.template(lovebird.pages[page],
|
||||||
{ lovebird = lovebird, req = req })
|
{ lovebird = lovebird, req = req })
|
||||||
end, lovebird.onError)
|
end, lovebird.onerror)
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lovebird.onConnect(client)
|
function lovebird.onconnect(client)
|
||||||
-- Create request table
|
-- Create request table
|
||||||
local requestptn = "(%S*)%s*(%S*)%s*(%S*)"
|
local requestptn = "(%S*)%s*(%S*)%s*(%S*)"
|
||||||
local req = {}
|
local req = {}
|
||||||
@@ -461,7 +461,7 @@ function lovebird.onConnect(client)
|
|||||||
-- Parse request line's url
|
-- Parse request line's url
|
||||||
req.parsedurl = lovebird.parseurl(req.url)
|
req.parsedurl = lovebird.parseurl(req.url)
|
||||||
-- Handle request; get data to send
|
-- Handle request; get data to send
|
||||||
local data, index = lovebird.onRequest(req), 0
|
local data, index = lovebird.onrequest(req), 0
|
||||||
-- Send data
|
-- Send data
|
||||||
while index < #data do
|
while index < #data do
|
||||||
index = index + client:send(data, index)
|
index = index + client:send(data, index)
|
||||||
@@ -478,7 +478,7 @@ function lovebird.update()
|
|||||||
client:settimeout(2)
|
client:settimeout(2)
|
||||||
local addr = client:getsockname()
|
local addr = client:getsockname()
|
||||||
if lovebird.checkwhitelist(addr) then
|
if lovebird.checkwhitelist(addr) then
|
||||||
xpcall(function() lovebird.onConnect(client) end, function() end)
|
xpcall(function() lovebird.onconnect(client) end, function() end)
|
||||||
else
|
else
|
||||||
trace("got non-whitelisted connection attempt: ", addr)
|
trace("got non-whitelisted connection attempt: ", addr)
|
||||||
client:close()
|
client:close()
|
||||||
|
Reference in New Issue
Block a user