Skip Menu |

This queue is for tickets about the Digest-MD5-Reverse CPAN distribution.

Report information
The Basics
Id: 79894
Status: new
Priority: 0/
Queue: Digest-MD5-Reverse

People
Owner: Nobody in particular
Requestors: rodrigo [...] familianascimento.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Do not work behind proxy servers
This module do not work behind proxies. To solve this, here is a patch for using LWP::UserAgent.
Subject: 0001-Use-LWP-UserAgent-for-proper-proxy-handling.patch
From e64480fdcca61f9c369a3bbf2917f389e1efcd79 Mon Sep 17 00:00:00 2001 From: Welton Rodrigo Torres Nascimento <rodrigo@familianascimento.org> Date: Thu, 27 Sep 2012 17:06:56 -0400 Subject: [PATCH] Use LWP::UserAgent for proper proxy handling. --- Build.PL | 3 +++ Changes | 3 +++ META.yml | 2 ++ lib/Digest/MD5/Reverse.pm | 32 ++++++++++++++++++++++---------- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Build.PL b/Build.PL index 3acd777..47b5313 100644 --- a/Build.PL +++ b/Build.PL @@ -11,6 +11,9 @@ my $builder = Module::Build->new( build_requires => { 'Test::More' => 0, }, + requires => { + 'LWP::UserAgent' => 0, + }, add_to_cleanup => [ 'Digest-MD5-Reverse-*' ], ); diff --git a/Changes b/Changes index d444d4a..e0c8b6c 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Digest-MD5-Reverse +1.4 27/9/2012 + - can use proxies + 1.3 31/8/2007 - no more poo interface - bigger database diff --git a/META.yml b/META.yml index a7925c8..cd6ac88 100644 --- a/META.yml +++ b/META.yml @@ -9,6 +9,8 @@ resources: license: http://dev.perl.org/licenses/ build_requires: Test::More: 0 +requires: + LWP::UserAgent: 0 provides: Digest::MD5::Reverse: file: lib/Digest/MD5/Reverse.pm diff --git a/lib/Digest/MD5/Reverse.pm b/lib/Digest/MD5/Reverse.pm index 3d5d430..27b00fc 100644 --- a/lib/Digest/MD5/Reverse.pm +++ b/lib/Digest/MD5/Reverse.pm @@ -2,8 +2,8 @@ package Digest::MD5::Reverse; use warnings; use strict; -use Socket; use Exporter; +use LWP; =head1 NAME @@ -14,6 +14,11 @@ Digest::MD5::Reverse - MD5 Reverse Lookup our $VERSION = "1.3"; our @ISA = qw(Exporter); our @EXPORT = qw(&reverse_md5); +our $UA = new LWP::UserAgent(timeout => 20); + +# Get proxy settings from environment variables. +$UA->env_proxy; + =head1 VERSION @@ -167,20 +172,27 @@ our $DATABASE = [ my $get = sub { my($url,$path) = @_; - socket(my $socket, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die "Socket Error : $!\n"; - connect($socket,sockaddr_in(80, inet_aton($url))) or die "Connect Error: $!\n"; - send($socket,"GET $path HTTP/1.1\015\012Host: $url\015\012User-Agent: Firefox\015\012Connection: Close\015\012\015\012",0); - return do { local $/; <$socket> }; + + my $res = $UA->get( "http://" . $url . $path ); + + if ($res->is_success){ + return $res->decoded_content; + }else{ + return; + } }; my $post = sub { my($url,$path,$content) = @_; - my $len = length $content; - socket(my $socket, PF_INET, SOCK_STREAM, getprotobyname("tcp")) or die "Socket Error : $!\n"; - connect($socket,sockaddr_in(80, inet_aton($url))) or die "Connect Error : $!\n"; - send($socket,"POST $path HTTP/1.1\015\012Host: $url\015\012User-Agent: Firefox\015\012Content-Type: application/x-www-form-urlencoded\015\012Connection: Close\015\012Content-Length: $len\015\012\015\012$content\015\012",0); - return do { local $/; <$socket> }; + + my $res = $UA->post( "http://" . $url . $path, Content => $content); + + if ($res->is_success){ + return $res->decoded_content; + }else{ + return; + } }; my $reverseit = sub -- 1.7.9.5