Add antiproxying protection.

Try to prevent malicious sites like danbooru.me or idanbooru.com from
proxying our site and inserting ads. If we detect that we're not running
on the real site, then we redirect to the real site.
This commit is contained in:
evazion
2020-06-01 13:41:15 -05:00
parent 6b490cacba
commit 8b46d00b9b
2 changed files with 19 additions and 1 deletions

View File

@@ -19,6 +19,14 @@ $(function() {
$('#notice').fadeOut("fast");
e.preventDefault();
});
const CANONICAL_DOMAIN = <%= Danbooru.config.domain.to_json.html_safe %>;
const CANONICAL_HOSTNAME = <%= Danbooru.config.hostname.to_json.html_safe %>;
const ENABLE_ANTIPROXYING = <%= Danbooru.config.enable_antiproxying?.to_json.html_safe %>;
if (ENABLE_ANTIPROXYING && !location.hostname.endsWith(CANONICAL_DOMAIN)) {
location.hostname = CANONICAL_HOSTNAME;
}
});
window.submitInvisibleRecaptchaForm = function () {