1
0
镜像自地址 https://git.sr.ht/~cadence/bibliogram 已同步 2025-07-01 17:02:05 +00:00

Notify users if they were blocked due to proxy

这个提交包含在:
Cadence Ember 2020-07-31 03:19:55 +12:00
父节点 f0a28d485f
当前提交 d4f9af44b0
找不到此签名对应的密钥
GPG 密钥 ID: 128B99B1B74A6412
共有 3 个文件被更改,包括 21 次插入2 次删除

查看文件

@ -38,5 +38,14 @@ function add(req, count) {
return limiter.add(identifier, count) return limiter.add(identifier, count)
} }
function isProxyNetwork(req) {
if (!constants.quota.enabled) return false // no need to try to perform detection if we didn't even load the lists
const ip = getIPFromReq(req)
const identifier = getIdentifier(ip)
return identifier === "proxy"
}
module.exports.remaining = remaining module.exports.remaining = remaining
module.exports.add = add module.exports.add = add
module.exports.isProxyNetwork = isProxyNetwork

查看文件

@ -159,7 +159,8 @@ module.exports = [
} else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) { } else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) {
return render(403, "pug/age_gated.pug", {settings}) return render(403, "pug/age_gated.pug", {settings})
} else if (error === constants.symbols.QUOTA_REACHED) { } else if (error === constants.symbols.QUOTA_REACHED) {
return render(429, "pug/quota_reached.pug") const isProxyNetwork = quota.isProxyNetwork(req)
return render(429, "pug/quota_reached.pug", {isProxyNetwork})
} else { } else {
throw error throw error
} }
@ -302,7 +303,8 @@ module.exports = [
} else if (error === constants.symbols.RATE_LIMITED) { } else if (error === constants.symbols.RATE_LIMITED) {
return render(503, "pug/blocked_graphql.pug") return render(503, "pug/blocked_graphql.pug")
} else if (error === constants.symbols.QUOTA_REACHED) { } else if (error === constants.symbols.QUOTA_REACHED) {
return render(429, "pug/quota_reached.pug") const isProxyNetwork = quota.isProxyNetwork(req)
return render(429, "pug/quota_reached.pug", {isProxyNetwork})
} else { } else {
throw error throw error
} }

查看文件

@ -1,3 +1,5 @@
//- Needs isProxyNetwork
include includes/error.pug include includes/error.pug
doctype html doctype html
@ -10,5 +12,11 @@ html
| Each person has a limited number of requests to Bibliogram. | Each person has a limited number of requests to Bibliogram.
| You have reached that limit. You cannot load any more data on this instance. | You have reached that limit. You cannot load any more data on this instance.
| Your quota will reset automatically after some time has passed. | Your quota will reset automatically after some time has passed.
if isProxyNetwork
|
|
| However, this website has detected that you are using a proxy network, like Tor or a VPN.
| To prevent bot abuse, all users on proxy networks share the same request quota.
|
| |
| |