fix upt calculate issue

This commit is contained in:
moicen
2023-05-07 02:00:58 +08:00
parent 43d2c1d9b9
commit bd2743e884
4 changed files with 22 additions and 4 deletions
+13 -1
View File
@@ -7,8 +7,20 @@ local _M = {}
--local strip_path = require("strip_path")
--local Upyun = require('upyun')
function host(s)
return (s.."/"):match("://(.-)/")
end
function _M.upt(uri)
local secret = ngx.var.upt_secret
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)