AnyEvent-SOCKS-Client

 view release on metacpan or  search on metacpan

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

			AE::log "error" => "Connect cmd rejected: status is $status" ;
			return ;
		}
		$self->connect_cmd_finalize( $type ); 
	});
}

sub connect_cmd_finalize{ 
	my( $self, $type ) = @_ ;

	AE::log "debug" => "Connect cmd done, bind atype is $type"; 

	if($type == TYPE_IP4){
		$self->{hd}->push_read( chunk => 6, sub{
			my( $host, $port) = unpack( "a4n", $_[1] );
			$self->socks_connect_done( format_ipv4( $host ), $port );
		}); 
	}
	elsif($type == TYPE_IP6){
		$self->{hd}->push_read( chunk => 18, sub{
			my( $host, $port) = unpack( "a16n", $_[1] );

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

				$self->socks_connect_done( $host, $port );
			});
		});
	}
	else{
		AE::log "error" => "Unknown atype $type";
	}
}

sub socks_connect_done{ 
	my( $self, $bind_host, $bind_port ) = @_; 

	my $that = shift @{ $self->{chain} }; # shift = move forward in chain
	AE::log "debug" => "Done with server socks$that->{v}://$that->{host}:$that->{port} , bound to $bind_host:$bind_port";

	if( @{ $self->{chain} } ){
		$self->handshake ;
		return ;
	}

	AE::log "debug" => "Giving up fh and returning to void...";
	my( $fh, $c_cb ) = ( $self->{hd}->fh, delete $self->{c_cb} );
	$self->DESTROY;
	$c_cb->( $fh );



( run in 0.567 second using v1.01-cache-2.11-cpan-140bd7fdf52 )