[Mimedefang] what are the different headers possible?

fakessh fakessh at fakessh.eu
Mon Apr 25 09:29:29 EDT 2011


Le jeudi 21 avril 2011 21:46, fakessh a écrit :
> Le jeudi 21 avril 2011 09:10, Steffen Kaiser a écrit :
> > On Thu, 21 Apr 2011, fakessh wrote:
> >
> > Hi fakessh,
> >
> > please keep in mind that MIMEDefang bases on a complete programming
> > language with plenty of modules. You need to learn this language in order
> > to get the configuration work in a production environment properly.
> >
> > > changes made ​​without any result: here is my code
> > >
> > >                my $gi = Geo::IP->open("/usr/share/GeoIP/GeoIP.dat",
> > > GEOIP_STANDARD);
> > >                my ($country, $region) =
> > > $gi->region_by_name($RelayAddr); action_add_header("X-Header-Country",
> > > "$country"); action_add_header("X-Header-Region", "$region");
> >
> > I don't use Geo::IP either (as Joseph Brennan), but I refer to the doc on
> > http://search.cpan.org/~borisz/Geo-IP-1.38/lib/Geo/IP.pm
> >
> > citate:
> >
> > "
> > ( $country, $region ) = $gi->region_by_addr('24.24.24.24');
> > Returns a list containing country and region. If region and/or country is
> > unknown, undef is returned. Sure this works only for region databases.
> > ( $country, $region ) = $gi->region_by_name('www.xyz.com');
> > Returns a list containing country and region. If region and/or country is
> > unknown, undef is returned. Sure this works only for region databases.
> > "
> >
> > Things to consider to get the code going:
> >
> > 1) MIMEDefang only knows the numerical IP the connection comes from, the
> > symbolical name stems from reverse DNS lookups, hence, I would never use
> > region_by_name() personally, but stick to region_by_addr(). Otherwise you
> > need to know how region_by_name() behaves, if you pass it "[a.b.c.d]"
> > symbolical names for IPs, that does not resolve.
> >
> > 2) region and country may be undef, hence, you ought to handle the case
> > the function does not return defined values.
> >
> > 3) open() may fail, too, you ought to handle that case as well.
> >
> > Regards,
>
> only seems to work
> $country = $gi->country_code_by_name('yahoo.com');
>
> any idea ?


I managed to get a result as I wanted with this code


use Geo::IP::PurePerl;
               
                            $gi =   
Geo::IP::PurePerl->new( "/usr/share/GeoIP/GeoLiteCity.dat", GEOIP_STANDARD );
                            $country = $gi->country_code_by_name($Helo);
                 my (
                            $country_code, $country_code3, $country_name, 
$region,
                            $city,         $postal_code,   $latitude,     
$longitude,
                            $metro_code,   $area_code
                       ) = $gi->get_city_record($Helo);
             action_add_header("X-Header-Country", "$country_code");
             action_add_header("X-Header-CountryCode3", "$country_code3");
             action_add_header("X-Header-CountryName", "$country_name");
             action_add_header("X-Header-Region",   "$region");
             action_add_header("X-Header-City" , "$city");
             action_add_header("X-Header-PostalCode" , "$postal_code");
             action_add_header("X-Header-Latitude", "$latitude");
             action_add_header("X-Header-Longitude",   "$longitude");
            action_add_header("X-Header-MetroCode", "$metro_code");
            action_add_header("X-Header-AreaCode",   "$area_code");

-- 
 http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x092164A7
 gpg --keyserver pgp.mit.edu --recv-key 092164A7
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.mimedefang.org/pipermail/mimedefang_lists.mimedefang.org/attachments/20110425/c9c1ba30/attachment.sig>


More information about the MIMEDefang mailing list