 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: recursive-query ( query servers -- message )
+: (recursive-query) ( query servers -- message )
   dup random                                 ! query servers server
   pick query->message 0 >>rd                 ! query servers server message
   over ask-server                            ! query servers server message

          remove                             ! message query servers
          dup empty?
            [ 2drop ]
            [ rot drop recursive-query ]
          if
        ]
      }
      [                                      ! query servers server message sym
        drop nip nip                         ! query message
        extract-ns-ips                       ! query ips
        recursive-query
      ]
    }
  case ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


:  name-hits? ( message -- message ? ) dup  name-hits empty? not ;
: cname-hits? ( message -- message ? ) dup cname-hits empty? not ;

! : name->ip/server ( name -- ip-or-f )
!   A IN query boa root-dns-servers recursive-query ! message
!     {
!       { [ name-hits? ]  [ name-hits  random rdata>>          ] }
!       { [ cname-hits? ] [ cname-hits random rdata>> name->ip ] }
!       { [ t           ] [ drop f ] }
!     }
!   cond ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: name->ip/server ( name -- ip-or-f )
  A IN query boa recursive-query ! message
    {
      { [ name-hits? ]  [ name-hits  random rdata>>          ] }
      { [ cname-hits? ] [ cname-hits random rdata>> name->ip ] }
