This commit is contained in:
Ivaylo Novakov 2022-03-14 17:53:02 +01:00
parent 45fa704d77
commit c4dc3222b2
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
1 changed files with 21 additions and 21 deletions

View File

@ -25,6 +25,25 @@ set $skynet_proof '';
set $limit_rate 0; set $limit_rate 0;
access_by_lua_block { access_by_lua_block {
if require("skynet.account").accounts_enabled() then
-- check if portal is in authenticated only mode
if require("skynet.account").is_access_unauthorized() then
return require("skynet.account").exit_access_unauthorized()
end
-- check if portal is in subscription only mode
if require("skynet.account").is_access_forbidden() then
return require("skynet.account").exit_access_forbidden()
end
-- get account limits of currently authenticated user
local limits = require("skynet.account").get_account_limits()
-- apply download speed limit
ngx.var.limit_rate = limits.download
end
}
### -- the block below only makes sense if we are using nginx cache ### -- the block below only makes sense if we are using nginx cache
### if not ngx.var.skyd_disk_cache_enabled then ### if not ngx.var.skyd_disk_cache_enabled then
### local httpc = require("resty.http").new() ### local httpc = require("resty.http").new()
@ -64,27 +83,8 @@ access_by_lua_block {
### ngx.var.nocache = "1" ### ngx.var.nocache = "1"
### end ### end
### end ### end
###
### if require("skynet.account").accounts_enabled() then
### -- check if portal is in authenticated only mode
### if require("skynet.account").is_access_unauthorized() then
### return require("skynet.account").exit_access_unauthorized()
### end
###
### -- check if portal is in subscription only mode
### if require("skynet.account").is_access_forbidden() then
### return require("skynet.account").exit_access_forbidden()
### end
###
### -- get account limits of currently authenticated user
### local limits = require("skynet.account").get_account_limits()
###
### -- apply download speed limit
### ngx.var.limit_rate = limits.download
### end
}
###header_filter_by_lua_block { header_filter_by_lua_block {
### ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. ngx.var.skynet_portal_domain ### ngx.header["Skynet-Portal-Api"] = ngx.var.scheme .. "://" .. ngx.var.skynet_portal_domain
### ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. ngx.var.skynet_server_domain ### ngx.header["Skynet-Server-Api"] = ngx.var.scheme .. "://" .. ngx.var.skynet_server_domain
### ###
@ -104,7 +104,7 @@ access_by_lua_block {
### ngx.shared.nocache:set(ngx.var.skylink_v1, ngx.header["Content-Length"]) ### ngx.shared.nocache:set(ngx.var.skylink_v1, ngx.header["Content-Length"])
### end ### end
### end ### end
###} }
limit_rate_after 512k; limit_rate_after 512k;
limit_rate $limit_rate; limit_rate $limit_rate;