version 1.13, 2004/05/03 19:52:19
|
version 1.15, 2005/02/06 07:23:40
|
Line 32 use strict;
|
Line 32 use strict;
|
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::File(); |
use Apache::File(); |
|
use IO::Socket; |
|
|
sub subscribed { |
sub subscribed { |
my ($filename,$id) = @_; |
my ($filename,$id) = @_; |
my $found=0; |
my $found=0; |
my $expr='^'.$id.':'.$Apache::lonnet::hostip{$id}.':'; |
my $hostname=$Apache::lonnet::hostname{$id}; |
|
my (undef,undef,undef,undef,$ip) = gethostbyname($hostname); |
|
$ip=inet_ntoa($ip); |
|
my $expr='^'.$id.':'.$ip.':'; |
$expr =~ s/\./\\\./g; |
$expr =~ s/\./\\\./g; |
my $sh; |
my $sh; |
if ($sh=Apache::File->new("$filename.subscription")) { |
if ($sh=Apache::File->new("$filename.subscription")) { |
Line 48 sub subscribed {
|
Line 52 sub subscribed {
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
my $reqhost = $r->get_remote_host(REMOTE_DOUBLE_REV); |
my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP); |
if (!$reqhost && $r->get_remote_host(REMOTE_NOLOOKUP) eq $r->get_server_name()) { |
my $netaddr=inet_aton($reqhost); |
$reqhost = $r->get_server_name(); |
($reqhost) = gethostbyaddr($netaddr,AF_INET); |
} |
if (!$reqhost) { |
unless ($reqhost) { |
$r->log_reason("Unable to do hostname $reqhost lookup for ".$r->get_remote_host(REMOTE_NOLOOKUP)); |
$r->log_reason("Spoof request from ".$ENV{'REMOTE_ADDR'}); |
return FORBIDDEN; |
return FORBIDDEN; |
|
} |
} |
if ($reqhost eq 'localhost.localdomain') { |
if ($reqhost eq 'localhost.localdomain') { |
return OK; |
return OK; |
} |
} |
my $return; |
my $return; |
my @ids=(); |
my @ids=(); |
my $id; |
my $id; |
foreach $id (keys %Apache::lonnet::hostname) { |
foreach $id (keys %Apache::lonnet::hostname) { |
if ($Apache::lonnet::hostname{$id} =~ /$reqhost/i) { |
if ($Apache::lonnet::hostname{$id} =~ /^\Q$reqhost\E$/i) { |
my $filename=$r->filename; |
my $filename=$r->filename; |
my $uri =$r->uri; |
my $uri =$r->uri; |
if ((-e "$filename.$id") || |
if ((-e "$filename.$id") || |