Rob Brown wrote:
I'm getting complaints about Apache::DNAT not working with Apache 2 because mod_perl 1.99 suddenly can't handle the things it used to.
I'm getting this spewage:
[Fri Mar 07 11:22:21 2003] [error] [client 166.70.29.72] Can't locate object method "connection" via package "Apache::RequestRec" at /usr/lib/perl5/site_perl/5.8.0/Apache/DNAT.pm line 8.
Here is the offending code:
my $c = $r->connection; ##### line 8
my $old_remote_addr = $c->remote_addr;
my ($old_port, $old_addr) = sockaddr_in($old_remote_addr);
$old_addr = inet_ntoa $old_addr;
# munge and compute $new_port and $new_addr .....
$c->remote_addr(scalar sockaddr_in($new_port, inet_aton($new_addr)));
$c->remote_ip($new_addr);
This all used to work just fine under mod_perl 1.27 but now fails miserably.
I tried using "Apache::compat" also. This seemed to pick up the $r->connection slightly better. But $c->remote_addr is really wacked. Now it crashes with this spewage:
[Fri Mar 07 12:20:32 2003] [error] [client 166.70.29.72] Bad arg length for Socket::unpack_sockaddr_in, length is 31, should be 16 at /usr/lib/perl5/5.8.0/i386-linux-thread-multi/Socket.pm line 370.
I did a Data::Dumper on it and it's a ref??!!
$old_remote_addr = bless( do{\(my $o = 135384736)}, 'APR::SockAddr' );
How am I supposed to pull the port and addr out of that nasty beast?
$c->ip_get or $c->addr ?
NOPE!
[Fri Mar 07 12:22:12 2003] [error] [client 166.70.29.72] Can't locate object method "ip_get" via package "APR::SockAddr" at /usr/lib/perl5/site_perl/5.8.0/Apache/DNAT.pm line 13.
[Fri Mar 07 12:24:58 2003] [error] [client 166.70.29.72] Can't locate object method "addr" via package "APR::SockAddr" at /usr/lib/perl5/site_perl/5.8.0/Apache/DNAT.pm line 13.
I've tried searching all the documentation for clues, but I must be looking in the wrong place. I've even tried dereferencing the SCALAR ref and sending that through sockaddr_in or inet_ntoa, but that totally doesn't work either. I'm running out of possibilities to try.
Also, once I GET the connection information, I need to be able to SET it again to spoof the request into thinking the request is coming from the more correct peer instead of what the actual socket reports. This should be reflected in the logs and in the environment REMOTE_ADDR and REMOTE_PORT for mod_cgi running CGI scripts.
$r->SET_remote_addr($new_remote_addr); # ??????
I just need to port my module from mp1 to mp2. Any ideas would be appreciated.
--
Rob
DETAILS:
Apache::DNAT is freely available from CPAN:
http://search.cpan.org/src/BBB/Net-DNAT-0.10/lib/Apache/DNAT.pm
$ uname -a
Linux box 2.4.18-14 #1 Wed Sep 4 12:13:11 EDT 2002 i686 athlon i386 GNU/Linux
I'm using the mod_perl rpm that comes stock with RedHat 8.0 linux:
mod_perl-1.99_05-3

1.99_05 is one 7 months old. Please test it again with the released 1.99_08 or even better with the current cvs:
http://perl.apache.org/download/source.html#2_0_Development_Source_Distribution


As for missing methods reports, see:
http://perl.apache.org/docs/2.0/api/ModPerl/MethodLookup.html
e.g. you need to load 'Apache::Connection' to get remote_addr


Also, in the future please add some new lines in your reports, it's extremely hard to parse when everything is piled in one para. Thanks.


I'm using the apache 2.0 rpm that comes stock with RedHat 8.0 linux:
httpd-2.0.40-11
I'm using the perl 5.8.0 rpm that comes stock with RedHat 8.0 linux:
perl-5.8.0-55


--


__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com



Reply via email to