class PowerDNS::DB::Record

Public Instance Methods

update_serial() click to toggle source

We do not use the conventional serial format (e.g. 1970010199), because the serial update counter is limited to two digits which is a problem with DynDNS.

The serial has the format:

<year><month-plus-20><four-digit-update-counter>
e.g. 1970219999

Maximum serial in PowerDNS is 2147483647. See github.com/PowerDNS/pdns/issues/4943

# File lib/powerdns_db_cli/record.rb, line 35
def update_serial
  return if self.type != 'SOA'

  a = self.content.split(' ')

  # Last 4 digits of serial (serial update counter)
  i = a[2][6..-1].to_i

  # 201801 -> 201821
  t = Time.now.strftime('%Y%m').to_i + 20

  # Reset serial update counter if serial is on "old" format (e.g.
  # 2018010199)
  i = 0 if a[2][4..5].to_i <= 12

  # Increment serial update counter
  i += 1

  a[2] = t.to_s + "%04d" % i
  self.content = a.join(' ')
end
update_serial!() click to toggle source
# File lib/powerdns_db_cli/record.rb, line 57
def update_serial!
  update_serial
  save!
end

Private Instance Methods

append_domain_name!() click to toggle source
# File lib/powerdns_db_cli/record.rb, line 64
def append_domain_name!
  if self.name.blank?
    self.name = self.domain.name
  else
    unless self.name.include?(self.domain.name)
      self.name << ".#{self.domain.name}"
    end
  end
end
update_change_date() click to toggle source
# File lib/powerdns_db_cli/record.rb, line 74
def update_change_date
  self.change_date = Time.now.to_i
end
update_soa_serial() click to toggle source
# File lib/powerdns_db_cli/record.rb, line 78
def update_soa_serial
  unless self.type == 'SOA' || @serial_updated || self.domain.slave?
    self.domain.soa_record.update_serial!
    @serial_updated = true
  end
end