cli

package
v0.0.0-...-5eed73c Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

* ZDNS Copyright 2024 Regents of the University of Michigan * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License.

  • ZDNS Copyright 2024 Regents of the University of Michigan *

  • Licensed under the Apache License, Version 2.0 (the "License"); you may not

  • use this file except in compliance with the License. You may obtain a copy

  • of the License at http://www.apache.org/licenses/LICENSE-2.0 *

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an "AS IS" BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or

  • implied. See the License for the specific language governing

  • permissions and limitations under the License.

  • ZDNS Copyright 2020 Regents of the University of Michigan *

  • Licensed under the Apache License, Version 2.0 (the "License"); you may not

  • use this file except in compliance with the License. You may obtain a copy

  • of the License at http://www.apache.org/licenses/LICENSE-2.0 *

  • Unless required by applicable law or agreed to in writing, software

  • distributed under the License is distributed on an "AS IS" BASIS,

  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or

  • implied. See the License for the specific language governing

  • permissions and limitations under the License.

* ZDNS Copyright 2024 Regents of the University of Michigan * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License.

Index

Constants

View Source
const (
	BINDVERSION = "BINDVERSION"
)

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetValidLookups

func GetValidLookups() map[string]struct{}

func RegisterLookupModule

func RegisterLookupModule(name string, lm LookupModule)

func Run

func Run(gc CLIConf)

Types

type BasicLookupModule

type BasicLookupModule struct {
	IsIterative          bool
	LookupAllNameServers bool
	DNSType              uint16
	DNSClass             uint16
	Description          string
}

func (*BasicLookupModule) CLIInit

func (lm *BasicLookupModule) CLIInit(gc *CLIConf, rc *zdns.ResolverConfig) error

func (*BasicLookupModule) GetDescription

func (lm *BasicLookupModule) GetDescription() string

func (*BasicLookupModule) Help

func (lm *BasicLookupModule) Help() string

func (*BasicLookupModule) Lookup

func (lm *BasicLookupModule) Lookup(resolver *zdns.Resolver, lookupName string, nameServer *zdns.NameServer) (interface{}, zdns.Trace, zdns.Status, error)

func (*BasicLookupModule) NewFlags

func (lm *BasicLookupModule) NewFlags() interface{}

func (*BasicLookupModule) Validate

func (lm *BasicLookupModule) Validate(args []string) error

type CLIConf

type CLIConf struct {
	GeneralOptions
	NetworkOptions
	InputOutputOptions
	QueryOptions
	OutputGroups       []string
	TimeFormat         string
	NameServers        []string // recursive resolvers if not in iterative mode, root servers/servers to start iteration if in iterative mode
	Domains            []string // if user provides domain names as arguments, dig-style
	LocalAddrSpecified bool
	LocalAddrs         []net.IP
	ClientSubnet       *dns.EDNS0_SUBNET
	InputHandler       InputHandler
	OutputHandler      OutputHandler
	CLIModule          string                  // the module name as passed in by the user
	ActiveModuleNames  []string                // names of modules that are active in this invocation of zdns. Mostly used with MULTIPLE
	ActiveModules      map[string]LookupModule // map of module names to modules
	Class              uint16
}
var GC CLIConf

type GeneralOptions

type GeneralOptions struct {
	LookupAllNameServers bool   `long:"all-nameservers" description:"Perform the lookup via all the nameservers for the domain."`
	CacheSize            int    `long:"cache-size" default:"10000" description:"how many items can be stored in internal recursive cache"`
	GoMaxProcs           int    `long:"go-processes" default:"0" description:"number of OS processes (GOMAXPROCS by default)"`
	IterationTimeout     int    `` /* 154-byte string literal not displayed */
	IterativeResolution  bool   `long:"iterative" description:"Perform own iteration instead of relying on recursive resolver"`
	MaxDepth             int    `long:"max-depth" default:"10" description:"how deep should we recurse when performing iterative lookups"`
	NameServerMode       bool   `` /* 146-byte string literal not displayed */
	NameServersString    string `` /* 165-byte string literal not displayed */
	UseNanoseconds       bool   `long:"nanoseconds" description:"Use nanosecond resolution timestamps in output"`
	NetworkTimeout       int    `long:"network-timeout" default:"2" description:"timeout for round trip network operations, in seconds"`
	DisableFollowCNAMEs  bool   `long:"no-follow-cnames" description:"do not follow CNAMEs/DNAMEs in the lookup process"`
	Retries              int    `` /* 136-byte string literal not displayed */
	Threads              int    `short:"t" long:"threads" default:"100" description:"number of lightweight go threads"`
	Timeout              int    `long:"timeout" default:"20" description:"timeout for resolving a individual name, in seconds"`
	Version              bool   `long:"version" short:"v" description:"Print the version of zdns and exit"`
}

GeneralOptions core options for all ZDNS modules Order here is the order they'll be printed to the user, so preserve alphabetical order

type InputHandler

type InputHandler interface {
	FeedChannel(in chan<- string, wg *sync.WaitGroup) error
}

type InputOutputOptions

type InputOutputOptions struct {
	AlexaFormat                  bool   `long:"alexa" description:"is input file from Alexa Top Million download"`
	BlacklistFilePath            string `long:"blacklist-file" description:"blacklist file for servers to exclude from lookups"`
	DNSConfigFilePath            string `long:"conf-file" default:"/etc/resolv.conf" description:"config file for DNS servers"`
	MultipleModuleConfigFilePath string `short:"c" long:"multi-config-file" description:"config file path for multiple module"`
	IncludeInOutput              string `` /* 161-byte string literal not displayed */
	InputFilePath                string `short:"f" long:"input-file" default:"-" description:"names to read, defaults to stdin"`
	LogFilePath                  string `long:"log-file" default:"-" description:"where should JSON logs be saved, defaults to stderr"`
	MetadataFilePath             string `long:"metadata-file" description:"where should JSON metadata be saved, defaults to no metadata output. Use '-' for stderr."`
	MetadataFormat               bool   `` /* 131-byte string literal not displayed */
	OutputFilePath               string `short:"o" long:"output-file" default:"-" description:"where should JSON output be saved, defaults to stdout"`
	NameOverride                 string `long:"override-name" description:"name overrides all passed in names. Commonly used with --name-server-mode."`
	NamePrefix                   string `long:"prefix" description:"name to be prepended to what's passed in (e.g., www.)"`
	ResultVerbosity              string `` /* 128-byte string literal not displayed */
	Verbosity                    int    `long:"verbosity" default:"3" description:"log verbosity: 1 (lowest)--5 (highest)"`
}

InputOutputOptions options for controlling the input and output behavior of zdns. Applicable to all modules.

type LookupModule

type LookupModule interface {
	CLIInit(gc *CLIConf, rc *zdns.ResolverConfig) error
	Lookup(resolver *zdns.Resolver, lookupName string, nameServer *zdns.NameServer) (interface{}, zdns.Trace, zdns.Status, error)
	Help() string                 // needed to satisfy the ZCommander interface in ZFlags.
	GetDescription() string       // needed to add a command to the parser, printed to the user. Printed to the user when they run the help command for a given module
	Validate(args []string) error // needed to satisfy the ZCommander interface in ZFlags
	NewFlags() interface{}        // needed to satisfy the ZModule interface in ZFlags
}

func GetLookupModule

func GetLookupModule(name string) (LookupModule, error)

type Metadata

type Metadata struct {
	Names           int                           `json:"names"`
	Lookups         int                           `json:"lookups"`
	Status          map[string]int                `json:"statuses"`
	StartTime       string                        `json:"start_time"`
	EndTime         string                        `json:"end_time"`
	NameServers     []string                      `json:"name_servers"`
	Timeout         int                           `json:"timeout"`
	Retries         int                           `json:"retries"`
	Conf            *CLIConf                      `json:"conf"`
	ZDNSVersion     string                        `json:"zdns_version"`
	CacheStatistics *zdns.CacheStatisticsMetadata `json:"cache_statistics,omitempty"`
}

type NetworkOptions

type NetworkOptions struct {
	IPv4TransportOnly     bool   `long:"4" description:"utilize IPv4 query transport only, incompatible with --6"`
	IPv6TransportOnly     bool   `long:"6" description:"utilize IPv6 query transport only, incompatible with --4"`
	DNSOverHTTPS          bool   `long:"https" description:"Use DNS over HTTPS for lookups, mutually exclusive with --udp-only, --iterative, and --tls"`
	LocalAddrString       string `long:"local-addr" description:"comma-delimited list of local addresses to use, serve as the source IP for outbound queries"`
	LocalIfaceString      string `long:"local-interface" description:"local interface to use"`
	DisableRecycleSockets bool   `` /* 141-byte string literal not displayed */
	PreferIPv4Iteration   bool   `` /* 160-byte string literal not displayed */
	PreferIPv6Iteration   bool   `` /* 163-byte string literal not displayed */
	RootCAsFile           string `` /* 157-byte string literal not displayed */
	TCPOnly               bool   `long:"tcp-only" description:"Only perform lookups over TCP"`
	DNSOverTLS            bool   `long:"tls" description:"Use DNS over TLS for lookups, mutually exclusive with --udp-only, --iterative, and --https"`
	UDPOnly               bool   `long:"udp-only" description:"Only perform lookups over UDP"`
	VerifyServerCert      bool   `long:"verify-server-cert" description:"Verify the server's certificate when using DNS over TLS or DNS over HTTPS"`
}

NetworkOptions options for controlling the network behavior. Applicable to all modules.

type OutputHandler

type OutputHandler interface {
	WriteResults(results <-chan string, wg *sync.WaitGroup) error
}

type QueryOptions

type QueryOptions struct {
	CheckingDisabled   bool   `long:"checking-disabled" description:"Sends DNS packets with the CD bit set"`
	ClassString        string `long:"class" default:"INET" description:"DNS class to query. Options: INET, CSNET, CHAOS, HESIOD, NONE, ANY."`
	ClientSubnetString string `long:"client-subnet" description:"Client subnet in CIDR format for EDNS0."`
	Dnssec             bool   `long:"dnssec" description:"Requests DNSSEC records by setting the DNSSEC OK (DO) bit"`
	UseNSID            bool   `long:"nsid" description:"Request NSID."`
}

QueryOptions affect the fields of the actual DNS queries. Applicable to all modules.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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