forked from zsh-users/zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_dig
executable file
·157 lines (151 loc) · 5.29 KB
/
_dig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#compdef dig
#
# Based on dig(1) version "DiG 9.9.1-P1". Incomplete, see XXX.
local curcontext="$curcontext" state line
typeset -A opt_args
local -aU dnsclasses
# taken from http://www.bind9.net/dns-parameters
dnsclasses=(IN CH HS)
# Though probably a better idea to do something like this elsewhere:
# typeset -aU dns_servers
# dns_servers=('\:\:1' 8.8.4.4 8.8.8.8 othernsnameorip..)
if [[ ${#dns_servers} -eq 0 ]]; then
dns_servers=${(z)${(Mz)${(f)"$(</etc/resolv.conf)"}:#nameserver *}:#nameserver}
fi
# Did not include +[no]defname as is deprecated
#
# XXX this option problematic due to - in option name, even with \hypen:
# '*+trusted\-key=[trusted key when chasing DNSSEC]:keyfile:_files' \
_arguments -C -s \
'(- *)-h[display help]' \
'(- *)-v[display version]' \
'(-4 -6)-4[IPv4 lookups]' \
'(-4 -6)-6[IPv6 lookups]' \
'(-c)-c[query class]:class:->dnsclass' \
'(-f)-f[batch mode file]:file:_files' \
'(-i)-i[older IP6.INT IPv6 reverse lookup method]' \
'(-k)-k[TSIG key file]:file:_files' \
'(-m)-m[enable memory usage debugging]' \
'(-b)-b[bind to address]:addr:->bindaddr' \
'(-p)-p[bind to port]:port:_ports' \
'(-q)-q[query name]:name:' \
'(-t)-t[query type]:type:->dnstype' \
'(-x)-x[IP address]:_ip' \
'(-y)-y[hmac name and key data (unsafe)]:authinfo' \
'*+novc' \
'*+vc[TCP Mode]' \
'*+notcp' \
'*+tcp[TCP mode, alternate syntax]' \
'*+time=[set query timeout]:timeout:' \
'*+tries=[set number of UDP attempts]:count:' \
'*+retry=[set number of UDP retries]:count' \
'*+domain=[set default domainname]:domain:_hosts' \
'*+bufsize=[set EDNS0 max UDP packet size]:number:' \
'*+ndots=[set NDOTS value]:value:' \
'*+edns=[set EDNS version]:version:' \
'*+nosearch' \
'*+search[set whether to use searchlist]' \
'*+noshowsearch' \
'*+showsearch[search with intermediate results]' \
'*+norecurse' \
'*+recurse[recursive mode]' \
'*+noignore' \
'*+ignore[do not revert to TCP for TC responses]' \
'*+nofail' \
'*+fail[do not try next server on SERVFAIL]' \
'*+nobesteffort' \
'*+besteffort[try to parse even illegal messages]' \
'*'{+noaaonly,+noaaflag} \
'*'{+aaonly,+aaflag}'[set AA flag in query]' \
'*+noadflag' \
'*+adflag[set AD flag in query]' \
'*+nocdflag' \
'*+cdflag[set CD flag in query]' \
'*+nocl' \
'*+cl[control display of class in records]' \
'*+nocmd' \
'*+cmd[control display of command line]' \
'*+nocomments' \
'*+comments[control display of comment lines]' \
'*+norrcomments' \
'*+rrcomments[control display of per-record comments]' \
'*+noquestion' \
'*+question[control display of question]' \
'*+noanswer' \
'*+answer[control display of answer]' \
'*+noauthority' \
'*+authority[control display of authority]' \
'*+noadditional' \
'*+additional[control display of additional]' \
'*+nostats' \
'*+stats[control display of statistics]' \
'*+noshort' \
'*+short[disable all except short form of answer]' \
'*+nottlid' \
'*+ttlid[control display of ttls]' \
'*+noall' \
'*+all[set all display flags]' \
'*+noqr' \
'*+qr[print question before sending]' \
'*+nonssearch' \
'*+nssearch[search all authoritative NS]' \
'*+noidentify' \
'*+identify[ID responders in short answers]' \
'*+notrace' \
'*+trace[trace delegation down from root]' \
'*+nodnssec' \
'*+dnssec[request DNSSEC records]' \
'*+nonsid' \
'*+nsid[request name server ID]' \
'*+sigchase)+nosigchase' \
'*+sigchase[chase DNSSEC signatures]' \
'*+notopdown' \
'*+topdown[do DNSSEC validation top down mode]' \
'*+nosplit' \
'*+split=[split hex/base64 fields into chunks]:value:' \
'*+nomultiline' \
'*+multiline[print records in a expanded format]' \
'*+noonesoa' \
'*+onesoa[AXFR prints only one SOA record]' \
'*: :->dnsquery' \
&& return 0
case "$state" in
bindaddr)
if compset -P '*[#]'; then
_ports
else
_bind_addresses
fi
;;
dnsclass)
_describe -t dnsclass 'DNS class' dnsclasses
;;
dnsquery)
# XXX need to support grammer, probably by keeping track of where
# the command line is in the following:
#
# Usage: dig [@global-server] [domain] [q-type] [q-class] {q-opt}
# {global-d-opt} host [@local-server] {local-d-opt}
# [ host [@local-server] {local-d-opt} [...]]
#
# but that is beyond my ability at present. So just complete hosts.
if compset -P '@'; then
_describe -t dnsserver 'DNS server' dns_servers
else
_wanted hosts expl server _hosts
# XXX this should instead be the count of non-@, -+, -- elements
# prior to the current position...
if [[ $#line -gt 1 ]]; then
local -a dnstypesshort
dnstypesshort=(ANY A NS CNAME SOA PTR HINFO MX TXT AAAA SRV IXFR AXFR)
_describe -t dnsquery 'DNS query' dnstypesshort
fi
fi
;;
dnstype)
local -a dnstypes
# taken from http://www.bind9.net/dns-parameters and * swapped for 'ANY'
dnstypes=(ANY A NS MD MF CNAME SOA MB MG MR NULL WKS PTR HINFO MINFO MX TXT RP AFSDB X25 ISDN RT NSAP NSAP-PTR SIG KEY PX GPOS AAAA LOC NXT EID NIMLOC SRV ATMA NAPTR KX CERT A6 DNAME SINK OPT APL DS SSHFP IPSECKEY RRSIG NSEC DNSKEY DHCID NSEC3 NSEC3PARAM TLSA HIP NINFO RKEY TALINK CDS SPF UINFO UID GID UNSPEC TKEY TSIG IXFR AXFR MAILB MAILA URI CAA TA DLV)
_describe -t dnstype 'DNS type' dnstypes
;;
esac