Rev 5 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 11 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #!/bin/bash |
1 | #!/bin/bash |
2 | 2 | ||
3 | # |
3 | # |
4 | # VWhois (ViaThinkSoft WHOIS, a fork of generic Whois / gwhois) |
4 | # VGWhoIs (ViaThinkSoft Global WhoIs, a fork of generic Whois / gwhois) |
5 | # Maintenance / Developer utilities |
5 | # Maintenance / Developer utilities |
6 | # |
6 | # |
7 | # (c) 2012-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
7 | # (c) 2012-2019 by Daniel Marschall, ViaThinkSoft <info@daniel-marschall.de> |
8 | # |
8 | # |
9 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
9 | # License: https://www.gnu.org/licenses/gpl-2.0.html (GPL version 2) |
Line 161... | Line 161... | ||
161 | } |
161 | } |
162 | 162 | ||
163 | function question2 { |
163 | function question2 { |
164 | while true; do |
164 | while true; do |
165 | echo "" |
165 | echo "" |
166 | echo "Gwhois might already have been fixed. Do you want to enforce a gwhois recheck now? ([y]es, [n]o, e[x]it)" |
166 | echo "vgwhois might already have been fixed. Do you want to enforce a vgwhois recheck now? ([y]es, [n]o, e[x]it)" |
167 | read yn |
167 | read yn |
168 | case $yn in |
168 | case $yn in |
169 | [YyRr]* ) |
169 | [YyRr]* ) |
170 | if [ -f "$Q" ]; then |
170 | if [ -f "$Q" ]; then |
171 | rm "$Q" |
171 | rm "$Q" |
Line 215... | Line 215... | ||
215 | if [ ! -f "$T" ]; then |
215 | if [ ! -f "$T" ]; then |
216 | echo "There is no action needed by the user" |
216 | echo "There is no action needed by the user" |
217 | return 0 |
217 | return 0 |
218 | fi |
218 | fi |
219 | else |
219 | else |
220 | T=$( mktemp --suffix='.gwhoisTC' ) |
220 | T=$( mktemp --suffix='.vgwhoisTC' ) |
221 | 221 | ||
222 | # In interactive/background mode, we will always do a webrequest when there is no problem and no expectation file without respect of the last checktime, to avoid that the status monitor will show entries with "no expectation file" when the user pressed "no", and then he would have to wait 7 days until "batch u" works again. |
222 | # In interactive/background mode, we will always do a webrequest when there is no problem and no expectation file without respect of the last checktime, to avoid that the status monitor will show entries with "no expectation file" when the user pressed "no", and then he would have to wait 7 days until "batch u" works again. |
223 | # TODO: how to do that in 1 line? |
223 | # TODO: how to do that in 1 line? |
224 | CALL_GWI=0 |
224 | CALL_GWI=0 |
225 | if [ $force -eq 1 ]; then |
225 | if [ $force -eq 1 ]; then |
Line 235... | Line 235... | ||
235 | CALL_GWI=1 |
235 | CALL_GWI=1 |
236 | fi |
236 | fi |
237 | fi |
237 | fi |
238 | fi |
238 | fi |
239 | if [ $CALL_GWI -eq 1 ]; then |
239 | if [ $CALL_GWI -eq 1 ]; then |
240 | echo "... calling gwhois ..." |
240 | echo "... calling vgwhois ..." |
241 | # We have to use loc_gwhois to allow $trytor to work correctly. |
241 | # We have to use loc_vgwhois to allow $trytor to work correctly. |
242 | # The torifiers "torify" and "usewithtor" always outputting bogus "libtorsocks" warning messages which would be saved in the output |
242 | # The torifiers "torify" and "usewithtor" always outputting bogus "libtorsocks" warning messages which would be saved in the output |
243 | # "vtor" - if applied to this script - can only filter them from STDOUT and STDERR, but not intercept this "&>" pipe |
243 | # "vtor" - if applied to this script - can only filter them from STDOUT and STDERR, but not intercept this "&>" pipe |
244 | # So we have to use this loc_gwhois script, where we torify manually |
244 | # So we have to use this loc_vgwhois script, where we torify manually |
245 | # Also, it is important that we do the warning message filtering in this step, because in the final output the lines will be colored/highlighted, and therefore "vtor" cannot grep them correctly anymore. |
245 | # Also, it is important that we do the warning message filtering in this step, because in the final output the lines will be colored/highlighted, and therefore "vtor" cannot grep them correctly anymore. |
246 | # Note: regex only valid in the years 1000-1099, 1900-2099, 2900-2999 |
246 | # Note: regex only valid in the years 1000-1099, 1900-2099, 2900-2999 |
247 | # grep away volative stuff like server names or times |
247 | # grep away volative stuff like server names or times |
248 | ( |
248 | ( |
249 | "$DIR"/loc_gwhois "$query" \ |
249 | "$DIR"/loc_vgwhois "$query" \ |
250 | | grep -v "This query was served by " \ |
250 | | grep -v "This query was served by " \ |
251 | | grep -v "(c)[12][90][0-9]\{2\}" \ |
251 | | grep -v "(c)[12][90][0-9]\{2\}" \ |
252 | | grep -v "[12][90][0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}" \ |
252 | | grep -v "[12][90][0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}" \ |
253 | | grep -v "\[[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\} REQUEST\]" \ |
253 | | grep -v "\[[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\} REQUEST\]" \ |
254 | | grep -v "RL Net \[.*\] - RL IP \[.*\]" \ |
254 | | grep -v "RL Net \[.*\] - RL IP \[.*\]" \ |
Line 267... | Line 267... | ||
267 | # -> lösung ?rm "$Q" nur im erfolgsfall |
267 | # -> lösung ?rm "$Q" nur im erfolgsfall |
268 | # if [ -f "$Q" ]; then |
268 | # if [ -f "$Q" ]; then |
269 | # rm "$Q" |
269 | # rm "$Q" |
270 | # fi |
270 | # fi |
271 | 271 | ||
272 | # behoben? in mode=i and mode=u, should the output of a new gwhois request be saved into the problem file, if the user cancels? (to avoid a second web request?) |
272 | # behoben? in mode=i and mode=u, should the output of a new vgwhois request be saved into the problem file, if the user cancels? (to avoid a second web request?) |
273 | # also, when doing a recheck after a perl error, and then cancel, the problem-file will not be updated! |
273 | # also, when doing a recheck after a perl error, and then cancel, the problem-file will not be updated! |
274 | # TODO: was ist besser? |
274 | # TODO: was ist besser? |
275 | #if [ ! -f "$Q" ] && [ "$T" != "$Q" ]; then |
275 | #if [ ! -f "$Q" ] && [ "$T" != "$Q" ]; then |
276 | if [ "$T" != "$Q" ]; then |
276 | if [ "$T" != "$Q" ]; then |
277 | cat "$T" > "$Q" |
277 | cat "$T" > "$Q" |
Line 297... | Line 297... | ||
297 | fi |
297 | fi |
298 | 298 | ||
299 | WARNINGS=() |
299 | WARNINGS=() |
300 | cat "$T" | grep -E "at /(bin|usr|etc|var)/\S+ line" > /dev/null |
300 | cat "$T" | grep -E "at /(bin|usr|etc|var)/\S+ line" > /dev/null |
301 | if [ $? -eq 0 ]; then |
301 | if [ $? -eq 0 ]; then |
302 | WARNINGS+=("Perl errors found in gwhois output!") |
302 | WARNINGS+=("Perl errors found in vgwhois output!") |
303 | fi |
303 | fi |
304 | cat "$T" | head -n 1 | grep -E "^("$'\xEF\xBB\xBF'"){0,1}Process query: '$query'" > /dev/null |
304 | cat "$T" | head -n 1 | grep -E "^("$'\xEF\xBB\xBF'"){0,1}Process query: '$query'" > /dev/null |
305 | if [ $? -ne 0 ]; then |
305 | if [ $? -ne 0 ]; then |
306 | WARNINGS+=("The gwhois output does not begin with 'Process query'!") |
306 | WARNINGS+=("The vgwhois output does not begin with 'Process query'!") |
307 | fi |
307 | fi |
308 | cat "$T" | grep "gwhois remarks: If this is a valid domainname or handle, please file a bug report." > /dev/null |
308 | cat "$T" | grep "vgwhois remarks: If this is a valid domainname or handle, please file a bug report." > /dev/null |
309 | if [ $? -eq 0 ]; then |
309 | if [ $? -eq 0 ]; then |
310 | WARNINGS+=("No pattern match!") |
310 | WARNINGS+=("No pattern match!") |
311 | fi |
311 | fi |
312 | if [ ${#WARNINGS[@]} -gt 0 ]; then |
312 | if [ ${#WARNINGS[@]} -gt 0 ]; then |
313 | if [ "$T" != "$Q" ]; then |
313 | if [ "$T" != "$Q" ]; then |
Line 383... | Line 383... | ||
383 | # touch "$tsfile" |
383 | # touch "$tsfile" |
384 | return 1 |
384 | return 1 |
385 | else |
385 | else |
386 | # resetconsole |
386 | # resetconsole |
387 | echo "This query has no expected state. Please define one." |
387 | echo "This query has no expected state. Please define one." |
388 | echo "This is the current output of gwhois:" |
388 | echo "This is the current output of vgwhois:" |
389 | 389 | ||
390 | echo "" |
390 | echo "" |
391 | cat "$T" | showPatternHighlighted |
391 | cat "$T" | showPatternHighlighted |
392 | echo "" |
392 | echo "" |
393 | 393 | ||
Line 444... | Line 444... | ||
444 | echo " b = background (download only and save the results for later query)" |
444 | echo " b = background (download only and save the results for later query)" |
445 | echo " u = user-dialog only (only ask the developer if there are questions, e.g. which were generated by mode b)." |
445 | echo " u = user-dialog only (only ask the developer if there are questions, e.g. which were generated by mode b)." |
446 | echo " -r|--rechecktime seconds" |
446 | echo " -r|--rechecktime seconds" |
447 | echo " Default: $recheck_time = approx. $hf_recheck_time)" |
447 | echo " Default: $recheck_time = approx. $hf_recheck_time)" |
448 | echo " -f|--force" |
448 | echo " -f|--force" |
449 | echo " Ignores --rechecktime and forces a new gwhois request" |
449 | echo " Ignores --rechecktime and forces a new vgwhois request" |
450 | echo " Default: $force" |
450 | echo " Default: $force" |
451 | } |
451 | } |
452 | 452 | ||
453 | # --- |
453 | # --- |
454 | 454 |