Replying to the DL.

On Tue, Dec 22, 2020 at 7:07 PM Mithun Bhattacharya <mit...@gmail.com>
wrote:

> $r->connection->client_ip would report your proxy server if you have a
> reverse proxy setup - this is not a common use case though.
>
> DNS lookup would usually be an expensive process and you are supposed to
> be nice to other services so cache it for the TTL of the PTR record.
>
> On Tue, Dec 22, 2020 at 6:44 PM Matthias Peng <pengmatth...@gmail.com>
> wrote:
>
>> I am a newbie to mp development stack.
>> After one day of work, I have made a simple handler, which returns the
>> client's address and its PTR record.
>> The demo:
>> https://myhostnames.com/
>>
>> The code shown below:
>>
>> package MyHostname;
>>
>>
>> use strict;
>>
>> use Net::DNS;
>>
>> use Apache2::RequestRec ();
>>
>> use Apache2::RequestIO ();
>>
>> use Apache2::Connection ();
>>
>> use APR::Table ();
>>
>> use Apache2::Const -compile => qw(OK FORBIDDEN);
>>
>>
>>
>> sub handler {
>>
>>
>>     my $r = shift;
>>
>>     my $ip = $r->headers_in->{'CF-Connecting-IP'} ||
>> $r->connection->client_ip;
>>
>>
>>     my $host = dns_query($ip) || "";
>>
>>
>>     $r->content_type('text/plain; charset=utf-8');
>>
>>     $r->print("Your IP: $ip, Hostname: $host");
>>
>>
>>     return Apache2::Const::OK;
>>
>> }
>>
>>
>>
>> sub dns_query {
>>
>>     my $ip = shift;
>>
>>     my $resolver = Net::DNS::Resolver->new();
>>
>>     my $reply = $resolver->query($ip, 'PTR');
>>
>>
>>     if ($reply) {
>>
>>         for my $rr ($reply->answer) {
>>
>>             return $rr->rdstring;  # we need only one
>>
>>         }
>>
>>     }
>>
>>
>>     return;
>>
>> }
>>
>>
>>
>> 1;
>>
>>
>>
>> Can anyone give your review? Thanks in advance.
>>
>>
>> Matthias
>>
>>
>>
>>
>> On Tue, Dec 22, 2020 at 1:49 PM Matthias Peng <pengmatth...@gmail.com>
>> wrote:
>>
>>> Hello
>>>
>>> I am developing a simple mp2 application.
>>> I looked for the installation for mp2 utils, and found this two:
>>>
>>> libapache2-mod-perl2
>>>
>>> libapache2-mod-apreq2
>>>
>>>
>>> what're their relations? Should I install both, or only the first one?
>>>
>>>
>>> Thanks.
>>>
>>

Reply via email to