MESSAGE
DATE | 2020-12-22 |
FROM | Matthias Peng
|
SUBJECT | Re: [Hangout - NYLXS] Confused about two development utils
|
From hangout-bounces-at-nylxs.com Wed Dec 23 09:21:57 2020 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www2.mrbrklyn.com (www2.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 06B00163FF2; Wed, 23 Dec 2020 09:21:57 -0500 (EST) X-Original-To: hangout-at-www2.mrbrklyn.com Delivered-To: hangout-at-www2.mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 1000) id 35C57163FE5; Wed, 23 Dec 2020 09:21:12 -0500 (EST) Resent-From: Ruben Safir Resent-Date: Wed, 23 Dec 2020 09:21:12 -0500 Resent-Message-ID: <20201223142112.GH26325-at-www2.mrbrklyn.com> Resent-To: hangout-at-mrbrklyn.com X-Original-To: ruben-at-mrbrklyn.com Delivered-To: ruben-at-mrbrklyn.com Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mrbrklyn.com (Postfix) with ESMTP id EDB32164002 for ; Tue, 22 Dec 2020 20:19:27 -0500 (EST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id B9D74471A2 for ; Wed, 23 Dec 2020 01:19:26 +0000 (UTC) Received: (qmail 87231 invoked by uid 500); 23 Dec 2020 01:19:26 -0000 Mailing-List: contact modperl-help-at-perl.apache.org; run by ezmlm Precedence: bulk Delivered-To: mailing list modperl-at-perl.apache.org Received: (qmail 87220 invoked by uid 99); 23 Dec 2020 01:19:25 -0000 Received: from spamproc1-he-de.apache.org (HELO spamproc1-he-de.apache.org) (116.203.196.100) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Dec 2020 01:19:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamproc1-he-de.apache.org (ASF Mail Server at spamproc1-he-de.apache.org) with ESMTP id 968B61FF3A1 for ; Wed, 23 Dec 2020 01:19:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamproc1-he-de.apache.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.2, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamproc1-he-de.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-he-de.apache.org ([116.203.227.195]) by localhost (spamproc1-he-de.apache.org [116.203.196.100]) (amavisd-new, port 10024) with ESMTP id l1lXd357Arn7 for ; Wed, 23 Dec 2020 01:19:23 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::341; helo=mail-ot1-x341.google.com; envelope-from=pengmatthias-at-gmail.com; receiver= Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 903897F9E1 for ; Wed, 23 Dec 2020 01:19:23 +0000 (UTC) Received: by mail-ot1-x341.google.com with SMTP id q25so13684597otn.10 for ; Tue, 22 Dec 2020 17:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LZstyltnkvNLcadEFU83WE/z9NyghljWDau6HmisD7E=; b=T6K1eg+6hzYliSdWyX6P2gw9a+wuxcFXORiQ5Ip5E0Nkz5oxdOcpZpTAdIxnDPhq9h joQHdEjQ4Kp300yDFpNV0sQr3GGgm2nWCF1xrErv3OMK5LfnWtbx4pFzhBRYe6/gMuNf M3t2m30GVU9kzVv6DDalu+a0+ePYwTyxw2qec1ghzIIVxJNQxbBKpwgqXChbRgvUJ5s3 FMRfKZ3ILvkAQ4afuP03G2lETEGzM6RhS8SmDFSJOGIH7doTh9vkOt1onxyKqgOXy2IM jTzlSwSAIj15hkqPVN7QeTVKRZMdzGyQZH8faHm6TleXHTyTBqgcvnX89E6HPUMIlQ60 ihZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LZstyltnkvNLcadEFU83WE/z9NyghljWDau6HmisD7E=; b=IhF15aOt2f6uQ5h2FeoABVu6sLAXUNOJbz18m8pzutJkw9aM7QDCxorePX4hDL1tkA gLleHBei7efFy1/cpTf/8dqUWxjL6CWHuNb1SfyR7CEY5XXTzjrXTjskZ5Y75vmAdbqA 7SzHI/D3m1GJqYh3/OrSSr2cM442Qeg7MEL9UKuN41Hm2CXjCpOqD9hShwXx7rLjfJVb MjvbVX49dkw37+fpeGPEj7Gah8JYOJbFE0RsdHf5Lys31nmeGcDOidQQ370vR8fFWIH8 P+8B7pP1UfQeyTyak/nxVJWRNR/RgDc9FnlR7raQjz1bSomoQmxx/9MtxmcEiVOIjPjp QGYw== X-Gm-Message-State: AOAM531jepg/x3YSAaOan1TN9UPyI+GeHB3+dHCBGZTVns+1u2PfQDRz DTFZDfjhjEs6mrEplPt0KdPtW4gEXsoxiOV6qF8= X-Google-Smtp-Source: ABdhPJwm9fCcdoiM0B3wXX9D+ZCWQyc53B2X75pXSCxl/j1pciUZLyLZgCQgAQMHvqLkk/0J1jn5Ow76dimd11F5cNg= X-Received: by 2002:a05:6830:1205:: with SMTP id r5mr17422918otp.51.1608686362254; Tue, 22 Dec 2020 17:19:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Matthias Peng Date: Wed, 23 Dec 2020 09:19:11 +0800 Message-ID: To: Mithun Bhattacharya Cc: mod_perl list Subject: Re: [Hangout - NYLXS] Confused about two development utils X-BeenThere: hangout-at-nylxs.com X-Mailman-Version: 2.1.30rc1 List-Id: NYLXS Tech Talk and Politics List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1348624379==" Errors-To: hangout-bounces-at-nylxs.com Sender: "Hangout"
--===============1348624379== Content-Type: multipart/alternative; boundary="0000000000002d618705b7177b4f"
--0000000000002d618705b7177b4f Content-Type: text/plain; charset="UTF-8"
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 wrote:
> Replying to the DL. > > On Tue, Dec 22, 2020 at 7:07 PM Mithun Bhattacharya > 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 >> 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 >>> 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. >>>> >>>
--0000000000002d618705b7177b4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks=C2=A0Mithun. 1. Since the query is passed throu= gh 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.
mail_quote"> "margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-le= ft:1ex">Replying to the DL.
uote"> te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204= );padding-left:1ex">$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=C2=A0to=C2=A0other ser= vices so cache it for the TTL of the PTR record.
=3D"gmail_quote"> lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli= d rgb(204,204,204);padding-left:1ex">I am a newbie to mp d= evelopment stack. After=C2=A0one day of work, I have made a simple hand= ler, which returns the client's address and its PTR record. T= he demo:
The code shown bel= ow: or:rgb(0,0,0);font-family:Menlo;font-size:11px">
style=3D"font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-= family:Menlo;font-size:11px">package MyHostname; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use strict; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Net::DNS; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::RequestRec (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::RequestIO (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::Connection (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use APR::Table (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::Const -compile =3D> qw(OK FORBIDDEN); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">sub handler { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $r =3D shift; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $ip =3D $r->headers_in->{'CF-= Connecting-IP'} ||=C2=A0 $r->connection->client_ip;<= /span> normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $host =3D dns_query($ip) || ""= ;; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 $r->content_type('text/plain; chars= et=3Dutf-8'); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 $r->print("Your IP: $ip, Hostname:= $host"); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 return Apache2::Const::OK; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">} normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">sub dns_query { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $ip =3D shift; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $resolver =3D Net::DNS::Resolver->ne= w(); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $reply =3D $resolver->query($ip, = 9;PTR'); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 if ($reply) { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 for my $rr ($reply->answe= r) { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return $rr->= ;rdstring;=C2=A0 # we need only one normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 } normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 } normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 return; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">} normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">1; variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:no= rmal;font-family:Menlo;color:rgb(0,0,0)">res:no-common-ligatures">
-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-siz= e:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">=3D"font-variant-ligatures:no-common-ligatures">
margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-= stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rg= b(0,0,0)">Can an= yone give your review? Thanks in advance. font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:nor= mal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><= span style=3D"font-variant-ligatures:no-common-ligatures">
style=3D"margin:0px;font-variant-numeric:normal;font-variant-east-asian:no= rmal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menl= o;color:rgb(0,0,0)">es">Matthias ont-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-heigh= t:normal;font-family:Menlo;color:rgb(0,0,0)">gatures:no-common-ligatures">
lass=3D"gmail_quote"> te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px = solid rgb(204,204,204);padding-left:1ex">Hello iv> I am developing a simple mp2 application. I looked for th= e installation for mp2 utils, and found this two:
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">libapache2-mod-perl2 meric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:1= 1px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">ont-variant-ligatures:no-common-ligatures">
east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;fon= t-family:Menlo;color:rgb(0,0,0)">ommon-ligatures">libapache2-mod-apreq2 t-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal= ;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">n style=3D"font-variant-ligatures:no-common-ligatures">
yle=3D"margin:0px;font-variant-numeric:normal;font-variant-east-asian:norma= l;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;c= olor:rgb(0,0,0)">>what're their=C2=A0relations? Should=C2=A0I install both, or only the = first one? t-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:= normal;font-family:Menlo;color:rgb(0,0,0)">tures:no-common-ligatures">
nt-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-s= ize:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">=3D"font-variant-ligatures:no-common-ligatures">Thanks. iv>
--0000000000002d618705b7177b4f--
--===============1348624379== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout
--===============1348624379==--
--===============1348624379== Content-Type: multipart/alternative; boundary="0000000000002d618705b7177b4f"
--0000000000002d618705b7177b4f Content-Type: text/plain; charset="UTF-8"
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 wrote:
> Replying to the DL. > > On Tue, Dec 22, 2020 at 7:07 PM Mithun Bhattacharya > 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 >> 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 >>> 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. >>>> >>>
--0000000000002d618705b7177b4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks=C2=A0Mithun. 1. Since the query is passed throu= gh 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.
mail_quote"> "margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-le= ft:1ex">Replying to the DL.
uote"> te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204= );padding-left:1ex">$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=C2=A0to=C2=A0other ser= vices so cache it for the TTL of the PTR record.
=3D"gmail_quote"> lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli= d rgb(204,204,204);padding-left:1ex">I am a newbie to mp d= evelopment stack. After=C2=A0one day of work, I have made a simple hand= ler, which returns the client's address and its PTR record. T= he demo:
The code shown bel= ow: or:rgb(0,0,0);font-family:Menlo;font-size:11px">
style=3D"font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-= family:Menlo;font-size:11px">package MyHostname; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use strict; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Net::DNS; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::RequestRec (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::RequestIO (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::Connection (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use APR::Table (); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">use Apache2::Const -compile =3D> qw(OK FORBIDDEN); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">sub handler { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $r =3D shift; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $ip =3D $r->headers_in->{'CF-= Connecting-IP'} ||=C2=A0 $r->connection->client_ip;<= /span> normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $host =3D dns_query($ip) || ""= ;; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 $r->content_type('text/plain; chars= et=3Dutf-8'); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 $r->print("Your IP: $ip, Hostname:= $host"); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 return Apache2::Const::OK; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">} normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">sub dns_query { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $ip =3D shift; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $resolver =3D Net::DNS::Resolver->ne= w(); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 my $reply =3D $resolver->query($ip, = 9;PTR'); normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 if ($reply) { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 for my $rr ($reply->answe= r) { normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return $rr->= ;rdstring;=C2=A0 # we need only one normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 =C2=A0 =C2=A0 } normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 } normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">=C2=A0 =C2=A0 return; normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">} normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0);min-height:13px">:no-common-ligatures">
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">1; variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:no= rmal;font-family:Menlo;color:rgb(0,0,0)">res:no-common-ligatures">
-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-siz= e:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">=3D"font-variant-ligatures:no-common-ligatures">
margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-= stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rg= b(0,0,0)">Can an= yone give your review? Thanks in advance. font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:nor= mal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><= span style=3D"font-variant-ligatures:no-common-ligatures">
style=3D"margin:0px;font-variant-numeric:normal;font-variant-east-asian:no= rmal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menl= o;color:rgb(0,0,0)">es">Matthias ont-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-heigh= t:normal;font-family:Menlo;color:rgb(0,0,0)">gatures:no-common-ligatures">
lass=3D"gmail_quote"> te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px = solid rgb(204,204,204);padding-left:1ex">Hello iv> I am developing a simple mp2 application. I looked for th= e installation for mp2 utils, and found this two:
normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me= nlo;color:rgb(0,0,0)">ures">libapache2-mod-perl2 meric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:1= 1px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">ont-variant-ligatures:no-common-ligatures">
east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;fon= t-family:Menlo;color:rgb(0,0,0)">ommon-ligatures">libapache2-mod-apreq2 t-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal= ;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">n style=3D"font-variant-ligatures:no-common-ligatures">
yle=3D"margin:0px;font-variant-numeric:normal;font-variant-east-asian:norma= l;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;c= olor:rgb(0,0,0)">>what're their=C2=A0relations? Should=C2=A0I install both, or only the = first one? t-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:= normal;font-family:Menlo;color:rgb(0,0,0)">tures:no-common-ligatures">
nt-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-s= ize:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">=3D"font-variant-ligatures:no-common-ligatures">Thanks. iv>
--0000000000002d618705b7177b4f--
--===============1348624379== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout
--===============1348624379==--
|
|