dnslex

package
v0.6.65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Zone file
	EOF uint8 = iota
	Error
	String
	Blank
	Quote
	Newline
	Rrtype
	Owner
	Class
	DirOrigin   // $ORIGIN
	DirTTL      // $TTL
	DirInclude  // $INCLUDE
	DirGenerate // $GENERATE
)

Tokenize a RFC 1035 zone file. The tokenizer will normalize it: * Add ownernames if they are left blank; * Suppress sequences of spaces; * Make each RR fit on one line (Newline is send as last) * Handle braces - anywhere.

Variables

This section is empty.

Functions

func Tokens

func Tokens(c *Lexer) []string

Tokens is used to gather up the remaining tokens and hand them to a custom Scan method for external RRs.

func TypeToInt added in v0.6.41

func TypeToInt(token string) (uint16, bool)

Extract the rr number from TYPExxx. There is no length check, it is assumed the caller has checked the prefix is at least "TYPE" (4)

Types

type Lex

type Lex struct {
	Token  string // text of the token
	As     uint8  // create an RR (asRR), an EDNS0 (asCode) or DSO RR (asStateful)
	Value  uint8  // value: String, Blank, etc.
	Line   uint32 // line in the file
	Column uint16 // column in the file
	Torc   uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
}

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer tokenizes the zone data, so that the grammar implemented in ZoneParser can parse RRs out of an RFC 1035 styled text file.

func New

func New(r io.Reader, StringToType, StringToCode, StringToClass map[string]uint16) *Lexer

New returns a pointer to a new Lexer.

func (*Lexer) Blank added in v0.6.62

func (zl *Lexer) Blank() bool

Blank consumes the next token and returns false if the token was not a blacnk

func (*Lexer) ClearKey added in v0.6.54

func (zl *Lexer) ClearKey(key uint8)

func (*Lexer) Err

func (zl *Lexer) Err() error

func (*Lexer) Key added in v0.6.54

func (zl *Lexer) Key(key uint8) bool

func (*Lexer) Next

func (zl *Lexer) Next() (Lex, bool)

func (*Lexer) Peek

func (zl *Lexer) Peek() Lex

func (*Lexer) SetKey added in v0.6.54

func (zl *Lexer) SetKey(key uint8)

type ScanError

type ScanError struct {
	Err string
	Lex Lex
}

ScanError is a scanning error, it has no presentation format, it is expected that ParseError will be wrapping this error, and uses Err and Lex directly.

func Discard added in v0.6.43

func Discard(c *Lexer) *ScanError

Discard discards the rest of the "line".

func (*ScanError) Error

func (e *ScanError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL