UniEvent::Socks - Socks support for UniEvent's tcp handles.
UniEvent::Socks makes it possible to connect UniEvent's tcp handle via socks proxy server.
UniEvent::Socks is a stream filter, it doesn't change API of tcp handle. Just use it as you would without socks proxy.
use UniEvent::Socks; my $tcp = UniEvent::Tcp->new; UniEvent::Socks::use_socks($tcp, $proxy_host, $proxy_port); $tcp->connect($host, $port); # connect to destination via proxy $tcp->connect_callback(sub { # called when connect to destination via proxy is established }); ... # use as arbitrary connection # via object method $tcp->use_socks("socks5://myproxy.com:1111");
Enables socks proxy for tcp handle.
$proxy_host and $proxy_port is the location of socks 5 proxy. Optional login and password can be defined to authorize on socks proxy.
$proxy_host
$proxy_port
If $socks_resolve is true and host supplied to tcp handle's connect() method is a domain name, then name resolution will be made on socks proxy server's side.
$socks_resolve
host
connect()
Gets host, port, login and password from an URI and calls the above version of use_socks() with these params and socks_resolve = true.
port
login
password
use_socks()
socks_resolve
URI must be a string or an object of class URI::XS. It must have "socks5" scheme ("sock5://user:pass@host:port/").
For convenience, UniEvent::Socks adds use_socks() method to UniEvent::Tcp package. Its synopsis is the same as for functions described above except for the first argument $tcp_handle which should not be passed.
UniEvent::Socks
UniEvent::Tcp
$tcp_handle
Pronin Oleg <syber@cpan.org>, Crazy Panda LTD
You may distribute this code under the same terms as Perl itself.
To install UniEvent::Socks, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UniEvent::Socks
CPAN shell
perl -MCPAN -e shell install UniEvent::Socks
For more information on module installation, please visit the detailed CPAN module installation guide.