labzone

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package labzone parses -simulate-zone scenario files (#76). A scenario defines exact names, records, wildcards and failures for a lab exercise. A local DNS server answers from it, so a lab runs the real resolver, wildcard detection, -rate pacing and reliability guard, deterministically and without sending traffic off the machine.

The format is line based; # starts a comment. Names are relative to the scanned domain: @ is the domain itself, and *.dev is a wildcard covering every name under dev that the file does not define.

$DELAY 20ms            # every answer waits this long
$REFUSE-ABOVE 50       # answer REFUSED past 50 queries a second
@        A        192.0.2.1
www      A        192.0.2.10
www      AAAA     2001:db8::10
shop     CNAME    www                    # relative target
blog     CNAME    ghost.example.net.     # absolute target (trailing dot)
*.dev    A        192.0.2.99
slow     TIMEOUT                         # never answered
broken   SERVFAIL                        # also REFUSED, NXDOMAIN

Names the file does not define are NXDOMAIN (or NODATA when a deeper name exists under them). The server stands in for the student's resolver and the scenario is the whole world, so names outside the scanned domain (an external CNAME target, say) are NXDOMAIN too.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Zone

type Zone struct {
	Delay       time.Duration // $DELAY
	RefuseAbove int           // $REFUSE-ABOVE; 0 means no limit
	// contains filtered or unexported fields
}

Zone is a parsed scenario.

func Load

func Load(path string) (*Zone, error)

Load parses the scenario file at path.

func Parse

func Parse(r io.Reader) (*Zone, error)

Parse reads a scenario.

func (*Zone) Answer

func (z *Zone) Answer(rel, origin string) dnsserver.Reply

Answer returns the reply for a name relative to the scanned domain ("" is the domain itself). origin is the scanned domain, used to resolve relative CNAME targets.

func (*Zone) Handler

func (z *Zone) Handler(origins []string) dnsserver.Handler

Handler answers queries for any of origins (the scanned domains) from the zone, applying $DELAY and $REFUSE-ABOVE. Other names are NXDOMAIN.

Jump to

Keyboard shortcuts

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