[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 09 Feb 2005 22:04:22 -0000


albertel		Wed Feb  9 17:04:22 2005 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - load up host -> ip table on start up
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.595 loncom/lonnet/perl/lonnet.pm:1.596
--- loncom/lonnet/perl/lonnet.pm:1.595	Sat Feb  5 17:20:56 2005
+++ loncom/lonnet/perl/lonnet.pm	Wed Feb  9 17:04:22 2005
@@ -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.596 2005/02/09 22:04:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,7 +35,7 @@
 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,7 +5683,15 @@
        next if ($configline =~ /^(\#|\s*$)/);
        chomp($configline);
        my ($id,$domain,$role,$name)=split(/:/,$configline);
+       $name=~s/\s^//g;
        if ($id && $domain && $role && $name) {
+	 my $ip = gethostbyname($name);
+	 if (length($ip) ne 4) {
+	     &logthis("Skipping host $id name $name no IP $ip found\n");
+	     next;
+	 }
+	 $ip=inet_ntoa($ip);
+	 push(@{$iphost{$ip}},$id);
 	 $hostname{$id}=$name;
 	 $hostdom{$id}=$domain;
 	 if ($role eq 'library') { $libserv{$id}=$name; }