Fix antiproxying (again).
Fuck it, just hardcode it. They rewrite certain parts of our markup so we can't rely on anything in the html.
This commit is contained in:
@@ -272,6 +272,8 @@ module ApplicationHelper
|
|||||||
current_item_data_attributes = data_attributes_for(current_item, model_name, model_attributes)
|
current_item_data_attributes = data_attributes_for(current_item, model_name, model_attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config_data_attributes = data_attributes_for(Danbooru.config, "config", [:hostname, :domain])
|
||||||
|
|
||||||
controller_param = params[:controller].parameterize.dasherize
|
controller_param = params[:controller].parameterize.dasherize
|
||||||
action_param = params[:action].parameterize.dasherize
|
action_param = params[:action].parameterize.dasherize
|
||||||
|
|
||||||
@@ -282,8 +284,11 @@ module ApplicationHelper
|
|||||||
controller: controller_param,
|
controller: controller_param,
|
||||||
action: action_param,
|
action: action_param,
|
||||||
layout: controller.class.send(:_layout),
|
layout: controller.class.send(:_layout),
|
||||||
|
"current-user-ip-addr": request.remote_ip,
|
||||||
**current_user_data_attributes,
|
**current_user_data_attributes,
|
||||||
**current_item_data_attributes.to_h
|
**current_item_data_attributes.to_h,
|
||||||
|
**config_data_attributes,
|
||||||
|
"config-environment": Rails.env,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ $(function() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Danbooru.config["enable_antiproxying?"] && !location.hostname.endsWith(Danbooru.config.domain)) {
|
if (location.hostname.endsWith("danbooru.me")) {
|
||||||
location.hostname = Danbooru.config.hostname;
|
location.hostname = "danbooru.donmai.us";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,6 @@
|
|||||||
window.Danbooru = {};
|
window.Danbooru = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
window.Danbooru.config = <%= [:hostname, :domain, :enable_antiproxying?].map { |opt| [opt, Danbooru.config.send(opt)] }.to_h.to_json.html_safe %>;
|
|
||||||
window.Danbooru.notice = Danbooru.Utility.notice;
|
window.Danbooru.notice = Danbooru.Utility.notice;
|
||||||
window.Danbooru.error = Danbooru.Utility.error;
|
window.Danbooru.error = Danbooru.Utility.error;
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ module Danbooru
|
|||||||
Socket.gethostname
|
Socket.gethostname
|
||||||
end
|
end
|
||||||
|
|
||||||
# The canonical base domain for the site, e.g. donmai.us.
|
|
||||||
def domain
|
|
||||||
hostname
|
|
||||||
end
|
|
||||||
|
|
||||||
# Contact email address of the admin.
|
# Contact email address of the admin.
|
||||||
def contact_email
|
def contact_email
|
||||||
"webmaster@#{hostname}"
|
"webmaster@#{hostname}"
|
||||||
@@ -472,11 +467,6 @@ module Danbooru
|
|||||||
def redis_url
|
def redis_url
|
||||||
"redis://localhost:6379"
|
"redis://localhost:6379"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Try to prevent copycat sites from proxying our site and inserting ads or phishing passwords.
|
|
||||||
def enable_antiproxying?
|
|
||||||
Rails.env.production?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class EnvironmentConfiguration
|
class EnvironmentConfiguration
|
||||||
|
|||||||
Reference in New Issue
Block a user