 io.encodings.utf8 io.sockets io.sockets.private
 io.streams.byte-array io.timeouts kernel make math math.bitwise
 math.parser namespaces nested-comments random sequences
-slots.syntax splitting system vectors vocabs.loader ;
+slots.syntax splitting system vectors vocabs.loader strings ;
 IN: dns
 
 : with-input-seek ( n seek-type quot -- )

        } cleave
    ] B{ } append-outputs-as ;

: rr>byte-array ( rr -- byte-array )
    [
        {

: dns-AAAA-query ( domain -- message ) AAAA IN <query> dns-query ;
: dns-MX-query ( domain -- message ) MX IN <query> dns-query ;
: dns-NS-query ( domain -- message ) NS IN <query> dns-query ;
: dns-TXT-query ( domain -- message ) TXT IN <query> dns-query ;

: TXT-message>strings ( message -- strings )
    answer-section>>
    [ rdata>>
        [
            binary <byte-reader> [
                [
                    read1 [
                        read , t
                    ] [
                        f
                    ] if*
                ] loop
            ] with-input-stream
        ] { } make [ >string ] map
    ] map ;

: TXT. ( domain -- )
    dns-TXT-query TXT-message>strings [ [ print ] each ] each ;

: reverse-lookup ( reversed-ip -- message )
    PTR IN <query> dns-query ;
