IO-Socket-Socks-Wrapper

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        package subroutine added
      - tests for new syntax added
      - documentation improvements

0.04  Fri Jun  3 00:38:32 2011
      - alot of tests added
      - suppress warnings about prototype mismatch
      - override IO::Socket::connect instead of IO::Socket::INET::connect if package inherits from IO::Socket,
        makes available to wrap IO::Socket::INET package
      - call package version of the connect if it has own, makes available to wrap packages like
        IO::Socket::SSL

0.03  Mon Apr 18 23:32:42 2011
      - added support for packages (even if package name != module name)

0.02  Mon Feb 15 18:22:17 2011
      - added support for modules with own connect function, different from IO::Socket::INET::connect;

0.01  Thu Feb 3 11:23:28 2011
      - original version;

t/11_live.t  view on Meta::CPAN


use Test::More;
use IO::Socket::Socks::Wrapper;
require 't/subs.pm';
use strict;

$^W = 0;

SKIP: {
	skip "fork, windows, sux" if $^O =~ /MSWin/i;
	eval { require IO::Socket::SSL; require LWP;  }
		or skip "No LWP or IO::Socket::SSL found";
	
	my $ua = LWP::UserAgent->new(timeout => 10);
	my $page = $ua->get('https://encrypted.google.com')->content;
	skip "Seems there is no internet connection on this machine"
		if (() = $page =~ /google/g) < 2;
	
	my ($s_pid, $s_host, $s_port) = make_socks_server(5);
	
	IO::Socket::Socks::Wrapper->import(
		IO::Socket::SSL:: => {
			ProxyAddr => $s_host,
			ProxyPort => $s_port,
		}
	);
	
	$ua = LWP::UserAgent->new(timeout => 10);
	$page = $ua->get('https://encrypted.google.com')->content;
	ok((() = $page =~ /google/g) >= 2, 'LWP+IO::Socket::SSL socks5 wrapping +Server');
	ok(IO::Socket::SSL->new(PeerAddr => "encrypted.google.com", PeerPort => 443, SSL_verify_mode => &IO::Socket::SSL::SSL_VERIFY_NONE), 'IO::Socket::SSL socks5 wrapping +Server')
		or diag "SYS_ERR=$!, SSL_ERR=$IO::Socket::SSL::SSL_ERROR, IO::Socket::SSL::VERSION=$IO::Socket::SSL::VERSION, Net::SSLeay::VERSION=$Net::SSLeay::VERSION";
	
	kill 15, $s_pid;
	is(wait(), $s_pid, 'socks5 server terminated');
	ok($?>>8 >= 2, '2 or more connections processed') or diag $?>>8, " connections processed; IO::Socket::SSL::VERSION=$IO::Socket::SSL::VERSION";
	
	$page = $ua->get('https://encrypted.google.com')->content;
	ok((() = $page =~ /google/g) < 2, 'LWP+IO::Socket::SSL socks5 wrapping -Server') or 
		diag "Net::HTTPS version=$Net::HTTPS::VERSION, SSL_SOCKET_CLASS=$Net::HTTPS::SSL_SOCKET_CLASS, page=", $page;
};

SKIP: {
	skip "fork, windows, sux" if $^O =~ /MSWin/i;
	eval { require Net::POP3 }
		or skip "No Net::POP3 found";
	
	Net::POP3->new('gorodok.net', Timeout => 10)
		or skip "Seems there is no internet connection on this machine";



( run in 0.501 second using v1.01-cache-2.11-cpan-4d50c553e7e )