version 1.1073, 2010/07/17 20:02:13
|
version 1.1074, 2010/07/20 02:42:47
|
Line 76 use HTTP::Date;
|
Line 76 use HTTP::Date;
|
use Image::Magick; |
use Image::Magick; |
|
|
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
use vars qw(%perlvar %spareid %pr %prp $memcache %packagetab $tmpdir |
$_64bit %env %protocol %loncaparevs); |
$_64bit %env %protocol %loncaparevs %serverhomeIDs); |
|
|
my (%badServerCache, $memcache, %courselogs, %accesshash, %domainrolehash, |
my (%badServerCache, $memcache, %courselogs, %accesshash, %domainrolehash, |
%userrolehash, $processmarker, $dumpcount, %coursedombuf, |
%userrolehash, $processmarker, $dumpcount, %coursedombuf, |
Line 253 sub get_server_loncaparev {
|
Line 253 sub get_server_loncaparev {
|
} |
} |
} |
} |
|
|
|
sub get_server_homeID { |
|
my ($hostname,$ignore_cache,$caller) = @_; |
|
unless ($ignore_cache) { |
|
my ($serverhomeID,$cached)=&is_cached_new('serverhomeID',$hostname); |
|
if (defined($cached)) { |
|
return $serverhomeID; |
|
} |
|
} |
|
my $cachetime = 12*3600; |
|
my $serverhomeID; |
|
if ($caller eq 'loncron') { |
|
my @machine_ids = &machine_ids($hostname); |
|
foreach my $id (@machine_ids) { |
|
my $response = &reply('serverhomeID',$id); |
|
unless (($response eq 'unknown_cmd') || ($response eq 'con_lost')) { |
|
$serverhomeID = $response; |
|
last; |
|
} |
|
} |
|
if ($serverhomeID eq '') { |
|
$serverhomeID = $machine_ids[-1]; |
|
} |
|
} else { |
|
$serverhomeID = $serverhomeIDs{$hostname}; |
|
} |
|
return &do_cache_new('serverhomeID',$hostname,$serverhomeID,$cachetime); |
|
} |
|
|
# -------------------------------------------------- Non-critical communication |
# -------------------------------------------------- Non-critical communication |
sub subreply { |
sub subreply { |
my ($cmd,$server)=@_; |
my ($cmd,$server)=@_; |
Line 884 sub authenticate {
|
Line 912 sub authenticate {
|
} |
} |
|
|
sub can_host_session { |
sub can_host_session { |
my ($udom,$machinedom,$remoterev,$remotesessions,$hostedsessions) = @_; |
my ($udom,$lonhost,$remoterev,$remotesessions,$hostedsessions) = @_; |
my $canhost = 1; |
my $canhost = 1; |
|
my $host_idn = &Apache::lonnet::internet_dom($lonhost); |
if (ref($remotesessions) eq 'HASH') { |
if (ref($remotesessions) eq 'HASH') { |
if (ref($remotesessions->{'excludedomain'}) eq 'ARRAY') { |
if (ref($remotesessions->{'excludedomain'}) eq 'ARRAY') { |
if (grep(/^\Q$machinedom\E$/,@{$remotesessions->{'excludedomain'}})) { |
if (grep(/^\Q$host_idn\E$/,@{$remotesessions->{'excludedomain'}})) { |
$canhost = 0; |
$canhost = 0; |
} else { |
} else { |
$canhost = 1; |
$canhost = 1; |
} |
} |
} |
} |
if (ref($remotesessions->{'includedomain'}) eq 'ARRAY') { |
if (ref($remotesessions->{'includedomain'}) eq 'ARRAY') { |
if (grep(/^\Q$machinedom\E$/,@{$remotesessions->{'includedomain'}})) { |
if (grep(/^\Q$host_idn\E$/,@{$remotesessions->{'includedomain'}})) { |
$canhost = 1; |
$canhost = 1; |
} else { |
} else { |
$canhost = 0; |
$canhost = 0; |
Line 9773 sub get_dns {
|
Line 9802 sub get_dns {
|
my %libserv; |
my %libserv; |
my $loaded; |
my $loaded; |
my %name_to_host; |
my %name_to_host; |
|
my %internetdom; |
|
|
sub parse_hosts_tab { |
sub parse_hosts_tab { |
my ($file) = @_; |
my ($file) = @_; |
Line 9780 sub get_dns {
|
Line 9810 sub get_dns {
|
next if ($configline =~ /^(\#|\s*$ )/x); |
next if ($configline =~ /^(\#|\s*$ )/x); |
next if ($configline =~ /^\^/); |
next if ($configline =~ /^\^/); |
chomp($configline); |
chomp($configline); |
my ($id,$domain,$role,$name,$protocol)=split(/:/,$configline); |
my ($id,$domain,$role,$name,$protocol,$intdom)=split(/:/,$configline); |
$name=~s/\s//g; |
$name=~s/\s//g; |
if ($id && $domain && $role && $name) { |
if ($id && $domain && $role && $name) { |
$hostname{$id}=$name; |
$hostname{$id}=$name; |
Line 9796 sub get_dns {
|
Line 9826 sub get_dns {
|
} else { |
} else { |
$protocol{$id} = 'http'; |
$protocol{$id} = 'http'; |
} |
} |
|
if (defined($intdom)) { |
|
$internetdom{$id} = $intdom; |
|
} |
} |
} |
} |
} |
} |
} |
Line 9905 sub get_dns {
|
Line 9938 sub get_dns {
|
my @uniq = grep(!$seen{$_}++, values(%hostdom)); |
my @uniq = grep(!$seen{$_}++, values(%hostdom)); |
return @uniq; |
return @uniq; |
} |
} |
|
|
|
sub internet_dom { |
|
&load_hosts_tab() if (!$loaded); |
|
|
|
my ($lonid) = @_; |
|
return $internetdom{$lonid}; |
|
} |
} |
} |
|
|
{ |
{ |
Line 10022 sub get_dns {
|
Line 10062 sub get_dns {
|
return undef; |
return undef; |
} |
} |
|
|
|
sub get_internet_names { |
|
my ($lonid) = @_; |
|
return if ($lonid eq ''); |
|
my ($idnref,$cached)= |
|
&Apache::lonnet::is_cached_new('internetnames',$lonid); |
|
if ($cached) { |
|
return $idnref; |
|
} |
|
my $ip = &get_host_ip($lonid); |
|
my @hosts = &get_hosts_from_ip($ip); |
|
my %iphost = &get_iphost(); |
|
my (@idns,%seen); |
|
foreach my $id (@hosts) { |
|
my $dom = &host_domain($id); |
|
my $prim_id = &domain($dom,'primary'); |
|
my $prim_ip = &get_host_ip($prim_id); |
|
next if ($seen{$prim_ip}); |
|
if (ref($iphost{$prim_ip}) eq 'ARRAY') { |
|
foreach my $id (@{$iphost{$prim_ip}}) { |
|
my $intdom = &internet_dom($id); |
|
unless (grep(/^\Q$intdom\E$/,@idns)) { |
|
push(@idns,$intdom); |
|
} |
|
} |
|
} |
|
$seen{$prim_ip} = 1; |
|
} |
|
return &Apache::lonnet::do_cache_new('internetnames',$lonid,\@idns,12*60*60); |
|
} |
|
|
} |
} |
|
|
BEGIN { |
BEGIN { |
Line 10110 BEGIN {
|
Line 10180 BEGIN {
|
} |
} |
close($config); |
close($config); |
} |
} |
|
} |
|
} |
|
|
|
# ---------------------------------------------------------- Read serverhostID table |
|
{ |
|
if (-e "$perlvar{'lonTabDir'}/serverhomeIDs.tab") { |
|
if (open(my $config,"<$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { |
|
while (my $configline=<$config>) { |
|
chomp($configline); |
|
my ($name,$id)=split(/:/,$configline); |
|
$serverhomeIDs{$name}=$id; |
|
} |
|
close($config); |
|
} |
} |
} |
} |
} |
|
|