Handle hostnames with upper-case letters
[webmin.git] / servers / find.cgi
1 #!/usr/local/bin/perl
2 # find.cgi
3 # Broadcast to other webmin servers
4
5 use strict;
6 use warnings;
7 require './servers-lib.pl';
8 our (%text, %access, %in, %config);
9 &ReadParse();
10 $access{'find'} || &error($text{'find_ecannot'});
11
12 my $limit;
13 my @broad;
14 if (defined($in{'scan'})) {
15         # send to all addresses on the given network
16         $in{'scan'} =~ /^(\d+\.\d+\.\d+)\.0$/ || &error($text{'find_escan'});
17         for(my $i=0; $i<256; $i++) {
18                 push(@broad, "$1.$i");
19                 }
20         $limit = $config{'scan_time'};
21         $in{'port'} =~ /^\d+$/ || &error($text{'find_eport'});
22         }
23 else {
24         # broadcast to some useful addresses
25         my $myip = &get_my_address();
26         if ($myip) {
27                 push(@broad, &address_to_broadcast($myip, 0));
28                 }
29         push(@broad, "255.255.255.255");
30         $limit = 2;
31         }
32
33 # Add local network addresses
34 if (&foreign_check("net") && !defined($in{'scan'})) {
35         &foreign_require("net", "net-lib.pl");
36         foreach my $a (&foreign_call("net", "active_interfaces")) {
37                 push(@broad, $a->{'broadcast'}) if ($a->{'broadcast'});
38                 }
39         }
40
41 # Get and display responses
42 &ui_print_unbuffered_header(undef, $text{'find_title'}, "");
43 if (defined($in{'scan'})) {
44         print &text('find_scanning', "<tt>$in{'scan'}</tt>"),"<p>\n";
45         }
46 else {
47         print &text('find_broading', join(" , ", map { "<tt>$_</tt>" } @broad)),"<p>\n";
48         }
49 &find_servers(\@broad, $limit, 0, $in{'defuser'}, $in{'defpass'}, undef, undef,
50               0, $in{'port'});
51
52 &ui_print_footer("", $text{'index_return'});
53