33 lines
1.1 KiB
Lua
33 lines
1.1 KiB
Lua
-- 指定模块引用目录,否则无法加载同目录下的其他文件
|
|
--package.path = package.path .. ';/usr/local/opt/openresty/nginx/scripts/?.lua';
|
|
package.path = package.path .. ';<SCRIPT_PATH>/?.lua';
|
|
|
|
local _M = {}
|
|
|
|
--local strip_path = require("strip_path")
|
|
--local Upyun = require('upyun')
|
|
|
|
function host(s)
|
|
return (s.."/"):match("://(.-)/")
|
|
end
|
|
|
|
|
|
function _M.upt(uri)
|
|
local hostname = host(uri)
|
|
|
|
local upt_table = {}
|
|
upt_table["moicen.com"] = ngx.var.upt_moicen_secret,
|
|
upt_table["alchemy-studio.cn"] = ngx.var.upt_alchemy_secret,
|
|
upt_table["huiwings.cn"] = ngx.var.upt_huiwings_secret
|
|
local secret = upt_table[hostname]
|
|
ngx.log(ngx.INFO, 'url...' .. uri .. ' host...' .. hostname .. 'secret...' .. secret)
|
|
local duration = ngx.var.upt_duration
|
|
local etime = os.time() + duration
|
|
local sign = ngx.md5(secret .. '&' .. etime .. '&' .. uri)
|
|
ngx.log(ngx.INFO, 'sign...' .. sign .. ' etime..' .. etime)
|
|
local upt = string.sub(sign, 13, 13 + 7) .. etime
|
|
ngx.log(ngx.INFO, 'upt...' .. upt)
|
|
return (upt)
|
|
end
|
|
|
|
return _M |