LWP-Protocol-socks-1.7/00007550004066ۈR0000000000012366271713012560 5ustar scrLWP-Protocol-socks-1.7/Changes00004440004066ۈR0000000150512366271655014057 0ustar scrRevision history for Perl extension LWP::Protocol::socks. 1.7 Wed Jul 30 15:34:17 PDT 2014 - need to use start_SSL instead of new_from_fd for https connections. (https://github.com/scr/cpan/pull/3) 1.6 Sun Feb 12 09:54:12 PST 2012 - Fix Issue with newer LWP. 1.4 Tue Aug 23 23:19:57 PDT 2011 - Incorporate Oleg's fixes to the following bugs: - https://rt.cpan.org/Ticket/Display.html?id=63468 - https://rt.cpan.org/Ticket/Display.html?id=63467 1.3 Fri Jul 24 12:00:00 2010 - Working on Adding user:pass support for https://rt.cpan.org/Ticket/Display.html?id=48172 1.2 Fri Jul 23 08:10:00 2010 - Making work when LWP::Protocol::https::Socket uses Net::SSL 0.01 Mon Jul 7 21:30:04 2008 - original version; created by h2xs 1.23 with options -b 5.6.1 -AXn LWP::Protocol::socks LWP-Protocol-socks-1.7/lib/00007550004066ۈR0000000000012366271713013326 5ustar scrLWP-Protocol-socks-1.7/lib/LWP/00007550004066ۈR0000000000012366271713013770 5ustar scrLWP-Protocol-socks-1.7/lib/LWP/Protocol/00007550004066ۈR0000000000012366271713015571 5ustar scrLWP-Protocol-socks-1.7/lib/LWP/Protocol/socks.pm00004440004066ۈR0000001162012366271677017260 0ustar scr############################## package LWP::Protocol::http::socks; require LWP::Protocol::http; our @ISA = qw(LWP::Protocol::http); our $VERSION = "1.7"; LWP::Protocol::implementor('http::socks' => 'LWP::Protocol::http::socks'); sub new { my $self = shift->SUPER::new(@_); $self->{scheme} =~ s/::socks$//; $self; } sub _extra_sock_opts { my $self = shift; my($host, $port) = @_; my @extra_sock_opts = $self->SUPER::_extra_sock_opts(@_); #(@extra_sock_opts, SocksDebug =>1, @{$self->{proxy_sock_opts}}); (@extra_sock_opts, @{$self->{proxy_sock_opts}}); } ############################## package LWP::Protocol::http::socks::Socket; require LWP::Protocol::http; require IO::Socket::Socks; require Net::HTTP; our @ISA = qw(LWP::Protocol::http::SocketMethods IO::Socket::Socks Net::HTTP); sub configure { my $self = shift; my $args = shift; my $connectAddr = $args->{ConnectAddr} = delete $args->{PeerAddr}; my $connectPort = $args->{ConnectPort} = delete $args->{PeerPort}; $self->SUPER::configure($args) or return; $self->http_configure($args); } # hack out the connect so it doesn't reconnect sub http_connect { 1; } ############################## package LWP::Protocol::https::socks; require LWP::Protocol::https; our @ISA = qw(LWP::Protocol::https); LWP::Protocol::implementor('https::socks' => 'LWP::Protocol::https::socks'); sub new { my $self = shift->SUPER::new(@_); $self->{scheme} =~ s/::socks$//; $self; } sub _extra_sock_opts { my $self = shift; my($host, $port) = @_; my @extra_sock_opts = $self->SUPER::_extra_sock_opts(@_); (@extra_sock_opts, @{$self->{proxy_sock_opts}}); #(@extra_sock_opts, @{$self->{proxy_sock_opts}}); } ############################## package LWP::Protocol::https::socks::Socket; require LWP::Protocol::https; require IO::Socket::Socks; use IO::Socket::SSL; require Net::HTTPS; our @ISA = qw(IO::Socket::SSL LWP::Protocol::https::Socket); sub new { my $class = shift; my %args = @_; my $connectAddr = $args{ConnectAddr} = delete $args{PeerAddr}; my $connectPort = $args{ConnectPort} = delete $args{PeerPort}; my $socks = new IO::Socket::Socks(%args); $args{PeerAddr} = $connectAddr; $args{PeerPort} = $connectPort; delete $args{ProxyAddr}; delete $args{ProxyPort}; delete $args{ConnectAddr}; delete $args{ConnectPort}; unless ($socks && $class->start_SSL($socks, %args)) { my $status = 'error while setting up ssl connection'; if ($@) { $status .= " ($@)"; } die($status); } $socks->http_configure(\%args); $socks; } # hack out the connect so it doesn't reconnect sub http_connect { 1; } ############################## package LWP::Protocol::socks; require LWP::Protocol; our @ISA = qw(LWP::Protocol); sub request { my($self, $request, $proxy, $arg, $size, $timeout) = @_; my $url = $request->uri; my $scheme = $url->scheme; my $protocol = LWP::Protocol::create("$scheme\::socks", $self->{ua}); $protocol->{proxy_sock_opts} = [ProxyAddr => $proxy->host, ProxyPort => $proxy->port, ]; # [RT 48172] Adding user/pass functionality if ( $proxy->userinfo() ) { push(@{$protocol->{proxy_sock_opts}}, AuthType => 'userpass', Username => $proxy->user(), Password => $proxy->pass(), ); } $protocol->request($request, undef, $arg, $size, $timeout); } 1; __END__ =head1 NAME LWP::Protocol::socks - adds support for the socks protocol and proxy facility =head1 SYNOPSIS use LWP::Protocol::socks; =head1 DESCRIPTION Use this package when you wish to use a socks proxy for your connections. It provides some essential hooks into the LWP system to implement a socks "scheme" similar to http for describing your socks connection, and can be used to proxy either http or https connections. The use case is to use LWP::UserAgent's proxy method to register your socks proxy like so: $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); Then just use your $ua object as usual! =head1 EXAMPLES #!/usr/local/bin/perl use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); # for socks5, use socks like so: $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); # for socks4, use socks4 like so: $ua->proxy([qw(http https)] => 'socks4://socks.yahoo.com:1080'); my $response = $ua->get("http://www.freebsd.org"); print $response->code,' ', $response->message,"\n"; my $response = $ua->get("https://www.microsoft.com"); print $response->code,' ', $response->message,"\n"; =head1 NOTES I don't have much time to contribute to this. If you'd like to contribute, please fork https://github.com/scr/cpan and send me a pull request. =head1 AUTHORS Sheridan C Rawlins EFE Oleg G EFE LWP-Protocol-socks-1.7/lib/LWP/Protocol/socks4.pm00004440004066ۈR0000000357312366271270017341 0ustar scrpackage LWP::Protocol::socks4; require LWP::Protocol::socks; our @ISA = qw(LWP::Protocol); sub request { my($self, $request, $proxy, $arg, $size, $timeout) = @_; my $url = $request->uri; my $scheme = $url->scheme; my $protocol = LWP::Protocol::create("$scheme\::socks", $self->{ua}); $protocol->{proxy_sock_opts} = [ProxyAddr => $proxy->host, ProxyPort => $proxy->port, SocksVersion => 4 ]; if ( $proxy->userinfo() ) { push(@{$protocol->{proxy_sock_opts}}, Username => $proxy->user() ); } $protocol->request($request, undef, $arg, $size, $timeout); } 1; __END__ =head1 NAME LWP::Protocol::socks - adds support for the socks protocol and proxy facility =head1 SYNOPSIS use LWP::Protocol::socks; =head1 DESCRIPTION Use this package when you wish to use a socks proxy for your connections. It provides some essential hooks into the LWP system to implement a socks "scheme" similar to http for describing your socks connection, and can be used to proxy either http or https connections. The use case is to use LWP::UserAgent's proxy method to register your socks proxy like so: $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); Then just use your $ua object as usual! =head1 EXAMPLES #!/usr/local/bin/perl use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); $ua->proxy([qw(http https)] => 'socks://socks.yahoo.com:1080'); my $response = $ua->get("http://www.freebsd.org"); print $response->code,' ', $response->message,"\n"; my $response = $ua->get("https://www.microsoft.com"); print $response->code,' ', $response->message,"\n"; =head1 SEE ALSO L L =head1 AUTHORS Oleg G EFE LWP-Protocol-socks-1.7/lib/URI/00007550004066ۈR0000000000012366271713013765 5ustar scrLWP-Protocol-socks-1.7/lib/URI/socks.pm00004440004066ۈR0000000116412366271270015443 0ustar scr############################## package URI::socks; require URI::http; use URI::Escape; #URI::implementor(socks => 'URI::http'); our @ISA = qw(URI::http); # [RT 48172] Adding user/pass functionality sub user { my $self = shift; my $userinfo = $self->userinfo(); my($user) = split(/:/, $userinfo); uri_unescape($user); } sub pass { my $self = shift; my $userinfo = $self->userinfo(); my(undef, $pass) = split(/:/, $userinfo); uri_unescape($pass); } 1; __END__ =head1 NAME URI::Socks - support for socks://host:port =head1 AUTHOR Sheridan C Rawlins EFE LWP-Protocol-socks-1.7/lib/URI/socks4.pm00004440004066ۈR0000000011112366271270015516 0ustar scrpackage URI::socks4; require URI::socks; our @ISA = qw(URI::socks); 1; LWP-Protocol-socks-1.7/Makefile.PL00004440004066ۈR0000000165512366271270014535 0ustar scruse 5.006001; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. my $min_lwp_version = 0; my @spec_deps; eval { require LWP; }; if ($@ || $LWP::VERSION >= 6.02) { # since LWP 6.02 LWP::Protocol::https was separated push @spec_deps, 'LWP::Protocol::https', 6.02; $min_lwp_version = 6.02; } WriteMakefile( NAME => 'LWP::Protocol::socks', VERSION_FROM => 'lib/LWP/Protocol/socks.pm', # finds $VERSION 'PREREQ_PM' => { 'IO::Socket::Socks' => 0.2, 'IO::Socket::SSL' => 0.96, 'LWP' => $min_lwp_version, @spec_deps }, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/LWP/Protocol/socks.pm', # retrieve abstract from module AUTHOR => 'Sheridan C Rawlins ') : ()), ); LWP-Protocol-socks-1.7/MANIFEST00004440004066ۈR0000000026212366271270013705 0ustar scrChanges Makefile.PL MANIFEST README t/LWP-Protocol-socks.t t/socks5.t t/socks4.t lib/LWP/Protocol/socks.pm lib/LWP/Protocol/socks4.pm lib/URI/socks.pm lib/URI/socks4.pm META.yml LWP-Protocol-socks-1.7/META.yml00004440004066ۈR0000000073612366271713014035 0ustar scr# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: LWP-Protocol-socks version: 1.7 version_from: lib/LWP/Protocol/socks.pm installdirs: site requires: IO::Socket::Socks: 0.2 IO::Socket::SSL: 0.96 LWP: 6.02 LWP::Protocol::https: 6.02 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 LWP-Protocol-socks-1.7/README00004440004066ۈR0000000246612366271270013444 0ustar scrLWP-Protocol-socks =============================== FYI, files are checked into git@github.com:scr/cpan.git git clone git@github.com:scr/cpan.git The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test # possibly setting env SOCKS_PROXY=proxyhost:proxyport make install DEPENDENCIES This module requires these other modules and libraries: blah blah blah COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) 2008 by Sheridan Rawlins This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. LWP-Protocol-socks-1.7/t/00007550004066ۈR0000000000012366271713013023 5ustar scrLWP-Protocol-socks-1.7/t/LWP-Protocol-socks.t00004440004066ۈR0000000151012366271270016562 0ustar scr# -*- mode: perl -*- # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl LWP-Protocol-socks.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 6; use_ok(qw(LWP::Protocol::socks)); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. # Tests for https://rt.cpan.org/Ticket/Display.html?id=48172 my $u = new URI('socks://user%3auser:pass%3apass@foobar.com/path/query=1'); ok($u); is(ref($u), 'URI::socks', 'isa URI::socks'); is($u->scheme(), 'socks', 'scheme eq socks'); is($u->user(), 'user:user', 'user eq "user:user"'); is($u->pass(), 'pass:pass', 'pass eq "pass:pass"'); LWP-Protocol-socks-1.7/t/socks4.t00004440004066ۈR0000000164012366271270014413 0ustar scr# -*- mode: perl -*- # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl LWP-Protocol-socks.t' ######################### use Test::More; if ($ENV{SOCKS_PROXY}) { plan tests => 3; } else { plan skip_all => 'no proxy defined; set SOCKS_PROXY'; } use_ok(qw(LWP::UserAgent)); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); ok($ua, 'got ua'); $ua->proxy([qw(http https)] => "socks4://$ENV{SOCKS_PROXY}"); my $response = $ua->get("http://www.freebsd.org"); is($response->code, 200, 'get www.freebsd.org code is 200') or diag(join(' ',$response->code,$response->message)); LWP-Protocol-socks-1.7/t/socks5.t00004440004066ۈR0000000163712366271270014422 0ustar scr# -*- mode: perl -*- # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl LWP-Protocol-socks.t' ######################### use Test::More; if ($ENV{SOCKS_PROXY}) { plan tests => 3; } else { plan skip_all => 'no proxy defined; set SOCKS_PROXY'; } use_ok(qw(LWP::UserAgent)); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $ua = new LWP::UserAgent(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/1.5.0.5'); ok($ua, 'got ua'); $ua->proxy([qw(http https)] => "socks://$ENV{SOCKS_PROXY}"); my $response = $ua->get("http://www.freebsd.org"); is($response->code, 200, 'get www.freebsd.org code is 200') or diag(join(' ',$response->code,$response->message));