AnyEvent-SOCKS-Client

 view release on metacpan or  search on metacpan

lib/AnyEvent/SOCKS/Client.pm  view on Meta::CPAN


use 5.006;
use strict ;

use AnyEvent;
use AnyEvent::Util qw/guard/;
use AnyEvent::Socket qw/tcp_connect parse_ipv4 format_ipv4 parse_ipv6 format_ipv6/;
use AnyEvent::Handle ;
use AnyEvent::Log ;

use Scalar::Util qw/weaken/;

require Exporter;
our $VERSION = '0.051';
our @ISA = qw/Exporter/;
our @EXPORT_OK = qw/tcp_connect_via/;

our $TIMEOUT = 300;

use constant {
	TYPE_IP4 => 1,

lib/AnyEvent/SOCKS/Client.pm  view on Meta::CPAN

		my $con = bless {
			chain => \@parsed,
			dst_host => $dst_host,
			dst_port => $dst_port,
			c_cb => $c_cb,
			pre_cb => $pre_cb,
		}, __PACKAGE__ ;
		$con->connect;

		if( defined wantarray ){ # not void
			weaken( $con );
			return guard{
				AE::log "debug" => "Guard triggered" ;
				if( ref $con eq __PACKAGE__ ){
					undef $con->{c_cb};
					$con->DESTROY;
				}
			};
		}
		undef;
	};



( run in 0.218 second using v1.01-cache-2.11-cpan-65fba6d93b7 )