# connections. These performance issues only matter if your server
# CPU is getting overloaded. Also, these only matter when retrieving
# HTML, because it's the HTML modification that takes all the time.
# If you can, use mod_perl. Starting with version 1.3.1, this should
# work under mod_perl, which requires Perl 5.004 or later. If you use
# mod_perl, be careful to install this as an NPH script, i.e. set the
# "PerlSendHeader Off" configuration directive. For more info, see the
# mod_perl documentation.
# If you use mod_perl and modify this script, see the note near the
# "reset 'a-z'" line below, regarding UPPER_CASE and lower_case
# variables.
#
#
# TO DO:
# What I want to hear about:
# . Any HTML tags not being converted here.
# . Any method of introducing JavaScript or other script, that's not
# being handled here.
# . Any script MIME types other than those already in @SCRIPT_MIME_TYPES.
# . Any MIME types other than text/html that have links that need to
# be converted.
# plug any other script holes (e.g. MSIE-proprietary, other MIME types?)
# This could use cleaner URL-encoding all over ($base_url, etc.)
# more error checking?
# find a simple encryption technique for proxy_encode()
# support more protocols, like mailto: or gopher:
# For ad filtering, add option to disable images from servers other than
# that of the containing HTML page? Is it worth it?
#
#
# BUGS:
# Anonymity may not not perfect. In particular, there may be some remaining
# JavaScript holes. Please let me know if you find any.
# Since ALL of your cookies are sent to this script (which then chooses
# the relevant ones), some cookies could conceivably be dropped if
# you accumulate a whole lot. I haven't seen this happen yet.
#
#
# I first wrote this in 1996 as an experiment to allow indirect browsing.
# The original seed was a program I wrote for Rich Morin's article
# in the June 1996 issue of Unix Review, online at
# http://www.cfcl.com/tin/P/199606.shtml.
#
# Confession: I didn't originally write this with the spec for HTTP
# proxies in mind, and there are probably some violations of the protocol
# (at least for proxies). This whole thing is one big violation of the
# proxy model anyway, so I hereby rationalize that the spec can be widely
# interpreted here. If there is demand, I can make it more conformant.
# The HTTP client and server components should be fine; it's just the
# special requirements for proxies that may not be followed.
#
#--------------------------------------------------------------------------
use strict ;
use Socket ;
# First block below is config variables, second block is sort-of config
# variables, third block is persistent constants, fourth block is would-be
# persistent constants (not set until needed), fifth block is constants for
# JavaScript processing (mostly regular expressions), and last block is
# variables.
# Removed $RE_JS_STRING_LITERAL to help with Perl's long-literal-string bug,
# but can replace it later if/when that is fixed. Added
# $RE_JS_STRING_LITERAL_START, $RE_JS_STRING_REMAINDER_1, and
# $RE_JS_STRING_REMAINDER_2 as part of the workaround.
use vars qw(
$TEXT_ONLY
$REMOVE_COOKIES $REMOVE_SCRIPTS $FILTER_ADS $HIDE_REFERER
$INSERT_ENTRY_FORM $ALLOW_USER_CONFIG
@ALLOWED_SERVERS @BANNED_SERVERS @BANNED_NETWORKS
$NO_COOKIE_WITH_IMAGE @ALLOWED_COOKIE_SERVERS @BANNED_COOKIE_SERVERS
@ALLOWED_SCRIPT_SERVERS @BANNED_SCRIPT_SERVERS
@BANNED_IMAGE_URL_PATTERNS $RETURN_EMPTY_GIF
$USER_IP_ADDRESS_TEST $DESTINATION_SERVER_TEST
$INSERT_HTML $INSERT_FILE $ANONYMIZE_INSERTION $FORM_AFTER_INSERTION
$INSERTION_FRAME_HEIGHT
$RUNNING_ON_SSL_SERVER $NOT_RUNNING_AS_NPH
$HTTP_PROXY $SSL_PROXY $NO_PROXY $PROXY_AUTH $SSL_PROXY_AUTH
$MINIMIZE_CACHING
$SESSION_COOKIES_ONLY $COOKIE_PATH_FOLLOWS_SPEC $RESPECT_THREE_DOT_RULE
@PROXY_GROUP
$USER_AGENT $USE_PASSIVE_FTP_MODE $SHOW_FTP_WELCOME
$PROXIFY_SCRIPTS $ALLOW_UNPROXIFIED_SCRIPTS $PROXIFY_COMMENTS
$ENCODE_DECODE_BLOCK_IN_JS
$USE_POST_ON_START $ENCODE_URL_INPUT
$REMOVE_TITLES $NO_BROWSE_THROUGH_SELF $NO_LINK_TO_START $MAX_REQUEST_SIZE
@TRANSMIT_HTML_IN_PARTS_URLS
$QUIETLY_EXIT_PROXY_SESSION
$OVERRIDE_SECURITY
@SCRIPT_MIME_TYPES @OTHER_TYPES_TO_REGISTER @TYPES_TO_HANDLE
$NON_TEXT_EXTENSIONS
$PROXY_VERSION
@MONTH @WEEKDAY %UN_MONTH
@BANNED_NETWORK_ADDRS
$USER_IP_ADDRESS_TEST_H $DESTINATION_SERVER_TEST_H
$RUNNING_ON_IIS
@NO_PROXY
$NO_CACHE_HEADERS
=2= |