diff options
Diffstat (limited to 'MyProxy.pl')
-rwxr-xr-x | MyProxy.pl | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -7,10 +7,9 @@ use HTTP::Response; use Log::Log4perl; use FindBin; use YAML; +use Getopt::Long; -# qui dovrei inizializzare log4perl -Log::Log4perl::init("$FindBin::Bin/log.conf"); - +my $LOGCONF="$FindBin::Bin/log.conf"; my $PORT=3128; my @PATFILES=map {"$FindBin::Bin/adzap/scripts/$_"} qw(prematch.list squid_redirect postmatch.list); my $ZAPSDIR="$FindBin::Bin/adzap/zaps"; @@ -212,9 +211,26 @@ sub jumpFilter { } { + my $socks=0; + GetOptions('socks|s!' => \$socks, + 'port|p=i' => \$PORT, + 'log|l=s' => \$LOGCONF, + ); + Log::Log4perl::init($LOGCONF); my $logger=Log::Log4perl->get_logger('MyProxy.main'); $logger->info("Loading..."); for (@PATFILES) {loadPatterns($_)}; + if ($socks) { + $logger->info("Using SOCKS"); + require LWP::Protocol::http::SocksChain; + LWP::Protocol::implementor( http => 'LWP::Protocol::http::SocksChain' ); + @LWP::Protocol::http::SocksChain::EXTRA_SOCK_OPTS=( Chain_Len => 1, + Debug => 0, + Random_Chain => 0, + Auto_Save => 1, + Restore_Type => 1, + ); + } my $proxy=HTTP::Proxy->new(port=>$PORT); $proxy->push_filter(request => HTTP::Proxy::HeaderFilter::simple->new(\&doFilter)); $proxy->push_filter(request => HTTP::Proxy::HeaderFilter::simple->new(\&jumpFilter)); |