Diff for /loncom/lonnet/perl/londns.pm between versions 1.4 and 1.7

version 1.4, 2017/11/30 14:33:35 version 1.7, 2021/06/06 23:14:18
Line 31  package Apache::londns; Line 31  package Apache::londns;
   
 use strict;  use strict;
 use LONCAPA;  use LONCAPA;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http :remotehost);
 use Apache::lonnet;  use Apache::lonnet;
   
 sub serve_file {  sub serve_file {
     my ($r,$file,$type)=@_;      my ($r,$dir,$file,$type)=@_;
     if (open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/$file")) {      if (($dir eq '') || ($file eq '')) {
           return FORBIDDEN;
       }
       if (open(my $config,"<","$dir/$file")) {
         my $contents = join('',<$config>);          my $contents = join('',<$config>);
           close($config);
         $r->content_type($type);          $r->content_type($type);
         $r->send_http_header;          $r->send_http_header;
         return OK if $r->header_only;          return OK if $r->header_only;
Line 51  sub serve_file { Line 55  sub serve_file {
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
   
       my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP);
       my @hostids= &Apache::lonnet::get_hosts_from_ip($reqhost);
       if (!@hostids && $reqhost ne '127.0.0.1' ) {
           $r->log_reason("Unable to find a host for ".
                          $r->get_remote_host(REMOTE_NOLOOKUP));
           return FORBIDDEN;
       }
   
     my $command = (split('/',$r->uri))[3];      my $command = (split('/',$r->uri))[3];
     if ($command eq 'hosts') {      my ($dir,$file) = &Apache::lonnet::parse_getdns_url($command,$r->uri);
  return &serve_file($r,'dns_hosts.tab','loncapa/hosts');      my %types = (
     } elsif ($command eq 'domain') {                      hosts      => 'loncapa/hosts',
  return &serve_file($r,'dns_domain.tab','loncapa/domain');                      domain     => 'loncapa/domain',
     } elsif ($command eq 'checksums') {                      checksums  => 'loncapa/versions',
         my $version = (split('/',$r->uri))[4];                      loncapaCRL => 'application/x-pem-file',
         return &serve_file($r,"dns_checksums/$version.tab",'loncapa/versions');                  );
       if (exists($types{$command})) {
           return &serve_file($r,$dir,$file,$types{$command});
     }      }
     return FORBIDDEN;      return FORBIDDEN;
 }  }

Removed from v.1.4  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>