Previously, the only integration was conversion procs for inet and cidr. This adds: * conversion procs for inet[] and cidr[] (previously these used IPAddr instead of NetAddr) * typecasting support * schema type validation * NetAddr object literalization and bound variable support Update the update_firewall_rules prog to handle NetAddr instead of IPAddr instances. This gives inet/cidr/inet[]/cidr[] columns a schema type when they did not have a schema type previously, which breaks the usage of literal string values for array columns in model objects. Literal strings are expressions and not values, and therefore shouldn't be used as model object values, they only work due to implementation details if a schema type is not present. Fix cases where literal strings were used as model object values, making all affected code simpler.
28 lines
649 B
Ruby
28 lines
649 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "socket"
|
|
require "open-uri"
|
|
require "net/http"
|
|
class Prog::ResolveGloballyBlockedDnsnames < Prog::Base
|
|
label def wait
|
|
GloballyBlockedDnsname.each do |globally_blocked_dnsname|
|
|
dns_name = globally_blocked_dnsname.dns_name
|
|
|
|
begin
|
|
addr_info = Socket.getaddrinfo(dns_name, nil)
|
|
rescue SocketError
|
|
Clog.emit("Failed to resolve blocked dns name") { {dns_name: dns_name} }
|
|
next
|
|
end
|
|
|
|
ip_list = addr_info.map do |info|
|
|
info[3]
|
|
end.uniq
|
|
|
|
globally_blocked_dnsname.update(ip_list:, last_check_at: Time.now)
|
|
end
|
|
|
|
nap 60 * 60
|
|
end
|
|
end
|