Skip to content

Rebase #76 and add tests and change log#85

Merged
horgh merged 7 commits intomasterfrom
greg/notes
Jan 27, 2020
Merged

Rebase #76 and add tests and change log#85
horgh merged 7 commits intomasterfrom
greg/notes

Conversation

@oschwald
Copy link
Member

Closes #76.

mfontani and others added 4 commits January 23, 2020 08:38
The old "mod_geoip" used to set _both_ environment _and_ notes.
This commit makes the setting of the notes optional.

This enables an Apache mod_perl running with:

    <Location "/">
      SetHandler perl-script
      PerlOptions -ParseHeaders -SetupEnv -GlobalRequest
      PerlResponseHandler ...
    </Location>

... and with a MaxMind configuration of:

    LoadModule maxminddb_module  /usr/lib/apache2/modules/mod_maxminddb.so
    <IfModule mod_maxminddb.c>
      # See https://github.com/maxmind/mod_maxminddb
      MaxMindDBEnable On
      MaxMindDBSetNotes On
      MaxMindDBFile COUNTRY_DB /path/to/GeoLite2-Country.mmdb
      MaxMindDBEnv MM_GEOIP_COUNTRY_CODE COUNTRY_DB/country/iso_code
      MaxMindDBEnv MM_GEOIP_CONTINENT_CODE COUNTRY_DB/continent/code
    </IfModule>

... to get the client's country code & continent code as an Apache
"note", without having to involve the environment.

The reason one usually wants to disable SetupEnv (via "-SetupEnv") for
mod_perl handlers is one of performance; from the docs at:

    https://perl.apache.org/docs/2.0/user/config/config.html#C_SetupEnv_c

    > But %ENV population is expensive. Those who have moved to the Perl
    > Apache API no longer need this extra %ENV population, and can gain
    > by disabling it.
Copy link
Contributor

@horgh horgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious feature!

t/notes.t Outdated
use JSON::XS qw( decode_json );
use Test::ModMaxMindDB;

my $url = '/cgi-bin/valid-db/json-env';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hitting /notes? I don't see us actually hitting the new path, nor checking what the test package is doing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That explains why it surprisingly passed right away. 🤣

maxminddb_register_hooks /* register hooks */
};

static void maxminddb_kv_set(maxminddb_config *conf,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a call to apr_table_set() in set_network_environment_variable() - should we use this function there too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I missed that on rebase.

This doesn't matter, but everywhere else used the same ordering.
@oschwald oschwald force-pushed the greg/notes branch 8 times, most recently from 5ce2af8 to d0b655a Compare January 25, 2020 00:22
@horgh horgh merged commit 999bf63 into master Jan 27, 2020
@horgh horgh deleted the greg/notes branch January 27, 2020 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants