mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 16:17:29 +00:00
Notify users if they were blocked due to proxy
This commit is contained in:
parent
f0a28d485f
commit
d4f9af44b0
@ -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.
|
||||||
|
|
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
|
Loading…
Reference in New Issue
Block a user