Re: Confused about two development utils

Mithun Bhattacharya <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAHTPV9LW_ne-1DBC9H=+s44kVQbURJfCeMCN-g4RWXAXD3tBfg@mail.gmail.com>
8.8.8.8 is google's public DNS server - yah they can handle whatever you
throw at them but you shouldnt misuse it. The whole point of TTL in DNS is
for suggested caching - you are welcome to ignore it but you are also being
rude to others.

$r->connection->client_ip is the IP your apache server is seeing you come
through which I assume is CloudFlare - I have no idea how to see the real
ip behind cloudflare.

On Tue, Dec 22, 2020 at 7:19 PM Matthias Peng <[email protected]>
wrote:

> Thanks Mithun.
> 1. Since the query is passed through cloudflare, so a CF- header is wanted
> for fetching client's real IP.
> 2. Since I am querying PTR via a stub resolver (such as 8.8.8.8), I guess
> this public dns server has already cached the result. right?
>
> Regards.
>
>
> On Wed, Dec 23, 2020 at 9:08 AM Mithun Bhattacharya <[email protected]>
> wrote:
>
>> Replying to the DL.
>>
>> On Tue, Dec 22, 2020 at 7:07 PM Mithun Bhattacharya <[email protected]>
>> 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 <[email protected]>
>>> 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 <[email protected]>
>>>> 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.
>>>>>
>>>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.