<div dir="ltr"><div>Putting a simple test script together, I found my problem. The client_ip method doesn't work on Apache2::Connection objects unless the Apache2::Connection module is loaded in the current namespace.</div><div><br></div><div>package test;<br>use strict;<br>use warnings;<br>use Apache2::RequestRec ();<br>use Apache2::Const -compile => 'OK';<br><br>sub handler {<br> my $r = shift;<br> $r->content_type('text/plain');<br> my $ref = ref($r);<br> print "ref(\$r) = $ref\n";<br> my $conn = $r->connection;<br> $ref = ref($conn);<br> print "ref(\$conn) = $ref\n";<br> for(1..2) {<br> if($_==2) {<br> print "require Apache2::Connection\n";<br> require Apache2::Connection;<br> }<br> if($conn->can('client_ip')) {<br> print "client_ip: ".$conn->client_ip."\n";<br> }<br> else {<br> print "\$conn cannot client_ip\n";<br> }<br> if($conn->can('remote_ip')) {<br> print "remote_ip: ".$conn->remote_ip."\n";</div><div> }<br> else {<br> print "\$conn cannot remote_ip\n";</div><div> }<br> }<br> return Apache2::Const::OK;<br>}<br>1;<br></div><div><br></div><div><pre style="color:rgb(0,0,0);white-space:pre-wrap">ref($r) = Apache2::RequestRec
ref($conn) = Apache2::Connection
$conn cannot client_ip
$conn cannot remote_ip
require Apache2::Connection
client_ip: 127.0.0.1
$conn cannot remote_ip</pre></div><div><br></div>On Thu, 28 Nov 2019 22:44:26 +0200 Damyan Ivanov <<a href="mailto:dmn@debian.org">dmn@debian.org</a>> wrote:<br>> -=| Chris Denley, 28.11.2019 08:02:52 -0600 |=-<br>> > client_ip and remote_ip do not work. Is there no way to get this value anymore?<br>> > <br>> > Can't locate object method "remote_ip" via package "Apache2::Connection"<br>> > Can't locate object method "client_ip" via package "Apache2::Connection"<br>> > Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_apreq2-20090110/2.8.0 mod_perl/2.0.10<br>> > Perl/v5.26.1<br>> <br>> the following works for me:<br>> <br>> my $conn = $r->connection;<br>> <br>> my $ip_addr<br>> = $conn->can('client_ip')<br>> ? $conn->client_ip<br>> : $conn->remote_ip;<br>> <br>> so one of them works, and I bet it is 'client_ip'<br>> <br>> (Debian/sid and Debian/buster (and several releases before that))<br>> <br>> Can you share the code that fails for you?<br>> <br>> -- Damyan<br>> <br>> <br></div>