campus-total-block/domain-to-search.rb

23 lines
441 B
Ruby
Raw Permalink Normal View History

2024-02-12 01:42:36 +02:00
#!/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(" , ")} )"