blob: ffdbc13f9da588110e91ba613604df4168b6e260 (
plain) (
blame)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
#compdef whois fwhois
_whois () {
_whois_setup
case "$0" in
fwhois) _whois_fwhois;;
*) $_whois_comp;;
esac
}
(( $+functions[_whois_setup] )) ||
_whois_setup () {
(( $+_whois_defaultserver )) ||
_whois_defaultserver='whois.internic.net'
(( $+_whois_servers )) || {
typeset -gUa _whois_servers
_whois_servers=(
$_whois_defaultserver
domain-registry.nl
is.nic.pw
whois.apnic.net:p
whois.arin.net:a
whois.aunic.net
whois.berkeley.edu
whois.cdnnet.ca
whois.dns.pt
whois.funet.fi
whois.gb.com
whois.gb.net
whois.internic.net
whois.jpl.nasa.gov
whois.nic-se.se
whois.nic.ad.jp
whois.nic.af
whois.nic.as
whois.nic.br
whois.nic.bt
whois.nic.ch
whois.nic.cx
whois.nic.fr
whois.nic.gov:g
whois.nic.hm
whois.nic.it
whois.nic.li
whois.nic.lk
whois.nic.mil:d
whois.nic.mx
whois.nic.nu
whois.nic.or.kr
whois.nic.sh
whois.nic.tj
whois.nic.tm
whois.nic.uk
whois.ripe.net:r
whois.ripn.net:R
whois.sics.se
whois.stanford.edu
whois.uk.com
www.nic.at
$(functions -m '_whois:*' |
awk '/^undefined _whois:/ {print substr($2,8,length($2)-7)}
/^_whois:/ {print substr($1,8,length($1)-7)}')
)
}
(( $+_whois_arguments )) || {
local help="$(whois </dev/null 2>&1)"
local tmp opt opts
local hostopt=-h+
if [[ $help = *"user[@<whois.server>]"* ]]; then
_whois_comp=_whois_fwhois
elif [[ $help = *(name\ ...|OBJECT...)* ]]; then
_whois_comp=_whois_multi
else
_whois_comp=_whois_single
hostopt=-h
fi
_whois_arguments=()
if [[ $help = *"-p PORT"* ]]; then
_whois_arguments=("$_whois_arguments[@]"
'-p[port]:port:_whois_ports'
)
fi
tmp="${(j::)${(@)${(@M)_whois_servers:#*:?}##*:}}"
if [[ $help = (#b)*\[-([$tmp]##)\]* ]]; then
tmp=(${(s::)match[1]})
else
tmp=()
fi
if [[ $help = *"-h host"* ]]; then
tmp=($tmp h)
fi
for opt in $tmp; do
opts=(-${^tmp:#$opt})
if (( $#opts )); then opts="($opts)"; else opts=; fi
if [[ $opt = h ]]; then
_whois_arguments=("$_whois_arguments[@]"
"${opts}${hostopt}:host:_whois_hosts")
else
_whois_arguments=("$_whois_arguments[@]"
"${opts}-${opt}[${${(@M)_whois_servers:#*:$opt}%:?}]")
fi
done
}
}
_whois_single () {
local curcontext="$curcontext" state line expl
typeset -A opt_args
local tmp host
_arguments -C \
"$_whois_arguments[@]" \
':identifier:->identifier'
case "$state" in
identifier)
if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then
compadd -QS '' \'
return
fi
compset -q
host="${opt_args[-h]:-$_whois_defaultserver}"
for tmp in $_whois_servers; do
if [[ $tmp = *:? && $+opt_args[-${tmp##*:}] -ne 0 ]]; then
host="${tmp%:?}"
break
fi
done
if (( $+functions[_whois:$host] )); then
"_whois:$host" "$expl[@]"
else
_message "identifier"
fi
;;
esac
}
_whois_multi () {
local curcontext="$curcontext" state line expl
typeset -A opt_args
local tmp host
_arguments -C \
"$_whois_arguments[@]" \
'*::identifier:->identifier'
case "$state" in
identifier)
host="${opt_args[-h]:-$_whois_defaultserver}"
for tmp in $_whois_servers; do
if [[ $tmp = *:? && $+opt_args[-${tmp##*:}] -ne 0 ]]; then
host="${tmp%:?}"
break
fi
done
if (( $+functions[_whois:$host] )); then
"_whois:$host" "$expl[@]"
else
_message "identifier"
fi
;;
esac
}
_whois_fwhois () {
if compset -P '*@'; then
_whois_hosts "$@"
else
if [[ -z "$QIPREFIX" && -z "$PREFIX" ]]; then
compadd -QS '' \'
return
fi
compset -q
host="$_whois_defaultserver"
if (( $+functions[_whois:$host] )); then
"_whois:$host" "$@"
else
_message "identifier"
fi
fi
}
_whois_hosts () {
_wanted hosts &&
compadd "$@" \
-M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' \
- ${_whois_servers%:?} || _hosts "$@"
}
_whois_ports () {
_wanted ports && compadd "$@" - whois || _ports "$@"
}
(( $+functions[_whois:whois.internic.net] )) ||
_whois:whois.internic.net () {
if (( CURRENT == 1 )); then
local expl
_wanted strings expl string compadd HELP DOMAIN HOST
else
_message 'string'
fi
}
(( $+functions[_whois:whois.nic.ad.jp] )) ||
_whois:whois.nic.ad.jp () {
if (( CURRENT == 1 )); then
local expl
_wanted strings expl string compadd HELP DOM NET HOST PERSON CONN COM
else
_message 'string'
fi
}
_whois "$@"
|