httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestConfig.pm TestConfigPerl.pm
Date Tue, 12 Aug 2003 23:36:51 GMT
nd          2003/08/12 16:36:51

  Modified:    perl-framework/Apache-Test Changes
               perl-framework/Apache-Test/lib/Apache TestConfig.pm
                        TestConfigPerl.pm
  Log:
  allow the creation of name based virtual hosts from .conf.in files.
  If you supply <VirtualHost servername:module> sections it will open
  just one port and insert proper NameVirtualHost and ServerName directives
  into the conf.
  
  Reviewed by: Stas
  
  Revision  Changes    Path
  1.40      +4 -0      httpd-test/perl-framework/Apache-Test/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- Changes	12 Aug 2003 19:26:41 -0000	1.39
  +++ Changes	12 Aug 2003 23:36:51 -0000	1.40
  @@ -8,6 +8,10 @@
   
   =item 1.04-dev - 
   
  +Allow the creation of name based virtual hosts by supplying
  +<VirtualHost servername:module> containers in .conf.in$ files.
  +[André Malo]
  +
   fix Apache::TestSSLCA to generate a separate index.txt file for each
   module, as on certain platforms openssl fails to re-use the same
   file. [Stas]
  
  
  
  1.170     +20 -9     httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
  
  Index: TestConfig.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
  retrieving revision 1.169
  retrieving revision 1.170
  diff -u -r1.169 -r1.170
  --- TestConfig.pm	6 Aug 2003 21:07:28 -0000	1.169
  +++ TestConfig.pm	12 Aug 2003 23:36:51 -0000	1.170
  @@ -927,10 +927,11 @@
   sub parse_vhost {
       my($self, $line) = @_;
   
  -    my($indent, $module);
  -    if ($line =~ /^(\s*)<VirtualHost\s+(?:_default_:)?(.*?)\s*>\s*$/) {
  -        $indent = $1 || "";
  -        $module = $2;
  +    my($indent, $module, $namebased);
  +    if ($line =~ /^(\s*)<VirtualHost\s+(?:_default_:|([^:]+):)?(.*?)\s*>\s*$/) {
  +        $indent    = $1 || "";
  +        $namebased = $2 || "";
  +        $module    = $3;
       }
       else {
           return undef;
  @@ -956,14 +957,23 @@
       }
   
       #allocate a port and configure this module into $self->{vhosts}
  -    my $port = $self->new_vhost($module);
  +    my $port = $self->new_vhost($module, $namebased);
   
       #extra config that should go *inside* the <VirtualHost ...>
  -    my @in_config = $self->servername_config($vars->{servername},
  +    my @in_config = $self->servername_config($namebased
  +                                                 ? $namebased
  +                                                 : $vars->{servername},
                                                $port);
   
  -    #extra config that should go *outside* the <VirtualHost ...>
  -    my @out_config = ([Listen => $port]);
  +    my @out_config = ();
  +    if ($self->{vhosts}->{$module}->{namebased} < 2) {
  +        #extra config that should go *outside* the <VirtualHost ...>
  +        @out_config = ([Listen => $port]);
  +
  +        if ($self->{vhosts}->{$module}->{namebased}) {
  +            push @out_config => [NameVirtualHost => "*:$port"];
  +        }
  +    }
   
       #there are two ways of building a vhost
       #first is when we parse test .pm and .c files
  @@ -989,7 +999,8 @@
           #used when parsing *.conf.in files
           in_string     => $form_string->($double_indent, @in_config),
           out_string    => $form_string->($indent, @out_config),
  -        line          => "$indent<VirtualHost _default_:$port>",
  +        line          => "$indent<VirtualHost " . ($namebased ? '*' : '_default_')
.
  +                         ":$port>",
       };
   }
   
  
  
  
  1.76      +21 -7     httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm
  
  Index: TestConfigPerl.pm
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- TestConfigPerl.pm	29 Jul 2003 15:19:24 -0000	1.75
  +++ TestConfigPerl.pm	12 Aug 2003 23:36:51 -0000	1.76
  @@ -214,17 +214,31 @@
   sub vhost_container {
       my($self, $module) = @_;
       my $port = $self->{vhosts}->{$module}->{port};
  -    VirtualHost => "_default_:$port";
  +    my $namebased = $self->{vhosts}->{$module}->{namebased};
  +
  +    VirtualHost => ($namebased ? '*' : '_default_') . ":$port";
   }
   
   sub new_vhost {
  -    my($self, $module) = @_;
  +    my($self, $module, $namebased) = @_;
  +    my($port, $servername, $vhost);
  +
  +    unless ($namebased and exists $self->{vhosts}->{$module}) {
  +        $port       = $self->server->select_port;
  +        $vhost      = $self->{vhosts}->{$module} = {};
  +
  +        $vhost->{port}       = $port;
  +        $vhost->{namebased}  = $namebased ? 1 : 0;
  +    }
  +    else {
  +        $vhost      = $self->{vhosts}->{$module};
  +        $port       = $vhost->{port};
  +        # remember the already configured Listen/NameVirtualHost
  +        $vhost->{namebased}++;
  +    }
   
  -    my $port       = $self->server->select_port;
  -    my $servername = $self->{vars}->{servername};
  -    my $vhost      = $self->{vhosts}->{$module} = {};
  +    $servername = $self->{vars}->{servername};
   
  -    $vhost->{port}       = $port;
       $vhost->{servername} = $servername;
       $vhost->{name}       = join ':', $servername, $port;
       $vhost->{hostport}   = $self->hostport($vhost, $module);
  @@ -354,7 +368,7 @@
       if ($cfg) {
           my $port = $cfg->{port};
           $cfg->{out_postamble}->();
  -        $self->postamble("$indent<VirtualHost _default_:$port>");
  +        $self->postamble($cfg->{line});
           $cfg->{in_postamble}->();
       } else {
           $self->postamble("$indent$line");
  
  
  

Mime
View raw message