Apache-ProxyConf

 view release on metacpan or  search on metacpan

ProxyConf.pm  view on Meta::CPAN

#
# $Id: ProxyConf.pm,v 1.2 2005/03/16 10:29:58 pschoo Exp $
# $Source: /cvs-mis/local/web/proxyconf/ProxyConf.pm,v $
#

package Apache::ProxyConf;

$^W=1;
use strict;
use vars qw($VERSION);
$VERSION = '1.0';

use Apache::Constants qw(:common);
use Apache::Log ();
use Config::IniFiles;
use Net::IPv4Addr qw(/^ipv4/);

my %cfname;	# Hash of configuration filenames per Location.
my %conf;	# Hash of parsed configuration files.
my %lastmod;	# Modification times of configuration files.

#
# Send header with proper content type. Add some HTML codes when the
# debugging option is enabled.
#

sub send_header {
        my($r, $debug) = @_;

	if ($debug) {
		$r->content_type('text/html');
		$r->send_http_header;
		print <<END;
<html>
<head>
<title>Output of ProxyConf.pm with debug option</title>

<style type="text/css">
code {
  font-family: LucidaTypewriter, Courier, "Courier New", monospace;
  color: #990000;
}
</style>
</head>
<body bgcolor="#FFFFFF">
<h1>Output of ProxyConf.pm with debug option</h1>
<pre>
END

	} else {
		$r->content_type('application/x-ns-proxy-autoconfig');
		$r->send_http_header;
	}
}

#
# Send trailer to close HTML statements properly.
#

sub send_trailer {
        my($debug) = @_;

	if ($debug) {
		print <<END;
</pre>
</body>
</html>
END

	}
}

#
# Return a default proxy autoconfig script when the configuration file is not
# defined, or cannot be opened.
#

sub default_config {
        my($r, $debug) = @_;
	
	send_header($r, $debug);
	print "<code>\n" if $debug;
	print <<END;
// Default configuration.
// The configuration file is not defined or cannot be opened.
function FindProxyForURL(url, host)
{
	return "DIRECT";
}
END

	print "</code>\n" if $debug;
	send_trailer($debug);
}

#
# Calculate the used subnet masklengths for all networks in a specified
# section.
#



( run in 1.910 second using v1.01-cache-2.11-cpan-ceb78f64989 )