mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
try to deal with rate limiting
This commit is contained in:
parent
3d73172246
commit
8a109f7b4b
3 changed files with 20 additions and 1 deletions
1
Gemfile
1
Gemfile
|
@ -47,6 +47,7 @@ gem 'acme-client', {
|
||||||
git: 'https://github.com/jhass/acme-client.git',
|
git: 'https://github.com/jhass/acme-client.git',
|
||||||
branch: 'no_activesupport'
|
branch: 'no_activesupport'
|
||||||
}
|
}
|
||||||
|
gem 'http'
|
||||||
|
|
||||||
platform :mri, :rbx do
|
platform :mri, :rbx do
|
||||||
gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic
|
gem 'magic' # sudo apt-get install file, For OSX: brew install libmagic
|
||||||
|
|
|
@ -97,8 +97,15 @@ GEM
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
hoe (3.14.2)
|
hoe (3.14.2)
|
||||||
rake (>= 0.8, < 11.0)
|
rake (>= 0.8, < 11.0)
|
||||||
|
http (2.0.1)
|
||||||
|
addressable (~> 2.3)
|
||||||
|
http-cookie (~> 1.0)
|
||||||
|
http-form_data (~> 1.0.1)
|
||||||
|
http_parser.rb (~> 0.6.0)
|
||||||
http-cookie (1.0.2)
|
http-cookie (1.0.2)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
|
http-form_data (1.0.1)
|
||||||
|
http_parser.rb (0.6.0)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
io-extra (1.2.8)
|
io-extra (1.2.8)
|
||||||
jimson-temp (0.9.5)
|
jimson-temp (0.9.5)
|
||||||
|
@ -280,6 +287,7 @@ DEPENDENCIES
|
||||||
geoip
|
geoip
|
||||||
hiredis
|
hiredis
|
||||||
hoe (= 3.14.2)
|
hoe (= 3.14.2)
|
||||||
|
http
|
||||||
io-extra
|
io-extra
|
||||||
jdbc-postgres
|
jdbc-postgres
|
||||||
jruby-openssl
|
jruby-openssl
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class LetsEncryptWorker
|
class LetsEncryptWorker
|
||||||
class NotAuthorizedYetError < StandardError; end
|
class NotAuthorizedYetError < StandardError; end
|
||||||
class VerificationTimeoutError < StandardError; end
|
class VerificationTimeoutError < StandardError; end
|
||||||
|
class VerifyNotFoundWithDomain < StandardError; end
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
sidekiq_options queue: :lets_encrypt_worker, retry: 100, backtrace: true
|
sidekiq_options queue: :lets_encrypt_worker, retry: 100, backtrace: true
|
||||||
|
|
||||||
|
@ -36,9 +37,18 @@ class LetsEncryptWorker
|
||||||
FileUtils.mkdir_p File.join(site.base_files_path, File.dirname(challenge.filename)) if index == 0
|
FileUtils.mkdir_p File.join(site.base_files_path, File.dirname(challenge.filename)) if index == 0
|
||||||
File.write File.join(site.base_files_path, challenge.filename), challenge.file_content
|
File.write File.join(site.base_files_path, challenge.filename), challenge.file_content
|
||||||
|
|
||||||
|
# Ensure that both domains work before sending request. Let's Encrypt has a low
|
||||||
|
# pending request limit, and it takes one week (!) to flush out.
|
||||||
|
sleep 2
|
||||||
|
challenge_url = "#{domain}/#{challenge.filename}"
|
||||||
|
["http://#{challenge_url}", "http://www.#{challenge_url}"].each do |url|
|
||||||
|
res = HTTP.follow.get(url)
|
||||||
|
raise VerifyNotFoundWithDomain unless res.status == 200
|
||||||
|
end
|
||||||
|
|
||||||
challenge.request_verification
|
challenge.request_verification
|
||||||
|
|
||||||
sleep 1
|
sleep 60
|
||||||
attempts = 0
|
attempts = 0
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Add table
Reference in a new issue