--- loncom/lonnet/perl/lonnet.pm 2005/02/05 22:20:56 1.595 +++ loncom/lonnet/perl/lonnet.pm 2005/02/10 22:26:38 1.598 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.595 2005/02/05 22:20:56 albertel Exp $ +# $Id: lonnet.pm,v 1.598 2005/02/10 22:26:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,7 +35,7 @@ use HTTP::Headers; use HTTP::Date; # use Date::Parse; use vars -qw(%perlvar %hostname %homecache %badServerCache %spareid %hostdom +qw(%perlvar %hostname %homecache %badServerCache %iphost %spareid %hostdom %libserv %pr %prp %metacache %packagetab %titlecache %courseresversioncache %resversioncache %courselogs %accesshash %userrolehash $processmarker $dumpcount %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf %courseresdatacache @@ -5683,6 +5683,7 @@ BEGIN { next if ($configline =~ /^(\#|\s*$)/); chomp($configline); my ($id,$domain,$role,$name)=split(/:/,$configline); + $name=~s/\s//g; if ($id && $domain && $role && $name) { $hostname{$id}=$name; $hostdom{$id}=$domain; @@ -5692,6 +5693,21 @@ BEGIN { close($config); } +sub get_iphost { + if (%iphost) { return %iphost; } + foreach my $id (keys(%hostname)) { + my $name=$hostname{$id}; + my $ip = gethostbyname($name); + if (!$ip || length($ip) ne 4) { + &logthis("Skipping host $id name $name no IP found\n"); + next; + } + $ip=inet_ntoa($ip); + push(@{$iphost{$ip}},$id); + } + return %iphost; +} + # ------------------------------------------------------ Read spare server file { open(my $config,"<$perlvar{'lonTabDir'}/spare.tab");