Add geoip data and 451 handler
This commit is contained in:
parent
7ac69b59af
commit
70d3bb6a36
@ -59,6 +59,7 @@ assets = [
|
||||
["reminder-dashboard/dist/index.html", "lib/reminder-rs/static/index.html", "644"],
|
||||
["conf/default.env", "etc/reminder-rs/config.env", "600"],
|
||||
["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"],
|
||||
["conf/geo-asn-country-ipv4.csv", "etc/reminder-rs/geo-asn-country-ipv4.csv", "600"],
|
||||
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
|
||||
]
|
||||
conf-files = [
|
||||
|
12676
conf/gb-ipv4.csv
Normal file
12676
conf/gb-ipv4.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,12 @@ pub(crate) async fn not_found() -> Template {
|
||||
Template::render("errors/404", &map)
|
||||
}
|
||||
|
||||
#[catch(451)]
|
||||
pub(crate) async fn legal_reasons() -> Template {
|
||||
let map: HashMap<String, String> = HashMap::new();
|
||||
Template::render("errors/451", &map)
|
||||
}
|
||||
|
||||
#[catch(413)]
|
||||
pub(crate) async fn payload_too_large() -> JsonValue {
|
||||
json!({"error": "Data too large.", "errors": ["Data too large."]})
|
||||
|
@ -107,6 +107,12 @@ pub async fn initialize(
|
||||
env::var("PATREON_GUILD_ID").expect("`PATREON_GUILD_ID' not supplied");
|
||||
}
|
||||
|
||||
info!("Loading GB IP list");
|
||||
|
||||
let lower_bounds: Vec<u32> = vec![];
|
||||
let upper_bounds: Vec<u32> = vec![];
|
||||
let mut reader = csv::Reader::from_path("gb-ipv4.csv");
|
||||
|
||||
info!("Done!");
|
||||
|
||||
let oauth2_client = BasicClient::new(
|
||||
@ -131,6 +137,7 @@ pub async fn initialize(
|
||||
catchers::not_authorized,
|
||||
catchers::forbidden,
|
||||
catchers::not_found,
|
||||
catchers::legal_reasons,
|
||||
catchers::internal_server_error,
|
||||
catchers::unprocessable_entity,
|
||||
catchers::payload_too_large,
|
||||
|
10
templates/errors/451.html.tera
Normal file
10
templates/errors/451.html.tera
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends "base" %}
|
||||
|
||||
{% block init %}
|
||||
{% set title = "451 Unavailable due to legal reasons" %}
|
||||
|
||||
{% set show_contact = True %}
|
||||
|
||||
{% set page_title = "Unavailable in this region" %}
|
||||
{% set page_subtitle = "This service is unavailable in the UK due to the Online Safety Act. Consider using a VPN to access this service." %}
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user