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
+3 -1
View File
@@ -20,7 +20,9 @@ server {
set $upyun_directory "music-room";
set $upyun_domain "https://upyun.alchemy-studio.cn";
set $wx_domain "wx.alchemy-studio.cn";
set $upt_secret "0D32E581A445404FA4C306709724FA07";
set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1";
set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18";
set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07";
set $upt_duration 3600;
location / {
+3 -1
View File
@@ -20,7 +20,9 @@ server {
set $upyun_directory "music-room";
set $upyun_domain "https://upyun.huiwings.cn";
set $wx_domain "wx.huiwings.cn";
set $upt_secret "0D32E581A445404FA4C306709724FA07";
set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1";
set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18";
set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07";
set $upt_duration 3600;
location / {
+3 -1
View File
@@ -24,7 +24,9 @@ server {
set $upyun_domain "https://upyun.moicen.com";
set $upyun_cdn "https://upyun.moicen.com/";
set $wx_domain "wx.moicen.com";
set $upt_secret "339666FBB93C46D7B00D9F6E790C6C18";
set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1";
set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18";
set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07";
set $upt_duration 3600;
location / {
+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)