|
NAMEAnyEvent::Connector - tcp_connect with transparent proxy handling SYNOPSIS use AnyEvent::Connector;
## Specify the proxy setting explicitly.
my $c = AnyEvent::Connector->new(
proxy => 'http://proxy.example.com:8080',
no_proxy => ['localhost', 'your-internal-domain.net']
);
## Proxy setting from "http_proxy" and "no_proxy" environment variables.
my $cenv = AnyEvent::Connector->new(
env_proxy => "http",
);
## Same API as AnyEvent::Socket::tcp_connect
my $guard = $c->tcp_connect(
"target.hogehoge.org", 80,
sub {
## connect callback
my ($fh ,$host, $port, $retry) = @_;
...;
},
sub {
## prepare calback
my ($fh) = @_;
...;
}
);
DESCRIPTIONAnyEvent::Connector object has "tcp_connect" method compatible with that from AnyEvent::Socket, and it handles proxy settings transparently. CLASS METHODS$conn = AnyEvent::Connector->new(%args)The constructor. Fields in %args are:
OBJECT METHOD$guard = $conn->tcp_connect($host, $port, $connect_cb, $prepare_cb)Make a (possibly proxied) TCP connection to the given $host and $port. If "$conn->proxy_for($host, $port)" returns "undef", the behavior of this method is exactly the same as "tcp_connect" function from AnyEvent::Socket. If "$conn->proxy_for($host, $port)" returns a proxy URL, it behaves in the following way.
$proxy = $conn->proxy_for($host, $port)If $conn uses a proxy to connect to the given $host and $port, it returns the string of the proxy URL. Otherwise, it returns "undef". SEE ALSO
REPOSITORY<https://github.com/debug-ito/AnyEvent-Connector> BUGS AND FEATURE REQUESTSPlease report bugs and feature requests to my Github issues <https://github.com/debug-ito/AnyEvent-Connector/issues>. Although I prefer Github, non-Github users can use CPAN RT <https://rt.cpan.org/Public/Dist/Display.html?Name=AnyEvent-Connector>. Please send email to "bug-AnyEvent-Connector at rt.cpan.org" to report bugs if you do not have CPAN RT account. AUTHORToshio Ito, "<toshioito at cpan.org>" LICENSE AND COPYRIGHTCopyright 2018 Toshio Ito. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See <http://dev.perl.org/licenses/> for more information.
|