vendor/bundle/ruby/2.7.0/gems/dnsruby-1.61.5/lib/dnsruby/zone_transfer.rb
#  The nameserver to use for the zone transfer - defaults to system config
The nameserver to use for the zone transfer - defaults to system config
The nameserver to use for the zone transfer - defaults to system config
def do_transfer(zone, server) 
      @transfer_type = Types.new(@transfer_type)
      @state = :InitialSoa
      socket = Socket.tcp(server, @port, @src_address, connect_timeout: @connect_timeout)
      begin
        msg = Message.new(zone, @transfer_type, @klass)
        if @transfer_type == Types.IXFR
          rr = RR.create("#{zone} 0 IN SOA" + '0 0 %u 0 0 0 0' % @serial)
          msg.add_authority(rr)
        end
        send_message(socket, msg)
        while (@state != :End)
          response = receive_message(socket)
          if (@state == :InitialSoa)
            rcode = response.rcode
            if (rcode != RCode.NOERROR)
              if (@transfer_type == Types.IXFR &&
                    rcode == RCode.NOTIMP)
                Dnsruby.log.debug("IXFR DID NOT WORK (rcode = NOTIMP) - TRYING AXFR!!")
                @state = :InitialSoa
                @transfer_type=Types.AXFR
                msg = Message.new(zone, @transfer_type, @klass)
                send_message(socket, msg)
                next
              end
              raise ResolvError.new(rcode.string);
            end
            if (response.question[0].qtype != @transfer_type)
              raise ResolvError.new("invalid question section")
            end
            if (response.header.ancount == 0 && @transfer_type == Types.IXFR)
              Dnsruby.log.debug("IXFR DID NOT WORK (ancount = 0) - TRYING AXFR!!")
              @transfer_type=Types.AXFR
              @state = :InitialSoa
              msg = Message.new(zone, @transfer_type, @klass)
              send_message(socket, msg)
              next
            end
          end
          response.each_answer { |rr|
            parseRR(rr)
          }
          if (@state == :End &&
                response.tsigstate == :Intermediate)
            raise ResolvError.new("last message must be signed")
          end
          if (@state == :End && @tsig)
            if (response.tsigstate != :Verified)
              @last_tsigstate = :Failed
              raise ResolvError.new("Zone transfer not correctly signed")
            end
            @last_tsigstate = :Verified
          end
        end
        socket.close
        if (@axfr!=nil)
          return @axfr
        end
        return @ixfr
      rescue Exception => e
        socket.close
        raise e
      end
    end
def do_transfer ( zone , server ) @transfer_type = Types . new ( @transfer_type ) @state = :InitialSoa socket = Socket . tcp ( server , @port , @src_address , connect_timeout : @connect_timeout ) begin msg = Message . new ( zone , @transfer_type , @klass ) if @transfer_type == Types . IXFR rr = RR . create ( "#{zone} 0 IN SOA" + '0 0 %u 0 0 0 0' % @serial ) msg . add_authority ( rr ) end send_message ( socket , msg ) while ( @state != :End ) response = receive_message ( socket ) if ( @state == :InitialSoa ) rcode = response . rcode if ( rcode != RCode . NOERROR ) if ( @transfer_type == Types . IXFR && rcode == RCode . NOTIMP ) Dnsruby . log . debug ( "IXFR DID NOT WORK (rcode = NOTIMP) - TRYING AXFR!!" ) @state = :InitialSoa @transfer_type = Types . AXFR msg = Message . new ( zone , @transfer_type , @klass ) send_message ( socket , msg ) next end raise ResolvError . new ( rcode . string ) ; end if ( response . question [ 0 ] . qtype != @transfer_type ) raise ResolvError . new ( "invalid question section" ) end if ( response . header . ancount == 0 && @transfer_type == Types . IXFR ) Dnsruby . log . debug ( "IXFR DID NOT WORK (ancount = 0) - TRYING AXFR!!" ) @transfer_type = Types . AXFR @state = :InitialSoa msg = Message . new ( zone , @transfer_type , @klass ) send_message ( socket , msg ) next end end response . each_answer { | rr | parseRR ( rr ) } if ( @state == :End && response . tsigstate == :Intermediate ) raise ResolvError . new ( "last message must be signed" ) end if ( @state == :End && @tsig ) if ( response . tsigstate != :Verified ) @last_tsigstate = :Failed raise ResolvError . new ( "Zone transfer not correctly signed" ) end @last_tsigstate = :Verified end end socket . close if ( @axfr != nil ) return @axfr end return @ixfr rescue Exception => e socket . close raise e end end
The nameserver to use for the zone transfer - defaults to system config
The nameserver to use for the zone transfer - defaults to system config
#:nodoc: all # socket = TCPSocket.new(server, @port, @src_address) #  Send an initial query #  IXFR didn't work - let's try AXFR #  Send an initial AXFR query #  IXFR didn't work - let's try AXFR #  Send an initial AXFR query #  This could return with an IXFR response, or an AXFR response. #  If it fails completely, then try to send an AXFR query. #  Once the query has been sent, then enter the main response loop. #  Unless we know we're definitely AXFR, we should be prepared for either IXFR or AXFR #  AXFR response : The first and the last RR of the response is the SOA record of the zone. #                  The whole zone is returned inbetween. #  IXFR response : one or more difference sequences is returned.  The list of difference #                  sequences is preceded and followed by a copy of the server's current #                  version of the SOA. #                  Each difference sequence represents one update to the zone (one SOA #                  serial change) consisting of deleted RRs and added RRs.  The first RR #                  of the deleted RRs is the older SOA RR and the first RR of the added #                  RRs is the newer SOA RR.
zone
<not_specific>
server
<not_specific>