0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-06-03 00:44:33 +02:00

Add extra 'tools' to wifibox devel install. Improve logging.

This commit is contained in:
Wouter R 2013-10-08 16:55:50 +02:00
parent 37783f3f06
commit 8991845427
3 changed files with 28 additions and 32 deletions

View File

@ -55,9 +55,15 @@ if [ $? -gt 0 ]; then
cat <<-EOM >> $IPKG_INSTROOT/root/.profile cat <<-EOM >> $IPKG_INSTROOT/root/.profile
# DO NOT MODIFY - this block of lines has been added by the wifibox package. # DO NOT MODIFY - this block of lines has been added by the wifibox package.
alias d='ls -la'
alias d3dapi='/usr/share/lua/wifibox/script/d3dapi' alias d3dapi='/usr/share/lua/wifibox/script/d3dapi'
alias encore='ulimit -c unlimited' alias encore='ulimit -c unlimited'
alias wopkg='opkg -f /usr/share/lua/wifibox/opkg.conf' alias wopkg='opkg -f /usr/share/lua/wifibox/opkg.conf'
loop() {
if [ \$# -lt 2 ]; then echo "Please supply a delay and a command."; return 1; fi
DELAY=\$1; shift; while true; do \$@; sleep \$DELAY; done
}
EOM EOM
fi fi

View File

@ -137,14 +137,13 @@ local function init(environment)
setupLogger() setupLogger()
local dbgText = "" local dbgText = ""
if confDefaults.DEBUG_API and confDefaults.DEBUG_PCALLS then dbgText = "pcall and api" if confDefaults.DEBUG_API and confDefaults.DEBUG_PCALLS then dbgText = "pcall+api"
elseif confDefaults.DEBUG_API then dbgText = "api" elseif confDefaults.DEBUG_API then dbgText = "api"
elseif confDefaults.DEBUG_PCALL then dbgText = "pcall" elseif confDefaults.DEBUG_PCALL then dbgText = "pcall"
end end
if dbgText ~= "" then dbgText = " (" .. dbgText .. " debugging enabled)" end if dbgText ~= "" then dbgText = " (" .. dbgText .. " debugging)" end
log:info("===========================") log:info("=======rest api" .. dbgText .. "=======")
log:info("Wifibox CGI handler started" .. dbgText)
if (environment['REQUEST_METHOD'] == 'POST') then if (environment['REQUEST_METHOD'] == 'POST') then
local n = tonumber(environment['CONTENT_LENGTH']) local n = tonumber(environment['CONTENT_LENGTH'])
@ -194,7 +193,7 @@ local function main(environment)
.. "/" .. (rq:getRealApiFunctionName() or "<unknown>")) .. "/" .. (rq:getRealApiFunctionName() or "<unknown>"))
if rq:getRequestMethod() ~= 'CMDLINE' then if rq:getRequestMethod() ~= 'CMDLINE' then
log:info("remote IP/port: " .. rq:getRemoteHost() .. "/" .. rq:getRemotePort()) log:info("remote IP/port: " .. rq:getRemoteHost() .. "/" .. rq:getRemotePort())
log:debug("user agent: " .. rq:getUserAgent()) --log:debug("user agent: " .. rq:getUserAgent())
end end
local response, err = rq:handle() local response, err = rq:handle()

View File

@ -97,31 +97,22 @@ end
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
function _M.parsequeryNoRegex (query, args) function _M.parsequeryNoRegex (query, args)
if type(query) == "string" then if type(query) == "string" then
local log = require('util.logger')
local util = require('util.utils')
log:info("parsequeryNoRegex")
--log:info(" query: " .. util.dump(query))
--log:info(" args: " .. util.dump(args))
local insertfield, unescape = _M.insertfield, _M.unescape local insertfield, unescape = _M.insertfield, _M.unescape
local k = 1 local k = 1
while true do while true do
local v = query:find('=', k+1, true) -- look for '=', assuming a key of at least 1 character and do not perform pattern matching local v = query:find('=', k+1, true) -- look for '=', assuming a key of at least 1 character and do not perform pattern matching
--log:info(" v: " .. util.dump(v))
if not v then break end -- no k/v pairs left if not v then break end -- no k/v pairs left
local key = query:sub(k, v-1) local key = query:sub(k, v-1)
log:info(" key: " .. util.dump(key))
v = v + 1 v = v + 1
--log:info(" >v: " .. util.dump(v))
local ampersand = query:find('&', v, true) local ampersand = query:find('&', v, true)
--log:info(" ampersand: " .. util.dump(ampersand))
if not ampersand then ampersand = 0 end -- 0 will become -1 in the substring call below...meaning end of string if not ampersand then ampersand = 0 end -- 0 will become -1 in the substring call below...meaning end of string
local value = query:sub(v, ampersand - 1) local value = query:sub(v, ampersand - 1)
--log:info(" value: " .. util.dump(value))
insertfield (args, unescape(key), unescape(value)) insertfield (args, unescape(key), unescape(value))
if ampersand == 0 then break end -- we couldn't find any ampersands anymore so this was the last k/v if ampersand == 0 then break end -- we couldn't find any ampersands anymore so this was the last k/v