pure.bend checks
raw source on the hub · import bend-kit-dns@0.8.0.1/pure.bend as Pure
Pure DNS codec and host lookup model.
2 imports
import Base import bend-kit-bytes@0.3.3.2/bytes.bend as Bytes
Types
type Step source · line 95 · raw
Data
One step through a name: continue at the next label or stop after the name.
GoStep
Stop@ok:Bool -> Step
type RR source · line 154 · raw
Data
RRBadRR
RRA@ip:String -> RR
RRSkipRR
Definitions
def label.ok source · line 8 · raw
@+l:String -> Bool
def label.ascii source · line 12 · raw
@s:String -> Bool
def labels.ok source · line 19 · raw
@xs:List<&2, String> -> Bool
def labels.len source · line 27 · raw
@xs:List<&2, String> -> @+n:U32 -> U32
QNAME's length without its final zero octet.
def written source · line 35 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor
The query buffer is allocated to its exact size before writing.
def label.put source · line 39 · raw
@s:String -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor
def labels.put source · line 46 · raw
@xs:List<&2, String> -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor
def query.done source · line 53 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes, U32) -> Maybe<&1, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes>
def query.if source · line 57 · raw
@+id:U32 -> @+xs:List<&2, String> -> @ok:Bool -> Maybe<&1, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes>
def query.labels source · line 74 · raw
@+id:U32 -> @+xs:List<&2, String> -> Maybe<&1, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes>
§2.3.4: a name is at most 255 octets in wire form, its final zero octet included.
def strip_dot.if source · line 77 · raw
@+s:String -> @dot:Bool -> String
def strip_dot source · line 84 · raw
@+s:String -> String
def query source · line 88 · raw
@id:U32 -> @name:String -> Maybe<&1, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes>
RFC 1035 §4.1: a standard query for the A record of name.
def name.advance source · line 99 · raw
@stop:Bool -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step)
def name.label source · line 108 · raw
@ok:Bool -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> @l:U32 -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step)
§4.1.4: zero terminates, 192..255 starts a pointer, 64..191 is reserved.
def name.pointer source · line 115 · raw
@pointer:Bool -> @+l:U32 -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step)
def name.step.of source · line 122 · raw
@+l:U32 -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step)
def name.step source · line 129 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step)
def name.walk source · line 137 · raw
@fuel:Nat -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Step) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool)
def name.skip source · line 151 · raw
@c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool)
§2.3.4: a name is at most 255 octets, so retain the 128-step limit.
def dotted source · line 159 · raw
@+ip:U32 -> String
def rr.a source · line 162 · raw
@limit:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.CursorLimit -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.data.some source · line 170 · raw
@a:Bool -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> @limit:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.CursorLimit -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.data source · line 178 · raw
@a:Bool -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&1, 0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.CursorLimit>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
Bound RDATA in the original packed buffer, then resume after the entire region.
def rr.len source · line 186 · raw
@+ty:U32 -> @+cl:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.ttl source · line 194 · raw
@+ty:U32 -> @+cl:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.cl source · line 202 · raw
@+ty:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.ty source · line 210 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr.name source · line 218 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
def rr source · line 227 · raw
@c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR)
§4.1.3: NAME, TYPE, CLASS, TTL, RDLENGTH, RDATA.
def answers.scan source · line 231 · raw
@fuel:Nat -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, RR) -> Maybe<&2, String>
fuel = records left. The first A record wins; CNAMEs before it are skipped.
def question.end source · line 246 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool)
QTYPE and QCLASS follow the name.
def questions source · line 254 · raw
@fuel:Nat -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool)
def body.go source · line 266 · raw
@+an:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Bool) -> Maybe<&2, String>
def body.an source · line 275 · raw
@+qd:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Maybe<&2, String>
The header ends with NSCOUNT and ARCOUNT; questions follow.
def body.qd source · line 283 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Maybe<&2, String>
def flags.ok source · line 292 · raw
@+f:U32 -> Bool
§4.1.1: QR set, opcode QUERY, not truncated, RCODE 0.
def head.flags.if source · line 295 · raw
@ok:Bool -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Maybe<&2, String>
def head.flags source · line 302 · raw
@r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Maybe<&2, String>
def head.id.if source · line 310 · raw
@ok:Bool -> @c:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor -> Maybe<&2, String>
def head.id source · line 317 · raw
@+id:U32 -> @r:Pair(0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Cursor, Maybe<&2, U32>) -> Maybe<&2, String>
def answer source · line 326 · raw
@id:U32 -> @msg:0x166a26e38c43ec5f8fe3323f5850e3d8/bytes.Bytes -> Maybe<&2, String>
The IPv4 address the response gives for the query with this id.
def nameservers.add source · line 332 · raw
@+line:String -> @rest:List<&2, String> -> @hit:Bool -> List<&2, String>
def nameservers.go source · line 339 · raw
@xs:List<&2, String> -> List<&2, String>
def nameservers source · line 347 · raw
@conf:String -> List<&2, String>
Every nameserver line, in file order.
def nameserver.first source · line 350 · raw
@xs:List<&2, String> -> Maybe<&2, String>
def nameserver source · line 358 · raw
@conf:String -> Maybe<&2, String>
The first nameserver line of a resolv.conf.
def list.append source · line 361 · raw
@xs:List<&2, String> -> @ys:List<&2, String> -> List<&2, String>
def list.one source · line 368 · raw
@+x:String -> List<&2, String>
def list.any source · line 371 · raw
@+xs:List<&2, String> -> Bool
def list.first source · line 378 · raw
@xs:List<&2, String> -> Maybe<&2, String>
def ipv4.go source · line 385 · raw
@s:String -> Bool
def ipv4 source · line 393 · raw
@+s:String -> Bool
Digits and dots; TCP.connect rejects anything else that is not an address.
def ipv6.ch source · line 396 · raw
@+c:U32 -> Bool
def ipv6.go source · line 403 · raw
@s:String -> Bool
def ipv6.has source · line 410 · raw
@s:String -> Bool
def ipv6 source · line 418 · raw
@+s:String -> Bool
Bracket-free IPv6 text; connect validates the address.
def ip source · line 421 · raw
@+s:String -> Bool
def hosts.on_line source · line 424 · raw
@+name:String -> @ns:List<&2, String> -> Bool
def hosts.line.all source · line 431 · raw
@+name:String -> @xs:List<&2, String> -> List<&2, String>
def hosts.sp source · line 438 · raw
@+c:U32 -> @tab:Bool -> U32
def hosts.flat source · line 445 · raw
@s:String -> String
def hosts.scan.all source · line 452 · raw
@xs:List<&2, String> -> @+name:String -> @acc:List<&2, String> -> List<&2, String>
def hosts.all source · line 461 · raw
@+name:String -> @text:String -> List<&2, String>
Every address for name in an /etc/hosts file. The name is already lowercase.
def hosts source · line 465 · raw
@+name:String -> @text:String -> Maybe<&2, String>
First address for name in an /etc/hosts file. The name is already lowercase.
def lookup.split source · line 468 · raw
@+s:String -> List<&2, String>
def resolve.literal.all source · line 472 · raw
@+host:String -> List<&2, String>
Literals and localhost without the OS (for laws and fast paths).
def resolve.literal source · line 477 · raw
@+host:String -> Maybe<&2, String>