Skip Menu |

This queue is for tickets about the LWP-Protocol-socks CPAN distribution.

Report information
The Basics
Id: 63468
Status: resolved
Priority: 0/
Queue: LWP-Protocol-socks

People
Owner: Nobody in particular
Requestors: oleg [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.3
Fixed in: (no value)



Subject: Socks 4 support
In version 0.2 IO::Socket::Socks module I added support for socks protocol version 4. It will be good if you can add support for this protocol in LWP. I think you can add one more proxy suffix, like 'socks4://'. Version protocol in IO::Socket::Socks could be specified using `SocksVersion' option, which default value is 5.
Subject: Socks 4 support patch
I made a patch. Patching: cd LWP-Protocol-socks-1.3 && patch -p1 < LWP-Protocol-socks-1.3.patch Usage: $ua->proxy(['http', 'https'] => 'socks4://localhost:1080'); # socks4 $ua->proxy(['http', 'https'] => 'socks://localhost:1080'); # socks5 And one possible bugfix in this patch. For http schema it was double connection to the proxy server. Hack from the https part of the module solved the problem.
Subject: LWP-Protocol-socks-1.3.patch
diff -Naur LWP-Protocol-socks-1.3//lib/LWP/Protocol/socks4.pm LWP-Protocol-socks-1.3-patched//lib/LWP/Protocol/socks4.pm --- LWP-Protocol-socks-1.3//lib/LWP/Protocol/socks4.pm 1970-01-01 07:00:00.000000000 +0700 +++ LWP-Protocol-socks-1.3-patched//lib/LWP/Protocol/socks4.pm 2011-02-05 20:22:11.000000000 +0600 @@ -0,0 +1,24 @@ +package 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; diff -Naur LWP-Protocol-socks-1.3//lib/LWP/Protocol/socks.pm LWP-Protocol-socks-1.3-patched//lib/LWP/Protocol/socks.pm --- LWP-Protocol-socks-1.3//lib/LWP/Protocol/socks.pm 2010-07-24 02:19:28.000000000 +0700 +++ LWP-Protocol-socks-1.3-patched//lib/LWP/Protocol/socks.pm 2011-02-05 20:29:44.993206258 +0600 @@ -37,6 +37,11 @@ $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; diff -Naur LWP-Protocol-socks-1.3//lib/URI/socks4.pm LWP-Protocol-socks-1.3-patched//lib/URI/socks4.pm --- LWP-Protocol-socks-1.3//lib/URI/socks4.pm 1970-01-01 07:00:00.000000000 +0700 +++ LWP-Protocol-socks-1.3-patched//lib/URI/socks4.pm 2011-02-05 20:23:22.000000000 +0600 @@ -0,0 +1,6 @@ +package URI::socks4; +require URI::socks; + +our @ISA = qw(URI::socks); + +1;
Should be fixed in 1.4