campus-total-block/domain-to-search.rb
2024-02-12 01:42:36 +02:00

23 lines
441 B
Ruby
Executable File

#!/usr/bin/evn ruby
def generate_domain_array(domain)
parts = domain.split(".")
l = parts.length
domains = []
domains << parts.join(".")
i = 0
while i < l do
domains << ".#{parts[i..-1].join(".")}"
i = i +1
end
domains
end
domain = ARGV[0]
domains = generate_domain_array(domain)
puts "Domain Array query:"
puts "SELECT * FROM squidconf.totalBlock WHERE dstdom IN ( #{domains.map { |d| "'#{d}'" }.join(" , ")} )"