Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: more rate limiting ignores #11332

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/ProductOpener/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ if (not defined $flavor) {
die("The PRODUCT_OPENER_FLAVOR_SHORT environment variable must be set.");
}

# %options will be redefined by autoload below
# but we need it to avoid Perl complaining
%ProductOpener::Config:: % options = ();
Comment on lines +35 to +37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephanegigandet our commits did cross, and so I realize this wasn't needed !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexgarel ah right, here is a PR to remove it: #11345


use Module::Load;

autoload("ProductOpener::Config_$flavor");
Expand Down Expand Up @@ -174,4 +178,35 @@ $ProductOpener::Config::options{other_servers} = {
}
};

=head2 Rate limiting options

=cut

# Number of requests per minutes for the search API
$ProductOpener::Config::options{rate_limit_search} = 10;
# Number of requests per minutes for all facets for anonymous users
$ProductOpener::Config::options{rate_limit_facet_products_unregistered} = 5;
# Number of requests per minutes for facets for registered users
$ProductOpener::Config::options{rate_limit_facet_products_registered} = 10;
# Number of requests per minutes for facets for bots
$ProductOpener::Config::options{rate_limit_facet_products_crawl_bot} = 10;
# Number of requests per minutes for facet tags (list of tags with count) for anonymous users
$ProductOpener::Config::options{rate_limit_facet_tags_unregistered} = 5;
$ProductOpener::Config::options{rate_limit_facet_tags_registered} = 10;
$ProductOpener::Config::options{rate_limit_facet_tags_crawl_bot} = 10;
$ProductOpener::Config::options{rate_limit_product} = 100;

# Rate limit allow list
$ProductOpener::Config::options{rate_limit_allow_list} = {
'146.59.148.140' => 1, # OVH1
'51.210.154.203' => 1, # OVH2
'51.210.32.79' => 1, # OVH3
'46.105.72.120' => 1, # proxy ovh1
'213.36.253.215' => 1, # proxy off1
'213.36.253.214' => 1, # proxy off2
'213.36.253.206' => 1, # off1
'213.36.253.208' => 1, # off2
'45.147.209.254' => 1, # Moji server (actually OSM proxy, Moji only has ipv6)
};

1;
24 changes: 0 additions & 24 deletions lib/ProductOpener/Config_off.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1605,28 +1605,4 @@ $options{sample_product_code} = "093270067481501"; # A good product for you -
#$options{sample_product_code_language_de} = "20884680"; # Waffeln Sondey
#$options{sample_product_code_country_at_language_de} = "5411188119098"; # Natur miss kokosnuss Alpro

## Rate limiting ##

# Number of requests per minutes for the search API
$options{rate_limit_search} = 10;
# Number of requests per minutes for all facets for anonymous users
$options{rate_limit_facet_products_unregistered} = 5;
# Number of requests per minutes for facets for registered users
$options{rate_limit_facet_products_registered} = 10;
# Number of requests per minutes for facets for bots
$options{rate_limit_facet_products_crawl_bot} = 10;
# Number of requests per minutes for facet tags (list of tags with count) for anonymous users
$options{rate_limit_facet_tags_unregistered} = 5;
$options{rate_limit_facet_tags_registered} = 10;
$options{rate_limit_facet_tags_crawl_bot} = 10;
$options{rate_limit_product} = 100;

# Rate limit allow list
$options{rate_limit_allow_list} = {
'146.59.148.140' => 1, # OVH1
'51.210.154.203' => 1, # OVH2
'51.210.32.79' => 1, # OVH3
'45.147.209.254' => 1, # Moji server (actually OSM proxy, Moji only has ipv6)
};

1;
Loading