File: switch.pl

package info (click to toggle)
libhttp-proxy-perl 0.304-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 720 kB
  • sloc: perl: 2,576; makefile: 4
file content (19 lines) | stat: -rwxr-xr-x 448 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl -w
use HTTP::Proxy;
use HTTP::Proxy::HeaderFilter::simple;

# call this proxy as
# eg/switch.pl proxy http://proxy1:port/,http://proxy2:port/
my %args = @ARGV;
my @proxy = split/,/, $args{proxy};
my $proxy = HTTP::Proxy->new(@ARGV);

$proxy->push_filter(
    request => HTTP::Proxy::HeaderFilter::simple->new(
        sub {
            shift->proxy->agent->proxy( http => $proxy[ rand @proxy ] );
        }
    )
);

$proxy->start;