X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/fd31d0bd32886ca4075d4938e374c5c7d72c9b8c..5c59f59f9cbbf5bdde28e44fdbec60c4d9a3c39e:/cookbooks/tile/templates/default/export.erb diff --git a/cookbooks/tile/templates/default/export.erb b/cookbooks/tile/templates/default/export.erb index dfd076252..b91c3957f 100644 --- a/cookbooks/tile/templates/default/export.erb +++ b/cookbooks/tile/templates/default/export.erb @@ -58,6 +58,10 @@ form = cgi.FieldStorage() if not os.environ.has_key('HTTP_USER_AGENT'): os.environ['HTTP_USER_AGENT'] = 'NONE' +# Make sure we have a referer +if not os.environ.has_key('HTTP_REFERER'): + os.environ['HTTP_REFERER'] = 'NONE' + # Get the load average cputimes = [float(n) for n in open("/proc/stat").readline().rstrip().split()[1:-1]] idletime = cputimes[3] / sum(cputimes) @@ -66,11 +70,19 @@ idletime = cputimes[3] / sum(cputimes) if idletime < 0.2: # Abort if the CPU idle time on the machine is too low output_error("The server is too busy at the moment. Please wait a few minutes before trying again.", "503 Service Unavailable") +elif form.getvalue("scale") == "4600": + # Block scraper + output_error("The server is too busy at the moment. Please wait a few minutes before trying again.", "503 Service Unavailable") <% @blocks["user_agents"].each do |user_agent| -%> elif os.environ['HTTP_USER_AGENT'] == '<%= user_agent %>': # Block scraper output_error("The server is too busy at the moment. Please wait a few minutes before trying again.", "503 Service Unavailable") <% end -%> +<% @blocks["referers"].each do |referer| -%> +elif os.environ['HTTP_REFERER'] == '<%= referer %>': + # Block scraper + output_error("The server is too busy at the moment. Please wait a few minutes before trying again.", "503 Service Unavailable") +<% end -%> elif not form.has_key("bbox"): # No bounding box specified output_error("No bounding box specified")