Files
resty_functions/scripts/lib/upt.lua
T

37 lines
1.1 KiB
Lua
Raw Normal View History

2022-08-23 01:11:25 +08:00
-- 指定模块引用目录,否则无法加载同目录下的其他文件
--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')
2023-05-07 02:00:58 +08:00
function host(s)
return (s.."/"):match("://(.-)/")
end
2022-08-23 01:12:31 +08:00
function _M.upt(uri)
2023-05-07 02:00:58 +08:00
local hostname = host(uri)
2023-05-07 02:08:27 +08:00
local secret;
if (hostname == 'moicen.com') then
secret = ngx.var.upt_moicen_secret
2023-05-07 02:12:37 +08:00
elseif hostname == "alchemy-studio.cn" then
2023-05-07 02:08:27 +08:00
secret = ngx.var.upt_alchemy_secret
2023-05-07 02:12:37 +08:00
elseif hostname == "huiwings.cn" then
2023-05-07 02:08:27 +08:00
secret = ngx.var.upt_huiwings_secret
end
2023-05-07 02:00:58 +08:00
ngx.log(ngx.INFO, 'url...' .. uri .. ' host...' .. hostname .. 'secret...' .. secret)
2022-08-23 01:11:25 +08:00
local duration = ngx.var.upt_duration
local etime = os.time() + duration
local sign = ngx.md5(secret .. '&' .. etime .. '&' .. uri)
2022-08-23 13:55:38 +08:00
ngx.log(ngx.INFO, 'sign...' .. sign .. ' etime..' .. etime)
2022-08-23 01:11:25 +08:00
local upt = string.sub(sign, 13, 13 + 7) .. etime
2022-12-26 22:46:51 +08:00
ngx.log(ngx.INFO, 'upt...' .. upt)
2022-08-23 01:14:19 +08:00
return (upt)
2022-08-23 01:12:31 +08:00
end
2022-08-23 01:11:25 +08:00
return _M