Net-Proxy

 view release on metacpan or  search on metacpan

script/connect-tunnel  view on Meta::CPAN

use Getopt::Long;
use Pod::Usage;

# die early if this module is not installed
eval { require LWP::UserAgent; };
die "LWP::UserAgent required to run connect-tunnel\n" if $@;

# default configuration
our %CONF = (
    'proxy-authentication' => '',
    'proxy'                => $ENV{HTTP_PROXY},
    'user-agent'           => "connect-tunnel/$Net::Proxy::VERSION",
    'verbose'              => 0,
);

#
# get and check the options
#
GetOptions( \%CONF, "verbose|v+", "tunnel|T=s@", "proxy|P=s",
    "proxy-authentication|A=s", "local-only|L", "user-agent|U=s" )
   or pod2usage();

script/connect-tunnel  view on Meta::CPAN

                -T 22:ssh.example.com:443
                -T 222:ssh2.example.com:443

But naturally, you will need to correctly set up the ports in your clients.

Mmm, such a long command line would perfectly fit in an alias or a F<.BAT>
file. C<;-)>

=head1 ENVIRONMENT VARIABLES

The environment variable C<HTTP_PROXY> can be used to provide
a proxy definition.

The environment variable is overriden by the B<--proxy> option,
if passed to B<connect-tunnel>.

=head1 AUTHOR

Philippe "BooK" Bruhat, C<< <book@cpan.org> >>.

I seem to have re-invented a well-known wheel with that script, but at

t/21connect.t  view on Meta::CPAN

my $args = {};

eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^host parameter is required /, 'No host');
$args->{host} = 'example.com';

eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^port parameter is required /, 'No port');
$args->{port} = 9999;

$ENV{HTTP_PROXY} = 'http://powie:zgruppp@urkk.crunch.com:8888/';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'env_proxy');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
delete $ENV{HTTP_PROXY};

eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^proxy_host parameter is required /, 'No proxy_host');
$args->{proxy_host} = 'urkk.crunch.com';

eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'proxy_host');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
$args->{proxy_port} = 8888;



( run in 0.940 second using v1.01-cache-2.11-cpan-71847e10f99 )