Net::ProxyGlue
Provides an interface to a remote host through a field of differing proxy types. Socks5, connect, http, and cgi (web based) proxies are currently supported.
Net::ProxyGlue lets the user build and send data through a chain of varying types of proxy servers with different levels to randomly select from. After a chain is built, the connection is set up to read and write to the remote destination through the chain. Data can then be sent and received as if the chain didn't exist, but the user is limited to http requests if there are cgi or http proxies anywhere in the chain.
Net::ProxyGlue comes with the following methods:
Net::ProxyGlue
object. Key/value pairs
will be forwarded to the grow()
method, and are not required. See
$chain->grow
for more information.
addr => address of remote proxy in the form "host:port"
type => type of proxy service offered socks5, connect, http, and cgi supported; defaults to socks5
country => country the proxy resides in
desc => description of the proxy
pos => add the proxy to this level in the chain If pos isn't specified, the proxy will be placed at the end.
take_pos => whether to move the other proxies potentially residing at pos aside or to join up with them and be seleted randomly when path selection occurs; 1 or a 0, default is 1
Proxy chains must be in the order (socks|connect)* -> http? -> cgi* to work properly.
$chain->dump_list
.
in this hash, No error checking is done on the list, so be sure the order is correct and enough keys are specified beforehand, or else you might get unexpected errors.
$chain->grow
, minus take_pos.
host:port:type:country:desc\n
This method is an easy way to save to and load chain data from disk.
$chain-
get_order>, but it returns all the proxies in every field
in order.
host:port
$chain->connect
)
through the chain. Only send HTTP requests through chains with CGI and HTTP
proxies or else you might get unexpected results.
$chain->connect()
, do:
my $sock = $chain->{"sock"};
However, using the resulting $sock to send data will generate wildly error-prone requests for chains with HTTP and CGI proxies, so it is highly recommended you only use this method for reading, if at all.
$chain->connect
, $chain->grow
, and
$chain->new
when they return 0.
#! /usr/bin/perl # Very template example, only 1 proxy per level # Get the destination and build the list out of @ARGV, then connect # to $dest, send data, and print the response. use Net::ProxyGlue; my $dest = shift @ARGV; my $chain = Net::ProxyGlue->new; foreach my $proxy (@ARGV) { my ($addr, $type) = split(m/-/, $proxy); $chain->grow ( addr => $addr, type => $type ); } $chain->connect($dest) || die($chain->error."\n"); # fill in "... data ..." with whatever yourself $chain->send(" ... data ... "); print $line while (my $line = $chain->read); $chain->close;
Add https, ssh tunnelling, and authentication procedures.
James Halliday ( substack@users.sourceforge.net )
Copyright (c) 2005 James Halliday. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GPL.