(feat)Completions and documentation #78
27 changed files with 373 additions and 155 deletions
|
@ -9,17 +9,17 @@ local testing(version, arch) = {
|
|||
},
|
||||
steps: [
|
||||
{
|
||||
name: "submodules",
|
||||
image: "alpine/git",
|
||||
name: "compile",
|
||||
image: "golang:" + version,
|
||||
commands: [
|
||||
"git submodule update --init --recursive"
|
||||
]
|
||||
"make awl"
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "lint",
|
||||
image: "rancher/drone-golangci-lint:latest",
|
||||
depends_on: [
|
||||
"submodules",
|
||||
"compile",
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ local testing(version, arch) = {
|
|||
"make test-ci"
|
||||
],
|
||||
depends_on: [
|
||||
"submodules",
|
||||
"lint",
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ local testing(version, arch) = {
|
|||
"make fuzz",
|
||||
],
|
||||
depends_on: [
|
||||
"submodules",
|
||||
"lint",
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -68,7 +68,6 @@ local release() = {
|
|||
image: "alpine/git",
|
||||
commands : [
|
||||
"git fetch --tags",
|
||||
"git submodule update --init --recursive"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -95,9 +94,9 @@ local release() = {
|
|||
|
||||
[
|
||||
testing("1.19", "amd64"),
|
||||
testing("1.19", "arm64"),
|
||||
testing("1.18", "amd64"),
|
||||
testing("1.18", "arm64"),
|
||||
// testing("1.19", "arm64"),
|
||||
// testing("1.18", "amd64"),
|
||||
// testing("1.18", "arm64"),
|
||||
|
||||
release()
|
||||
]
|
5
.github/workflows/ghrelease.yaml
vendored
5
.github/workflows/ghrelease.yaml
vendored
|
@ -17,6 +17,11 @@ jobs:
|
|||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
|
||||
- name: Release with GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v3
|
||||
with:
|
||||
|
|
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
|
@ -22,4 +22,4 @@ jobs:
|
|||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Test
|
||||
run: go test -race -v ./...
|
||||
run: make test-ci
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "doc/wiki"]
|
||||
path = doc/wiki
|
||||
url = ../awl.wiki
|
||||
[submodule "pkg/awl-dns-git"]
|
||||
path = pkg/awl-dns-git
|
||||
url = https://aur.archlinux.org/awl-dns-git.git
|
||||
|
|
|
@ -32,7 +32,7 @@ linters:
|
|||
- predeclared
|
||||
- revive
|
||||
- staticcheck
|
||||
# - testpackage
|
||||
#- testpackage
|
||||
- whitespace
|
||||
- wrapcheck
|
||||
- wsl
|
||||
|
@ -49,26 +49,25 @@ linters-settings:
|
|||
errorCode: 1
|
||||
warningCode: 1
|
||||
rules:
|
||||
# rules can be uncommented after https://github.com/golangci/golangci-lint/issues/2997 is fixed
|
||||
- name: blank-imports
|
||||
- name: context-as-argument
|
||||
# - name: context-keys-type
|
||||
- name: context-keys-type
|
||||
- name: dot-imports
|
||||
- name: duplicated-imports
|
||||
- name: error-return
|
||||
- name: error-strings
|
||||
- name: error-naming
|
||||
# - name: errorf
|
||||
- name: errorf
|
||||
- name: exported
|
||||
- name: if-return
|
||||
- name: increment-decrement
|
||||
# - name: modifies-value-receiver
|
||||
- name: modifies-value-receiver
|
||||
- name: package-comments
|
||||
- name: range
|
||||
- name: receiver-naming
|
||||
# - name: time-naming
|
||||
# - name: unexported-return
|
||||
# - name: var-declaration
|
||||
- name: time-naming
|
||||
- name: unexported-return
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
|
||||
issues:
|
||||
|
|
10
GNUmakefile
10
GNUmakefile
|
@ -1,4 +1,5 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# GNU Makefile allowing for building on Windows (with GNU Make)
|
||||
|
||||
include template.mk
|
||||
|
||||
|
@ -6,13 +7,10 @@ ifeq ($(OS),Windows_NT)
|
|||
EXE := $(PROG).exe
|
||||
else
|
||||
EXE := $(PROG)
|
||||
|
||||
endif
|
||||
|
||||
$(PROG): $(SOURCES)
|
||||
$(GO) build -o $(EXE) $(GOFLAGS) .
|
||||
|
||||
## install: installs awl
|
||||
.PHONY: install
|
||||
ifeq ($(OS),Windows_NT)
|
||||
install:
|
||||
$(GO) install $(GOFLAGS) .
|
||||
|
@ -20,6 +18,6 @@ else
|
|||
install: all
|
||||
install -Dm755 $(PROG) $(DESTDIR)$(PREFIX)/$(BIN)/$(PROG)
|
||||
install -Dm644 doc/$(PROG).1 $(DESTDIR)$(MAN)/man1/$(PROG).1
|
||||
# completions need to go in one specific place :)
|
||||
install -Dm644 completions/zsh.zsh $(DESTDIR)/$(PREFIX)/$(SHARE)/zsh/site-functions/_$(PROG)
|
||||
endif
|
||||
|
||||
.PHONY: install
|
10
Makefile
10
Makefile
|
@ -3,12 +3,12 @@
|
|||
|
||||
include template.mk
|
||||
|
||||
$(PROG): $(SOURCES)
|
||||
$(GO) build -o $(PROG) $(GOFLAGS) .
|
||||
EXE := $(PROG)
|
||||
|
||||
## install: installs awl and the manpage, RUN AS ROOT
|
||||
## install: installs awl
|
||||
.PHONY: install
|
||||
install: all
|
||||
install -Dm755 $(PROG) $(DESTDIR)$(PREFIX)/$(BIN)/$(PROG)
|
||||
install -Dm644 doc/$(PROG).1 $(DESTDIR)$(MAN)/man1/$(PROG).1
|
||||
|
||||
.PHONY: install
|
||||
# completions need to go in one specific place :)
|
||||
install -Dm644 completions/zsh.zsh $(DESTDIR)/$(PREFIX)/$(SHARE)/zsh/site-functions/_$(PROG)
|
|
@ -34,6 +34,7 @@ Dependencies:
|
|||
|
||||
- Go >= 1.18
|
||||
- GNU/BSD make or Plan 9 mk (if using the makefile/mkfile)
|
||||
- scdoc (optional, for man page)
|
||||
|
||||
Using `go install` (recommended):
|
||||
|
||||
|
@ -45,7 +46,7 @@ Using the makefile:
|
|||
|
||||
```sh
|
||||
make
|
||||
sudo make install
|
||||
make && sudo make install
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
@ -59,4 +60,4 @@ Found a bug or want a new feature? Create an issue
|
|||
|
||||
### Licence
|
||||
|
||||
See [LICENCE](./LICENCE)
|
||||
Revised BSD, See [LICENCE](./LICENCE)
|
||||
|
|
|
@ -35,14 +35,14 @@ func ParseCLI(version string) (util.Options, error) {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
// CLI flag
|
||||
// CLI flags
|
||||
var (
|
||||
port = flag.Int("port", 0, "`port` to make DNS query (default: 53 for UDP/TCP, 853 for TLS/QUIC)", flag.OptShorthand('p'), flag.OptDisablePrintDefault(true))
|
||||
query = flag.String("query", "", "domain name to `query` (default: .)", flag.OptShorthand('q'))
|
||||
class = flag.String("class", "IN", "DNS `class` to query", flag.OptShorthand('c'))
|
||||
qType = flag.String("qType", "", "`type` to query (default: A)", flag.OptShorthand('t'))
|
||||
|
||||
ipv4 = flag.Bool("4", false, "force IPv4", flag.OptShorthandStr("4"))
|
||||
ipv4 = flag.Bool("4", false, "force IPv4", flag.OptShorthand('4'))
|
||||
ipv6 = flag.Bool("6", false, "force IPv6", flag.OptShorthand('6'))
|
||||
reverse = flag.Bool("reverse", false, "do a reverse lookup", flag.OptShorthand('x'))
|
||||
|
||||
|
@ -57,7 +57,7 @@ func ParseCLI(version string) (util.Options, error) {
|
|||
cookie = flag.Bool("no-cookie", false, "disable sending EDNS cookie (default: cookie sent)")
|
||||
tcpKeepAlive = flag.Bool("keep-alive", false, "send EDNS TCP keep-alive")
|
||||
udpBufSize = flag.Uint16("buffer-size", 1232, "set EDNS UDP buffer size", flag.OptShorthand('b'))
|
||||
mbzflag = flag.String("zflag", "0", "set EDNS z-flag")
|
||||
mbzflag = flag.String("zflag", "0", "set EDNS z-flag `value`")
|
||||
subnet = flag.String("subnet", "", "set EDNS subnet")
|
||||
padding = flag.Bool("pad", false, "set EDNS padding")
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func ParseDig(arg string, opts *util.Options) error {
|
|||
opts.Display.Authority = isNo
|
||||
opts.Display.Additional = isNo
|
||||
opts.Display.Statistics = isNo
|
||||
case "idnout":
|
||||
case "idnin", "idnout":
|
||||
opts.Display.UcodeTranslate = isNo
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
/*
|
||||
Package cli is the CLI part of the package, including both POSIX
|
||||
flag parsing and dig-like flag parsing.
|
||||
|
|
|
@ -117,8 +117,8 @@ func ParseMiscArgs(args []string, opts *util.Options) error {
|
|||
|
||||
if err != nil {
|
||||
// :^)
|
||||
opts.Logger.Warn("Could not query system for server. Using default")
|
||||
opts.Request.Server = "95.216.99.249"
|
||||
opts.Logger.Warn("Could not query system for server. Using localhost")
|
||||
opts.Request.Server = "127.0.0.1"
|
||||
} else {
|
||||
// Make sure that if IPv4 or IPv6 is asked for it actually uses it
|
||||
harmful:
|
||||
|
|
110
completions/zsh.zsh
Normal file
110
completions/zsh.zsh
Normal file
|
@ -0,0 +1,110 @@
|
|||
#compdef awl
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
local curcontext="$curcontext" state line expl
|
||||
local -a alts args
|
||||
[[ -prefix + ]] && args=(
|
||||
'*+'{no,}'tcp[use TCP instead of UDP for queries]'
|
||||
'*+'{no,}'ignore[ignore truncation in UDP responses]'
|
||||
'*+'{no,}'tls[use DNS-over-TLS for queries]'
|
||||
'*+'{no,}'dnscrypt[use DNSCrypt for queries]'
|
||||
'*+'{no,}'https[use DNS-over-HTTPS for queries]'
|
||||
'*+'{no,}'quic[use DNS-over-QUIC for queries]'
|
||||
'*+'{no,}'aaonly[set aa flag in the query]'
|
||||
'*+'{no,}'additional[print additional section of a reply]'
|
||||
'*+'{no,}'adflag[set the AD (authentic data) bit in the query]'
|
||||
'*+'{no,}'cdflag[set the CD (checking disabled) bit in the query]'
|
||||
'*+'{no,}'cookie[add a COOKIE option to the request]'
|
||||
'*+edns=[specify EDNS version for query]:version (0-255)'
|
||||
'*+noedns[clear EDNS version to be sent]'
|
||||
'*+ednsflags=[set EDNS flags bits]:flags'
|
||||
# '*+ednsopt=[specify EDNS option]:code point'
|
||||
'*+noedns[clear EDNS options to be sent]'
|
||||
'*+'{no,}'expire[send an EDNS Expire option]'
|
||||
# '*+'{no,}'idnin[set processing of IDN domain names on input]'
|
||||
'*+'{no,}'idnout[set conversion of IDN puny code on output]'
|
||||
'*+'{no,}'keepalive[request EDNS TCP keepalive]'
|
||||
'*+'{no,}'keepopen[keep TCP socket open between queries]'
|
||||
'*+'{no,}'recurse[set the RD (recursion desired) bit in the query]'
|
||||
# '*+'{no,}'nssearch[search all authoritative nameservers]'
|
||||
# '*+'{no,}'trace[trace delegation down from root]'
|
||||
# '*+'{no,}'cmd[print initial comment in output]'
|
||||
'*+'{no,}'short[print terse output]'
|
||||
'*+'{no,}'identify[print IP and port of responder]'
|
||||
'*+'{no,}'comments[print comment lines in output]'
|
||||
'*+'{no,}'stats[print statistics]'
|
||||
'*+padding[set padding block size]:size [0]'
|
||||
'*+'{no,}'qr[print query as it was sent]'
|
||||
'*+'{no,}'question[print question section of a query]'
|
||||
'*+'{no,}'raflag[set RA flag in the query]'
|
||||
'*+'{no,}'answer[print answer section of a reply]'
|
||||
'*+'{no,}'authority[print authority section of a reply]'
|
||||
'*+'{no,}'all[set all print/display flags]'
|
||||
'*+'{no,}'subnet=[send EDNS client subnet option]:addr/prefix-length'
|
||||
'*+'{no,}'tcflag[set TC flag in the query]'
|
||||
'*+time=[set query timeout]:timeout (seconds) [1]'
|
||||
'*+timeout=[set query timeout]:timeout (seconds) [1]'
|
||||
'*+tries=[specify number of UDP query attempts]:tries [3]'
|
||||
'*+retry=[specify number of UDP query retries]:retries [2]'
|
||||
# '*+'{no,}'rrcomments[set display of per-record comments]'
|
||||
# '*+ndots=[specify number of dots to be considered absolute]:dots'
|
||||
'*+bufsize=[specify UDP buffer size]:size (bytes)'
|
||||
'*+'{no,}'dnssec[enable DNSSEC]'
|
||||
'*+'{no,}'nsid[include EDNS name server ID request in query]'
|
||||
'*+'{no,}'class[display the class whening printing the answer]'
|
||||
'*+'{no,}'ttlid[display the TTL whening printing the record]'
|
||||
'*+'{no,}'ttlunits[display the TTL in human-readable units]'
|
||||
# '*+'{no,}'unknownformat[print RDATA in RFC 3597 "unknown" format]'
|
||||
'*+'{no,}'json[present the results as JSON]'
|
||||
'*+'{no,}'xml[present the results as XML]'
|
||||
'*+'{no,}'yaml[present the results as YAML]'
|
||||
'*+'{no,}'zflag[set Z flag in query]'
|
||||
)
|
||||
# TODO: Add the regular (POSIX/GNU) flags
|
||||
_arguments -s -C $args \
|
||||
'(- *)-'{h,-help}'[display help information]' \
|
||||
'(- *)-'{V,-version}'[display version information]' \
|
||||
'-'{v,-verbosity}'=+[set verbosity to custom level]:verbosity:compadd -M "m\:{\-1-3}={\-1-3}" - \-1 0 1 2 3' \
|
||||
'-'{v,-verbosity}'+[set verbosity to info]' \
|
||||
'*-'{p,-port}'+[specify port number]:port:_ports' \
|
||||
'*-'{q,-query}'+[specify host name to query]:host:_hosts' \
|
||||
'*-'{c,-class}'+[specify class]:class:compadd -M "m\:{a-z}={A-Z}" - IN CS CH HS' \
|
||||
'*-'{t,-qType}'+[specify type]:type:_dns_types' \
|
||||
'*-4+[force IPv4 only]' \
|
||||
'*-6+[force IPv6 only]' \
|
||||
'*-'{x,-reverse}'+[reverse lookup]' \
|
||||
'*--timeout+[timeout in seconds]:number [1]' \
|
||||
'*--retry+[specify number of UDP query retries]:number [2]' \
|
||||
'*--no-edns+[disable EDNS]' \
|
||||
'*--edns-ver+[specify EDNS version for query]:version (0-255) [0]' \
|
||||
'*-'{D,-dnssec}'+[enable DNSSEC]' \
|
||||
'*--expire+[send EDNS expire]' \
|
||||
'*-'{n,-nsid}'+[include EDNS name server ID request in query]' \
|
||||
'*--no-cookie+[disable sending EDNS cookie]' \
|
||||
'*--keep-alive+[request EDNS TCP keepalive]' \
|
||||
'*-'{b,-buffer-size}'+[specify UDP buffer size]:size (bytes) [1232]' \
|
||||
'*--zflag+[set EDNS z-flag]:decimal, hex or octal [0]' \
|
||||
'*--subnet+[set EDNS client subnet]:addr/prefix-length' \
|
||||
'*--no-truncate+[ignore truncation in UDP responses]' \
|
||||
'*--tcp+[use TCP instead of UDP for queries]' \
|
||||
'*--dnscrypt+[use DNSCrypt for queries]' \
|
||||
'*-'{T,-tls}'+[use DNS-over-TLS for queries]' \
|
||||
'*-'{H,-https}'+[use DNS-over-HTTPS for queries]' \
|
||||
'*-'{Q,-quic}'+[use DNS-over-QUIC for queries]' \
|
||||
'*--tls-no-verify+[disable TLS verification]' \
|
||||
'*--tls-host+[set TLS lookup hostname]:host:_hosts' \
|
||||
'*-'{s,-short}'+[print terse output]' \
|
||||
'*-'{j,-json}'+[present the results as JSON]' \
|
||||
'*-'{x,-xml}'+[present the results as XML]' \
|
||||
'*-'{y,-yaml}'+[present the results as YAML]' \
|
||||
'*: :->args' && ret=0
|
||||
|
||||
if [[ -n $state ]]; then
|
||||
if compset -P @; then
|
||||
_wanted hosts expl 'DNS server' _hosts && ret=0;
|
||||
else
|
||||
_alternative 'hosts:host:_hosts' 'types:query type:_dns_types' && ret=0
|
||||
fi
|
||||
fi
|
||||
|
||||
return ret
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
/*
|
||||
Package conf contains helper functions for getting local nameservers
|
||||
|
||||
|
|
237
doc/awl.1.scd
237
doc/awl.1.scd
|
@ -1,4 +1,5 @@
|
|||
awl(1)
|
||||
; SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# NAME
|
||||
|
||||
|
@ -6,159 +7,217 @@ awl - DNS lookup tool
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
_awl_ [ _OPTIONS_ ] _name_ [ _@server_ ] [ _type_ ], where
|
||||
*awl* [ _OPTIONS_ ] _name_ [ _@server_ ] [ _type_ ], where
|
||||
|
||||
_name_ is the query to make (_example: froth.zone_)++
|
||||
_@server_ is the server to query (_example: dns.froth.zone_)++
|
||||
_type_ is the DNS resource type (_example: AAAA_)
|
||||
_name_ is the query to make (example: froth.zone)++
|
||||
_@server_ is the server to query (example: dns.froth.zone)++
|
||||
_type_ is the DNS resource type (example: AAAA)
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
_awl_ (*a*wls *w*ant *l*icorice) is a simple tool designed to make DNS queries,
|
||||
much like the venerable _dig_(1). An awl is a tool used to make small holes,
|
||||
*awl* (*a*wls *w*ant *l*icorice) is a simple tool designed to make DNS queries,
|
||||
much like the venerable *dig*(1). An awl is a tool used to make small holes,
|
||||
typically used in leatherworking.
|
||||
|
||||
_awl_ is designed to be a more "modern" version of _drill_(1) by including
|
||||
some more recent RFCs and output options. _awl_ is still heavily
|
||||
Work-In-Progress so some features may get added or removed.
|
||||
*awl* is designed to be a more "modern" version of *drill*(1) by including
|
||||
some more recent RFCs and output options.
|
||||
|
||||
When no arguments are given, *awl* will perform an _NS_ query on the root ('_._').
|
||||
|
||||
When a nameserver is not given, *awl* will query a random system nameserver.
|
||||
If one cannot be found, *awl* will query localhost.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
Dig-like +[no]flags are supported, see dig(1)
|
||||
Anything in [brackets] is optional.
|
||||
|
||||
_-D_, _--dnssec_, _+dnssec_
|
||||
*-D*, *--dnssec*, *+dnssec*
|
||||
Enable DNSSEC. This needs to be manually enabled.
|
||||
|
||||
_-v_ _value_
|
||||
Set verbosity (currently WIP)
|
||||
*-v*[=_int_]
|
||||
Set verbosity
|
||||
Accepted values are as follows:
|
||||
- _0_: Only log errors.
|
||||
- _1_: Log warnings. *This is the default.*
|
||||
- _2_: Log information *Default when specifying just* _-v_.
|
||||
- _3_: Log information useful for debugging.
|
||||
|
||||
_-V_
|
||||
Setting a value lower than 0 disables logging entirely.
|
||||
|
||||
By default, specifying just *-v* sets the verbosity to 2 (info).
|
||||
|
||||
*-V*
|
||||
Print the version and exit.
|
||||
|
||||
_-h_
|
||||
*-h*
|
||||
Show a "short" help message.
|
||||
|
||||
## Query Options
|
||||
|
||||
_-4_
|
||||
*-4*
|
||||
Only make query over IPv4
|
||||
|
||||
_-6_
|
||||
*-6*
|
||||
Only make query over IPv6
|
||||
|
||||
_-p_, _--port_ _port_
|
||||
*-p*, *--port* *port*
|
||||
Sets the port to query. Default ports listed below.
|
||||
|
||||
- _53_ for _UDP_ and _TCP_
|
||||
- _853_ for _TLS_ and _QUIC_
|
||||
- _443_ for _HTTPS_
|
||||
- _53_ for *UDP* and *TCP*
|
||||
- _853_ for *TLS* and *QUIC*
|
||||
- _443_ for *HTTPS*
|
||||
|
||||
_-q_, _--query_ _domain_
|
||||
*-q*, *--query* _domain_
|
||||
Domain to query (eg. example.com)
|
||||
|
||||
_-c_, _--class_ _class_
|
||||
*-c*, *--class* _class_
|
||||
DNS class to query (eg. IN, CH)
|
||||
The default is IN.
|
||||
|
||||
_-t_, _--qType_ _type_
|
||||
DNS type to query (eg. A, NS)
|
||||
*-t*, *--qType* _type_
|
||||
DNS type to query (eg. A, AAAA, NS)
|
||||
The default is A.
|
||||
|
||||
_--no-truncate_, _+ignore_
|
||||
Ignore UDP truncation (by default, awl _retries with TCP_)
|
||||
*--no-truncate*, *+ignore*
|
||||
Ignore UDP truncation (by default, awl *retries with TCP*).
|
||||
|
||||
_--tcp_, _+tcp_, _+vc_
|
||||
Use TCP for the query (see _RFC 7766_)
|
||||
*--tcp*, *+tcp*, *+vc*
|
||||
Use TCP for the query (see RFC 7766).
|
||||
|
||||
_--dnscrypt_, _+dnscrypt_
|
||||
Use DNSCrypt
|
||||
*--dnscrypt*, *+dnscrypt*
|
||||
Use DNSCrypt.
|
||||
|
||||
_-T_, _--tls_, _+tls_
|
||||
Use DNS-over-TLS, implies _--tcp_ (see _RFC 7858_)
|
||||
*-T*, *--tls*, *+tls*
|
||||
Use DNS-over-TLS, implies *--tcp* (see RFC 7858)
|
||||
|
||||
_--tls-host_ _string_
|
||||
*--tls-host* _string_
|
||||
Set hostname to use for TLS certificate validation.
|
||||
Default is the name of the domain when querying over TLS, and empty for IPs.
|
||||
|
||||
_--tls-no-verify_
|
||||
*--tls-no-verify*
|
||||
Ignore TLS validation when performing a DNS query.
|
||||
|
||||
_-H_. _--https_, _+https_
|
||||
Use DNS-over-HTTPS (see _RFC 8484_)
|
||||
*-H*. *--https*, *+https*
|
||||
Use DNS-over-HTTPS (see RFC 8484).
|
||||
|
||||
_-Q_. _--quic_, _+quic_
|
||||
Use DNS-over-QUIC (see _RFC 9250_)
|
||||
*-Q*. *--quic*, *+quic*
|
||||
Use DNS-over-QUIC (see RFC 9250).
|
||||
|
||||
_-x_, _--reverse_
|
||||
Do a reverse lookup. Sets default _type_ to PTR.++
|
||||
_awl_ automatically makes an IP or phone number canonical.
|
||||
*-x*, *--reverse*
|
||||
Do a reverse lookup. Sets default *type* to PTR.
|
||||
*awl* automatically makes an IP or phone number canonical.
|
||||
|
||||
_--timeout_ _seconds_, _+timeout=__seconds_
|
||||
Set the timeout period. Floating point numbers are accepted.++
|
||||
0.5 seconds is the minimum.
|
||||
*--timeout* _seconds_, *+timeout*=_seconds_
|
||||
Set the timeout period. Floating point numbers are accepted.
|
||||
0.5 seconds is the minimum.
|
||||
|
||||
_--retries_ _int_, _+tries_=_int_, _+ retry_=_int_
|
||||
*--retries* _int_, *+tries*=_int_, *+retry*=_int_
|
||||
Set the number of retries.
|
||||
Retry is one more than tries, dig style
|
||||
Retry is one more than tries, dig style.
|
||||
|
||||
## DNS Flags
|
||||
|
||||
_--aa=[false]_, _+[no]aaflag_
|
||||
(Set, Unset) AA (Authoritative Answer) flag
|
||||
*--aa*[=_bool_], *+[no]aaflag*
|
||||
(Set, Unset) AA (Authoritative Answer) flag.
|
||||
|
||||
_--ad=[false]_, _+[no]adflag_
|
||||
(Set, Unset) AD (Authenticated Data) flag
|
||||
*--ad*[=_bool_], *+[no]adflag*
|
||||
(Set, Unset) AD (Authenticated Data) flag.
|
||||
|
||||
_--tc=[false]_, _+[no]tcflag_
|
||||
*--tc*[=_bool_], *+[no]tcflag*
|
||||
(Set, Unset) TC (TrunCated) flag
|
||||
|
||||
_-z=[false]_, _+[no]zflag_
|
||||
(Set, Unset) Z (Zero) flag
|
||||
*-z*[=_bool_], *+[no]zflag*
|
||||
(Set, Unset) Z (Zero) flag.
|
||||
|
||||
_--cd=[false]_, _+[no]cdflag_
|
||||
(Set, Unset) CD (Checking Disabled) flag
|
||||
*--cd*[=_bool_], *+[no]cdflag*
|
||||
(Set, Unset) CD (Checking Disabled) flag.
|
||||
|
||||
_--qr=[false]_, _+[no]qrflag_
|
||||
(Set, Unset) QR (QueRy) flag
|
||||
*--qr*[=_bool_], *+[no]qrflag*
|
||||
(Set, Unset) QR (QueRy) flag.
|
||||
|
||||
_--rd=[true]_, _+[no]rdflag_
|
||||
(Set, Unset) RD (Recursion Desired) flag
|
||||
*--rd*[=_bool_], *+[no]rdflag*
|
||||
(Set, Unset) RD (Recursion Desired) flag.
|
||||
|
||||
_--ra=[false]_, _+[no]raflag_
|
||||
(Set, Unset) RA (Recursion Available) flag
|
||||
*--ra*[=_bool_], *+[no]raflag*
|
||||
(Set, Unset) RA (Recursion Available) flag.
|
||||
|
||||
## EDNS
|
||||
All of these options except disabling EDNS imply *+edns*.
|
||||
|
||||
*--no-edns*, *+noedns*
|
||||
Disable EDNS.
|
||||
|
||||
*--edns-ver*, *+edns*[=_int_]
|
||||
Enable EDNS and set EDNS version.
|
||||
The maximum value is 255, and the minimum (default) value is 0.
|
||||
|
||||
*--expire*. *+[no]expire*
|
||||
Send an EDNS Expire.
|
||||
|
||||
*--nsid*, *+[no]nsid*
|
||||
Send an EDNS name server ID request.
|
||||
|
||||
*--no-cookie*, *+[no]cookie*[=_string_]
|
||||
Send an EDNS cookie.
|
||||
This is enabled by default with a random string.
|
||||
|
||||
*--keep-alive*, *+[no]keepalive*, *+[no]keepopen*
|
||||
Send an EDNS keep-alive.
|
||||
This does nothing unless using TCP.
|
||||
|
||||
*--buffer-size* _int_, *+bufize*=_int_
|
||||
Set the UDP message buffer size, using EDNS.
|
||||
Max is 65535, minimum is zero.
|
||||
The default value is 1232.
|
||||
|
||||
*--zflag* _int_, *+ednsflags*=_int_
|
||||
Set the must-be-zero EDNS flags.
|
||||
Decimal, hexadecimal and octal are supported.
|
||||
Trying to set DO will be ignored.
|
||||
|
||||
*--subnet* _ip_[_/prefix_], *+[no]subnet*=_ip_[_/prefix_]
|
||||
Send an EDNS Client Subnet option with the specified address.
|
||||
|
||||
Like *dig*(1), setting the IP to _0.0.0.0/0_, _::/0_ or _0_ will signal the resolver to not use any client information when returning the query.
|
||||
|
||||
## Output Display
|
||||
|
||||
_--no-question_, _+noquestion_
|
||||
Do not display the Question section
|
||||
*--no-question*, *+[no]question*
|
||||
Toggle the display of the Question section.
|
||||
|
||||
_--no-answer_, _+noanswer_
|
||||
Do not display the Answer section
|
||||
*--no-answer*, *+[no]answer*
|
||||
Toggle the display of the Answer section.
|
||||
|
||||
_--no-answer_, _+noanswer_
|
||||
Do not display the Answer section
|
||||
*--no-answer*, *+[no]answer*
|
||||
Toggle the display of the Answer section.
|
||||
|
||||
_--no-authority_, _+noauthority_
|
||||
Do not display the Authority section
|
||||
*--no-authority*, *+[no]authority*
|
||||
Toggle the display of the Authority section.
|
||||
|
||||
_--no-additional_, _+noadditional_
|
||||
Do not display the Additional section
|
||||
*--no-additional*, *+[no]additional*
|
||||
Toggle the display of the Additional section.
|
||||
|
||||
_--no-statistics_, _+nostats_
|
||||
Do not display the Statistics (additional comments) section
|
||||
*--no-statistics*, *+[no]stats*
|
||||
Toggle the display of the Statistics (additional comments) section.
|
||||
|
||||
## Output Formats
|
||||
|
||||
_-j_, _--json_, _+json_
|
||||
*-j*, *--json*, *+json*
|
||||
Print the query results as JSON.
|
||||
|
||||
_-X_, _--xml_, _+xml_
|
||||
*-X*, *--xml*, *+xml*
|
||||
Print the query results as XML.
|
||||
|
||||
_-y_, _--yaml_, _+yaml_
|
||||
*-y*, *--yaml*, *+yaml*
|
||||
Print the query results as YAML.
|
||||
|
||||
_-s_, _--short_, _+short_
|
||||
*-s*, *--short*, *+short*
|
||||
Print just the address of the answer.
|
||||
|
||||
# EXIT STATUS
|
||||
|
||||
The exit code is 0 when a query is successfully made and received.
|
||||
This includes SERVFAILs, NOTIMPL among others.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
|
@ -182,4 +241,22 @@ Query dns.google over TLS for the PTR record to the IP address 8.8.4.4
|
|||
|
||||
# SEE ALSO
|
||||
|
||||
_drill_(1), _dig_(1), the many DNS RFCs
|
||||
*drill*(1), *dig*(1)
|
||||
|
||||
# STANDARDS
|
||||
|
||||
RFC 1034,1035 (UDP), 7766 (TCP), 7858 (TLS), 8484 (HTTPS), 9230 (QUIC)
|
||||
|
||||
Probably more, _https://www.statdns.com/rfc_
|
||||
|
||||
# BUGS
|
||||
|
||||
OPT records are only printed when using a standard output, not JSON/XML/YAML.
|
||||
|
||||
Full parity with *dig*(1) is not complete.
|
||||
|
||||
This man page is probably not complete.
|
||||
|
||||
Likely numerous more, report them either to the tracker
|
||||
_https://git.froth.zone/sam/awl/issues_ or via email
|
||||
_~sammefishe/awl-dev@lists.sr.ht_
|
||||
|
|
2
doc/wiki
2
doc/wiki
|
@ -1 +1 @@
|
|||
Subproject commit d25a7f13273737938d5e1e08c7332d39fffadc6b
|
||||
Subproject commit 4974d316fc3be3c28b54af5188860f8cfb2bdd6b
|
2
docs.go
2
docs.go
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
/*
|
||||
awl is a DNS lookup tool written in Go, similar to (and heavily inspired by) drill.
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
/*
|
||||
Package logawl is a package for custom logging needs
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@ func (l *Logger) level() Level {
|
|||
// UnMarshalLevel unmarshalls the int value of level for writing the header.
|
||||
func (l *Logger) UnMarshalLevel(lv Level) (string, error) {
|
||||
switch lv {
|
||||
case 0:
|
||||
case ErrLevel:
|
||||
return "ERROR ", nil
|
||||
case 1:
|
||||
case WarnLevel:
|
||||
return "WARN ", nil
|
||||
case 2:
|
||||
case InfoLevel:
|
||||
return "INFO ", nil
|
||||
case 3:
|
||||
case DebugLevel:
|
||||
return "DEBUG ", nil
|
||||
}
|
||||
|
||||
|
|
26
mkfile
26
mkfile
|
@ -4,27 +4,31 @@
|
|||
GO = go
|
||||
PROG = awl
|
||||
|
||||
GOFLAGS = -ldflags=-s -ldflags=-w -ldflags=-X=main.version=PLAN9 -trimpath
|
||||
|
||||
CGO_ENABLED = 0
|
||||
|
||||
$PROG:
|
||||
$GO build -ldflags="-s -w -X=main.version=PLAN9" -o $PROG .
|
||||
all:V: $PROG
|
||||
|
||||
install:
|
||||
$GO install -ldflags="-s -w -X=main.version=PLAN9" .
|
||||
$PROG:
|
||||
$GO build $GOFLAGS -o $target .
|
||||
|
||||
install:V:
|
||||
$GO install $GOFLAGS .
|
||||
cp doc/$PROG.1 /sys/man/1/$PROG
|
||||
|
||||
test:
|
||||
$GO test -cover -coverprofile=coverage/coverage.out ./...
|
||||
test:V:
|
||||
$GO test -v -cover ./...
|
||||
|
||||
fmt:
|
||||
fmt:V:
|
||||
gofmt -w -s .
|
||||
|
||||
vet:
|
||||
vet:V:
|
||||
$GO vet ./...
|
||||
|
||||
lint: fmt vet
|
||||
lint:V: fmt vet
|
||||
|
||||
clean:
|
||||
clean:V:
|
||||
$GO clean
|
||||
|
||||
nuke: clean
|
||||
nuke:V: clean
|
||||
|
|
1
pkg/awl-dns-git
Submodule
1
pkg/awl-dns-git
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c8686b1e149b6c42db019c77caf36475aafadd03
|
|
@ -1,2 +1,4 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package query is for the various query types.
|
||||
package query
|
||||
|
|
|
@ -36,7 +36,10 @@ func TestResolve(t *testing.T) {
|
|||
assert.ErrorContains(t, err, "timeout")
|
||||
}
|
||||
|
||||
// FIXME: See when this is fixed and fix it.
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
t.Skip("Sadly this is broken.")
|
||||
t.Parallel()
|
||||
|
||||
opts := util.Options{
|
||||
|
|
|
@ -74,9 +74,9 @@ func CreateQuery(opts util.Options) (util.Response, error) {
|
|||
opts.Logger.Info("Setting EDNS padding")
|
||||
}
|
||||
|
||||
o.SetUDPSize(opts.BufSize)
|
||||
o.SetUDPSize(opts.EDNS.BufSize)
|
||||
|
||||
opts.Logger.Info("EDNS UDP buffer set to", opts.BufSize)
|
||||
opts.Logger.Info("EDNS UDP buffer set to", opts.EDNS.BufSize)
|
||||
|
||||
o.SetZ(opts.EDNS.ZFlag)
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ import (
|
|||
)
|
||||
|
||||
// Message is for overall DNS responses.
|
||||
//
|
||||
//nolint:fieldalignment // IMO this looks better when printed like this
|
||||
type Message struct {
|
||||
Question []Question `json:"question,omitempty" xml:"question,omitempty" yaml:",omitempty"`
|
||||
Answer []Answer `json:"answer,omitempty" xml:"answer,omitempty" yaml:",omitempty"`
|
||||
|
@ -39,8 +37,6 @@ type RRHeader struct {
|
|||
}
|
||||
|
||||
// Answer is for a DNS Response.
|
||||
//
|
||||
//nolint:fieldalignment // IMO this looks better when printed like this
|
||||
type Answer struct {
|
||||
Value string `json:"response,omitempty" xml:"response,omitempty" yaml:"response,omitempty"`
|
||||
RRHeader `json:"header,omitempty" xml:"header,omitempty" yaml:"header,omitempty"`
|
||||
|
|
38
template.mk
38
template.mk
|
@ -8,24 +8,34 @@ TEST_SOURCES ?= $(shell find . -name "*_test.go" -type f)
|
|||
|
||||
CGO_ENABLED ?= 0
|
||||
GO ?= go
|
||||
TEST ?= $(GO) test -race
|
||||
TEST ?= $(GO) test -race -cover
|
||||
COVER ?= $(GO) tool cover
|
||||
GOFLAGS ?= -ldflags "-s -w -X=main.version=$(HASH)" -trimpath
|
||||
GOFLAGS ?= -ldflags="-s -w -X=main.version=$(HASH)" -trimpath
|
||||
DESTDIR :=
|
||||
|
||||
PREFIX ?= /usr/local
|
||||
BIN ?= bin
|
||||
SHARE ?= share
|
||||
|
||||
SCDOC ?= scdoc
|
||||
MAN ?= $(PREFIX)/share/man
|
||||
MAN ?= $(PREFIX)/$(SHARE)/man
|
||||
|
||||
PROG ?= awl
|
||||
|
||||
# hehe
|
||||
all: $(PROG) doc/$(PROG).1
|
||||
|
||||
$(PROG): $(SOURCES)
|
||||
$(GO) build -o $(EXE) $(GOFLAGS) .
|
||||
|
||||
doc/$(PROG).1: doc/$(PROG).1.scd
|
||||
$(SCDOC) <doc/$(PROG).1.scd >doc/$(PROG).1
|
||||
$(SCDOC) <$< >$@
|
||||
|
||||
doc/wiki/$(PROG).1.md: doc/$(PROG).1
|
||||
pandoc --from man --to gfm -o $@ $<
|
||||
|
||||
## update_doc: update documentation (requires pandoc)
|
||||
update_doc: doc/wiki/$(PROG).1.md
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
|
@ -42,25 +52,24 @@ lint: fmt vet
|
|||
|
||||
## test: run go test
|
||||
test: $(TEST_SOURCES)
|
||||
$(TEST) -cover -coverprofile=coverage/coverage.out ./...
|
||||
$(TEST) -v -coverprofile=coverage/coverage.out ./...
|
||||
|
||||
.PHONY: test-ci
|
||||
test-ci:
|
||||
$(TEST) -v
|
||||
$(TEST) ./...
|
||||
|
||||
## fuzz: runs fuzz tests
|
||||
fuzz: $(TEST_SOURCES)
|
||||
cd cli
|
||||
$(TEST) -fuzz=FuzzFlags -fuzztime 10000x
|
||||
$(TEST) -fuzz=FuzzDig -fuzztime 10000x
|
||||
$(TEST) -fuzz=FuzzParseArgs -fuzztime 10000x
|
||||
cd ..
|
||||
$(TEST) -fuzz=FuzzFlags -fuzztime 10000x ./cli
|
||||
$(TEST) -fuzz=FuzzDig -fuzztime 10000x ./cli
|
||||
$(TEST) -fuzz=FuzzParseArgs -fuzztime 5000x ./cli
|
||||
|
||||
.PHONY: full_test
|
||||
full_test: test fuzz
|
||||
|
||||
coverage/coverage.out: test
|
||||
$(COVER) -func=coverage/coverage.out
|
||||
$(COVER) -html=coverage/coverage.out -o coverage/cover.html
|
||||
$(COVER) -func=$@
|
||||
$(COVER) -html=$@ -o coverage/cover.html
|
||||
|
||||
## cover: generates test coverage, output as HTML
|
||||
cover: coverage/coverage.out
|
||||
|
@ -69,7 +78,8 @@ cover: coverage/coverage.out
|
|||
.PHONY: clean
|
||||
clean:
|
||||
$(GO) clean
|
||||
rm doc/$(PROG).1
|
||||
# Ignore errors if you remove something that doesn't exist
|
||||
rm -f doc/$(PROG).1
|
||||
|
||||
## help: Prints this help message
|
||||
.PHONY: help
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package util contains helper functions that don't belong anywhere else
|
||||
package util
|
||||
|
|
Loading…
Reference in a new issue