From f6d35ed57d156f4225338a89372c8e83721e46c9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 29 Apr 2022 23:27:03 +0200 Subject: Remove IP matching from e-mail domain blocks (#18190) Clear out e-mail domain blocks created from automatically resolved DNS records --- .../email_domain_block_refresh_scheduler.rb | 31 ---------------------- 1 file changed, 31 deletions(-) delete mode 100644 app/workers/scheduler/email_domain_block_refresh_scheduler.rb (limited to 'app/workers') diff --git a/app/workers/scheduler/email_domain_block_refresh_scheduler.rb b/app/workers/scheduler/email_domain_block_refresh_scheduler.rb deleted file mode 100644 index e0ad89866..000000000 --- a/app/workers/scheduler/email_domain_block_refresh_scheduler.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -class Scheduler::EmailDomainBlockRefreshScheduler - include Sidekiq::Worker - include Redisable - - sidekiq_options retry: 0 - - def perform - Resolv::DNS.open do |dns| - dns.timeouts = 5 - - EmailDomainBlock.find_each do |email_domain_block| - ips = begin - if ip?(email_domain_block.domain) - [email_domain_block.domain] - else - resources = dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::A).to_a + dns.getresources(email_domain_block.domain, Resolv::DNS::Resource::IN::AAAA).to_a - resources.map { |resource| resource.address.to_s } - end - end - - email_domain_block.update(ips: ips, last_refresh_at: Time.now.utc) - end - end - end - - def ip?(str) - str =~ Regexp.union([Resolv::IPv4::Regex, Resolv::IPv6::Regex]) - end -end -- cgit