--- loncom/lonnet/perl/lonnet.pm 2007/03/28 21:44:13 1.854 +++ loncom/lonnet/perl/lonnet.pm 2007/04/03 00:49:14 1.857 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.854 2007/03/28 21:44:13 albertel Exp $ +# $Id: lonnet.pm,v 1.857 2007/04/03 00:49:14 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -53,7 +53,6 @@ use Digest::MD5; use Math::Random; use LONCAPA qw(:DEFAULT :match); use LONCAPA::Configuration; -use Apache::lonhosts; my $readit; my $max_connection_retries = 10; # Or some such value. @@ -7590,6 +7589,7 @@ sub goodbye { } BEGIN { + # ----------------------------------- Read loncapa.conf and loncapa_apache.conf unless ($readit) { { @@ -7762,6 +7762,8 @@ sub get_dns { { my %iphost; + my %name_to_ip; + my %lonid_to_ip; sub get_hosts_from_ip { my ($ip) = @_; my %iphosts = &get_iphost(); @@ -7770,10 +7772,23 @@ sub get_dns { } return; } + + sub get_host_ip { + my ($lonid) = @_; + if (exists($lonid_to_ip{$lonid})) { + return $lonid_to_ip{$lonid}; + } + my $name=&hostname($lonid); + my $ip = gethostbyname($name); + return if (!$ip || length($ip) ne 4); + $ip=inet_ntoa($ip); + $name_to_ip{$name} = $ip; + $lonid_to_ip{$lonid} = $ip; + return $ip; + } sub get_iphost { if (%iphost) { return %iphost; } - my %name_to_ip; my %hostname = &all_hostnames(); foreach my $id (keys(%hostname)) { my $name=$hostname{$id}; @@ -7789,6 +7804,7 @@ sub get_dns { } else { $ip = $name_to_ip{$name}; } + $lonid_to_ip{$id} = $ip; push(@{$iphost{$ip}},$id); } return %iphost;