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 <pengmatth...@gmail.com> 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 <mit...@gmail.com> > wrote: > >> 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. >>>>> >>>>