Login | ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/vgwhois/trunk/main/lib/VGWhoIs/Core.pm
(Generate patch)

Comparing trunk/main/lib/VGWhoIs/Core.pm (file contents):
Revision 12 by daniel-marschall, Tue May 21 19:26:19 2019 UTC vs.
Revision 20 by daniel-marschall, Mon May 27 23:40:30 2019 UTC

# Line 100 | Line 100 | sub VGWhoIs::Core::inicwhoisaccess { # t
100          return ($result, $exitcode);
101   }
102  
103 # ($result, $exitcode) = VGWhoIs::Core::wwwsgrep($url,$match)
104 sub VGWhoIs::Core::wwwsgrep {
105        my ($url,$match) = @_;
106        my ($result, $line, $exitcode) = ('', '', 0);
107
108        ($line, $exitcode) = VGWhoIs::Core::getsource($url);
109        if (!$exitcode) {
110                $line =~ s/\n/ /g;
111                if ($line =~ $match) {
112                        ($result) = $line =~ /$match/s;
113                }
114        }
115        return ($result, $exitcode);
116 }
117
103   # ($host, $additional) = VGWhoIs::Core::methodpatternregex($query,$host,$additional,$queryline);
104   sub VGWhoIs::Core::methodpatternregex {
105          my ($query,$host,$additional,$line) = @_;
# Line 281 | Line 266 | sub VGWhoIs::Core::doquery {
266                  $method = '';
267          }
268  
269 < # TODO: usage of methods. delete unused ones!
285 < # wwwgreplv -> removed
286 < # whoisjp: not in pattern
287 < # whoisarin: not in pattern
288 < # inicwhois: in use
289 <
290 <        elsif ($method eq 'wwwsgrep') {
291 <                my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
292 <
293 <                print "Querying $hostname with $protocol.\n\n";
294 <
295 <                my ($loc_text, $loc_exitcode) = VGWhoIs::Core::wwwsgrep($host,$additional);
296 <                $exitcode = max($exitcode, $loc_exitcode);
297 <                if ($loc_exitcode) {
298 <                        $result .= "Query to web server failed.\n";
299 <                } else {
300 <                        if ($loc_text ne '') {
301 <                                $result = "Match found:\n$loc_text\n";
302 <                        } else {
303 <                                $result = "No match found. This probably means that this domain does not exist.\n";
304 <                        }
305 <                }
306 <        }
307 <
308 <        elsif ($method =~ /^whois(|jp|arin)$/) {
269 >        elsif ($method eq 'whois') {
270                  my ($parameter,$outquery,$prefix) = ('', '', '');
271  
272                  my $port       = 43;
# Line 382 | Line 343 | sub VGWhoIs::Core::doquery {
343   #               $result = `lynx -connect_timeout=10 -dump "$host" 2>&1`;
344   #               $result .= "FAILED with exit code $?\n\n" if $?;
345  
346 + #               $result = `curl --max-time 10 --stderr /dev/null "$host" 2>&1`; # TODO escape
347 +
348                  # TODO: VGWhoIs::Core::getsource ok? war vorher IMMER lynx
349                  my ($loc_text, $loc_exitcode) = VGWhoIs::Core::getsource($host);
350  
# Line 397 | Line 360 | sub VGWhoIs::Core::doquery {
360                  my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
361  
362                  print "Querying $hostname ($protocol) with cgi.\n\n";
400 #!!
401 #               print "echo -e '$additional\n---' | lynx -connect_timeout=10 -dump -post_data '$host'\n";
402
403 # TODO: VGWhoIs::Utils::render_html() better? TODO: lynx source?
404 # [Ma 22.07.2013] "echo -e" does not work... "-e" will shown to the output... However "\n" will still work if I remove -e ... weird.
405 #               $result = `echo -e "$additional\n---" | lynx -dump -post_data "$host" 2>&1`; # TODO escape
406 #               $result = `echo "$additional\n---" | lynx -dump -post_data "$host" 2>&1`; # TODO escape
407                $result = `echo "$additional" | curl --silent -X POST --data-binary \@- "$host" | lynx -dump -stdin 2>&1`; # TODO escape
408                my $loc_exitcode = $?;
409                $exitcode = max($exitcode, $loc_exitcode);
410                $result .= "FAILED with exit code $loc_exitcode\n\n" if $loc_exitcode;
411        }
412
413        elsif ($method eq 'cgipostcurl') {
414                my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
415
416                print "Querying $hostname ($protocol) with cgi.\n\n";
417 #               print "$additional\n"; #!!
418 #               print "curl --max-time 10 --stderr /dev/null -e $host --data '$additional' $host | lynx -dump -stdin\n";
419
420                # TODO: "set pipefail" doesn't work (insecure certificate will not cause the function to fail)
421                $result = `curl --max-time 10 --insecure --stderr /dev/null -e "$host" --data "$additional" "$host" | lynx -dump -stdin 2>&1`; # TODO escape
363  
364 +                # DM 2019-05-27: Added "-e" (referrer) because www.whois.az needs it
365 +                # Things we could additionally add:  --max-time 10 --insecure --stderr /dev/null
366 +                $result = `printf "$additional" | curl --silent -e "$host" -X POST --data-binary \@- "$host" | lynx -dump -stdin 2>&1`; # TODO escape
367                  my $loc_exitcode = $?;
368                  $exitcode = max($exitcode, $loc_exitcode);
369                  $result .= "FAILED with exit code $loc_exitcode\n\n" if $loc_exitcode;
370          }
371  
428        elsif ($method eq 'cgihttps') {
429                my ($protocol, $hostname) = VGWhoIs::Utils::splitProtocolHost($host);
430
431                print "Querying $hostname ($protocol) with cgi.\n\n";
432 #               print "$additional\n"; #!!
433 #               print "curl --max-time 10 --stderr /dev/null $host | lynx -dump -stdin\n";
434 #               $result = `curl --max-time 10 --insecure --stderr /dev/null "$host" | lynx -dump -stdin 2>&1`;
435                my $html = `curl --max-time 10 --insecure --stderr /dev/null "$host" 2>&1`; # TODO escape. why --insecure?
436                my $loc_exitcode = $?;
437                $exitcode = max($exitcode, $loc_exitcode);
438                $html .= "FAILED with exit code $loc_exitcode\n\n" if $loc_exitcode;
439                $result = VGWhoIs::Utils::render_html($html);
440        }
441
372          elsif ($method eq 'notice') {
373                  if ($inside_multiple) {
374                          $result = "\n\nAdditional information for query '$query'.\n\n" . $additional . "\n\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines