2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

convert geoip to geoip2 in win32utils/Configure

This commit is contained in:
Thomas Jach 2019-07-02 16:27:42 -07:00 committed by Evan Hunt
parent 3781448c89
commit 9ba3e3f1b5
9 changed files with 54 additions and 131 deletions

View File

@ -64,8 +64,10 @@ options {\n\
#ifndef WIN32 #ifndef WIN32
" files unlimited;\n" " files unlimited;\n"
#endif #endif
#ifdef HAVE_GEOIP2 #if defined(HAVE_GEOIP2) && !defined(WIN32)
" geoip-directory \"" MAXMINDDB_PREFIX "/share/GeoIP2\";\n" " geoip-directory \"" MAXMINDDB_PREFIX "/share/GeoIP2\";\n"
#elif defined(HAVE_GEOIP2)
" geoip-directory \".\";\n"
#endif #endif
"\ "\
# has-old-clients <obsolete>;\n\ # has-old-clients <obsolete>;\n\

View File

@ -40,7 +40,7 @@ open_geoip2(const char *dir, const char *dbfile, MMDB_s *mmdb) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR, NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"GeoIP2 database '%s/%s': path too long", "GeoIP2 database '%s/%s': path too long",
(dir != NULL) ? dir : ".", dbfile); dir, dbfile);
return (NULL); return (NULL);
} }
@ -78,6 +78,10 @@ named_geoip_load(char *dir) {
#if defined(HAVE_GEOIP2) #if defined(HAVE_GEOIP2)
REQUIRE(dir != NULL); REQUIRE(dir != NULL);
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"looking for GeoIP2 databases in '%s'", dir);
named_g_geoip->country = open_geoip2(dir, "GeoIP2-Country.mmdb", named_g_geoip->country = open_geoip2(dir, "GeoIP2-Country.mmdb",
&geoip_country); &geoip_country);
if (named_g_geoip->country == NULL) { if (named_g_geoip->country == NULL) {

View File

@ -8270,12 +8270,11 @@ load_configuration(const char *filename, named_server_t *server,
*/ */
obj = NULL; obj = NULL;
result = named_config_get(maps, "geoip-directory", &obj); result = named_config_get(maps, "geoip-directory", &obj);
if (result == ISC_R_SUCCESS && cfg_obj_isstring(obj)) { INSIST(result == ISC_R_SUCCESS);
if (cfg_obj_isstring(obj)) {
char *dir; char *dir;
DE_CONST(cfg_obj_asstring(obj), dir); DE_CONST(cfg_obj_asstring(obj), dir);
named_geoip_load(dir); named_geoip_load(dir);
} else {
named_geoip_load(NULL);
} }
named_g_aclconfctx->geoip = named_g_geoip; named_g_aclconfctx->geoip = named_g_geoip;
#endif /* HAVE_GEOIP2 */ #endif /* HAVE_GEOIP2 */

View File

@ -310,9 +310,6 @@ typedef __int64 off_t;
/* Define to 1 if you have the `readline' function. */ /* Define to 1 if you have the `readline' function. */
@HAVE_READLINE@ @HAVE_READLINE@
/* Build with GeoIP support */
@HAVE_GEOIP@
/* Build with GeoIP2 support */ /* Build with GeoIP2 support */
@HAVE_GEOIP2@ @HAVE_GEOIP2@

View File

@ -4562,8 +4562,9 @@ badresp:1,adberr:0,findfail:0,valfail:0]
module: for example, if the library is installed in module: for example, if the library is installed in
<filename>/usr/local/lib</filename>, then the default <filename>/usr/local/lib</filename>, then the default
<command>geoip-directory</command> will be <command>geoip-directory</command> will be
<filename>/usr/local/share/GeoIP</filename>. <filename>/usr/local/share/GeoIP</filename>. On Windows,
See <xref linkend="acl"/> for details about the default is the <command>named</command> working
directory. See <xref linkend="acl"/> for details about
<command>geoip</command> ACLs. <command>geoip</command> ACLs.
</para> </para>
</listitem> </listitem>

View File

@ -103,7 +103,7 @@
<Filter>Library Source Files</Filter> <Filter>Library Source Files</Filter>
</ClCompile> </ClCompile>
@IF GEOIP @IF GEOIP
<ClCompile Include="..\geoip.c"> <ClCompile Include="..\geoip2.c">
<Filter>Library Source Files</Filter> <Filter>Library Source Files</Filter>
</ClCompile> </ClCompile>
@END GEOIP @END GEOIP

View File

@ -139,7 +139,7 @@
<ClCompile Include="..\fixedname.c" /> <ClCompile Include="..\fixedname.c" />
<ClCompile Include="..\forward.c" /> <ClCompile Include="..\forward.c" />
@IF GEOIP @IF GEOIP
<ClCompile Include="..\geoip.c" /> <ClCompile Include="..\geoip2.c" />
@END GEOIP @END GEOIP
<ClCompile Include="..\gssapictx.c" /> <ClCompile Include="..\gssapictx.c" />
<ClCompile Include="..\gssapi_link.c" /> <ClCompile Include="..\gssapi_link.c" />

View File

@ -109,12 +109,6 @@ copy @K5SPRT_DLL@ ..\Build\Debug\
copy @WSHELP_DLL@ ..\Build\Debug\ copy @WSHELP_DLL@ ..\Build\Debug\
@END GSSAPI @END GSSAPI
@IF GEOIP
echo Copying the GeoIP DLL.
copy @GEOIP_DLL@ ..\Build\Debug\
@END GEOIP
@IF IDNKIT @IF IDNKIT
echo Copying the IDN kit DLL. echo Copying the IDN kit DLL.
@ -258,12 +252,6 @@ copy @K5SPRT_DLL@ ..\Build\Release\
copy @WSHELP_DLL@ ..\Build\Release\ copy @WSHELP_DLL@ ..\Build\Release\
@END GSSAPI @END GSSAPI
@IF GEOIP
echo Copying the GeoIP DLL.
copy @GEOIP_DLL@ ..\Build\Release\
@END GEOIP
@IF IDNKIT @IF IDNKIT
echo Copying the IDN kit DLL. echo Copying the IDN kit DLL.

View File

@ -195,9 +195,7 @@ my %configdefh;
my @substdefh = ("AES_CC", my @substdefh = ("AES_CC",
"CONFIGARGS", "CONFIGARGS",
"DNS_RDATASET_FIXED", "DNS_RDATASET_FIXED",
"HAVE_GEOIP", "HAVE_GEOIP2",
"HAVE_GEOIP_CITY_V6",
"HAVE_GEOIP_V6",
"HAVE_LIBXML2", "HAVE_LIBXML2",
"HAVE_OPENSSL_ED25519", "HAVE_OPENSSL_ED25519",
"HAVE_OPENSSL_ED448", "HAVE_OPENSSL_ED448",
@ -283,7 +281,6 @@ my %configdll;
my @substdll = ("COMERR_DLL", my @substdll = ("COMERR_DLL",
"GSSAPI_DLL", "GSSAPI_DLL",
"GEOIP_DLL",
"ICONV_DLL", "ICONV_DLL",
"IDN_DLL", "IDN_DLL",
"KRB5_DLL", "KRB5_DLL",
@ -369,7 +366,7 @@ my @withlist = ("aes",
"eddsa", "eddsa",
"extra-tests", "extra-tests",
"gssapi", "gssapi",
"geoip", "geoip2",
"iconv", "iconv",
"idn", "idn",
"openssl", "openssl",
@ -426,7 +423,7 @@ my @help = (
" with-cc-alg choose the algorithm for cookies aes|sha1|sha256\n", " with-cc-alg choose the algorithm for cookies aes|sha1|sha256\n",
" with-gssapi[=PATH] build with MIT KfW GSSAPI yes|no|path\n", " with-gssapi[=PATH] build with MIT KfW GSSAPI yes|no|path\n",
" with-libxml2[=PATH] build with libxml2 library yes|no|path\n", " with-libxml2[=PATH] build with libxml2 library yes|no|path\n",
" with-geoip[=PATH] build with GeoIP support yes|no|path\n", " with-geoip2[=PATH] build with GeoIP2 support yes|no|path\n",
" with-pssuspend[=COMMAND] specify pssuspend command\n", " with-pssuspend[=COMMAND] specify pssuspend command\n",
" with-python[=COMMAND] specify python interpreter python|command\n", " with-python[=COMMAND] specify python interpreter python|command\n",
" with-readline[=PATH] build with readline library support yes|no|path\n", " with-readline[=PATH] build with readline library support yes|no|path\n",
@ -472,8 +469,8 @@ my $cookie_algorithm = "aes";
my $use_gssapi = "no"; my $use_gssapi = "no";
my $validation_default = "auto"; my $validation_default = "auto";
my $gssapi_path = "C:\\Program\ Files\\MIT\\Kerberos\\"; my $gssapi_path = "C:\\Program\ Files\\MIT\\Kerberos\\";
my $use_geoip = "no"; my $use_geoip2 = "no";
my $geoip_path = ""; my $geoip2_path = "";
my $use_libxml2 = "auto"; my $use_libxml2 = "auto";
my $libxml2_path = "..\\..\\"; my $libxml2_path = "..\\..\\";
my $with_pssuspend = "no"; my $with_pssuspend = "no";
@ -776,11 +773,13 @@ sub mywith {
$use_libxml2 = "yes"; $use_libxml2 = "yes";
$libxml2_path = $val; $libxml2_path = $val;
} }
} elsif ($key =~ /^geoip$/i) { } elsif ($key =~ /^geoip2$/i) {
if ($val !~ /^no$/i) { if ($val !~ /^no$/i) {
$use_geoip = "yes"; $use_geoip2 = "yes";
if ($val !~ /^yes$/i) { if ($val !~ /^yes$/i) {
$geoip_path = $val; $geoip2_path = $val;
} else {
$geoip2_path = "..\\..\\GeoIP2";
} }
} }
} elsif ($key =~ /^readline$/i) { } elsif ($key =~ /^readline$/i) {
@ -978,10 +977,10 @@ if ($verbose) {
} else { } else {
print "libxml2-path: $libxml2_path\n"; print "libxml2-path: $libxml2_path\n";
} }
if ($use_geoip eq "no") { if ($use_geoip2 eq "no") {
print "geoip: disabled\n"; print "geoip2: disabled\n";
} else { } else {
print "geoip-path: $geoip_path\n"; print "geoip2-path: $geoip2_path\n";
} }
if ($use_readline eq "no") { if ($use_readline eq "no") {
print "readline: disabled\n"; print "readline: disabled\n";
@ -1479,6 +1478,7 @@ EOF
$configdefh{"HAVE_DH_GET0_KEY"} = 1; $configdefh{"HAVE_DH_GET0_KEY"} = 1;
$configdefh{"HAVE_ECDSA_SIG_GET0"} = 1; $configdefh{"HAVE_ECDSA_SIG_GET0"} = 1;
$configdefh{"HAVE_RSA_SET0_KEY"} = 1; $configdefh{"HAVE_RSA_SET0_KEY"} = 1;
$configdefh{"HAVE_CRYPTO_ZALLOC"} = 1;
$configdefh{"HAVE_EVP_CIPHER_CTX_FREE"} = 1; $configdefh{"HAVE_EVP_CIPHER_CTX_FREE"} = 1;
$configdefh{"HAVE_EVP_CIPHER_CTX_NEW"} = 1; $configdefh{"HAVE_EVP_CIPHER_CTX_NEW"} = 1;
$configdefh{"HAVE_EVP_MD_CTX_FREE"} = 1; $configdefh{"HAVE_EVP_MD_CTX_FREE"} = 1;
@ -1730,118 +1730,53 @@ if ($use_gssapi ne "yes") {
# disable-auto-validation # disable-auto-validation
$configdefh{"VALIDATION_DEFAULT"} = "\"$validation_default\""; $configdefh{"VALIDATION_DEFAULT"} = "\"$validation_default\"";
# with-geoip # with-geoip2
if ($use_geoip eq "no") { if ($use_geoip2 eq "no") {
if ($verbose) { if ($verbose) {
print "geoip library is disabled\n"; print "geoip2 library is disabled\n";
} }
} else { } else {
$configcond{"GEOIP"} = 1; $configcond{"GEOIP"} = 1;
$geoip_path = File::Spec->rel2abs($geoip_path); $geoip2_path = File::Spec->rel2abs($geoip2_path);
if ($verbose) { if ($verbose) {
print "checking for geoip directory at \"$geoip_path\"\n"; print "checking for geoip2 directory at \"$geoip2_path\"\n";
} }
if (!-f File::Spec->catfile($geoip_path, "GeoIP.h")) { if (!-f File::Spec->catfile($geoip2_path, "maxminddb.h")) {
die "can't find GeoIP.h include\n"; die "can't find maxminddb.h include\n";
} }
if (!-f File::Spec->catfile($geoip_path, "GeoIP.lib")) { if (!-f File::Spec->catfile($geoip2_path, "maxminddb_config.h")) {
die "can't find Geoip.lib library\n"; die "can't find maxminddb_config.h include\n";
} }
if (!-f File::Spec->catfile($geoip_path, "GeoIP.dll")) { if (!-f File::Spec->catfile($geoip2_path, "libmaxminddb.lib")) {
die "can't find Geoip.dll DLL\n"; die "can't find libmaxminddb.lib library\n";
} }
$configinc{"GEOIP_INC"} = "$geoip_path"; $configinc{"GEOIP_INC"} = "$geoip2_path";
my $geoip_lib = File::Spec->catfile($geoip_path, "GeoIP.lib"); my $geoip2_lib = File::Spec->catfile($geoip2_path, "libmaxminddb.lib");
$configlib{"GEOIP_LIB"} = "$geoip_lib"; $configlib{"GEOIP_LIB"} = "$geoip2_lib";
my $geoip_dll = File::Spec->catfile($geoip_path, "GeoIP.dll"); my $geoip_inc = qq(/I "$geoip2_path");
$configdll{"GEOIP_DLL"} = "$geoip_dll"; my $geoip2_libs = qq("$geoip2_lib" Ws2_32.Lib);
if ($verbose) { if ($verbose) {
print "checking for GeoIP support\n"; print "checking for GeoIP2 support\n";
}
my $ret = `copy "$geoip_dll" .`;
if ($? != 0) {
die "Can't copy GeoIP DLL to working directory: $ret\n";
}
open F, ">testgeoip.c" || die $!;
print F << 'EOF';
extern void *GeoIP_open();
int main() {
return GeoIP_open != 0;
}
EOF
close F;
$compret = `cl /nologo /MD testgeoip.c "$geoip_lib"`;
if (grep { -f and -x } ".\\testgeoip.exe") {
`.\\testgeoip.exe`;
if ($? == 0) {
die "GeoIP test failed\n";
}
} else {
die "can't compile GeoIP test: $compret\n";
}
$configdefh{"HAVE_GEOIP"} = 1;
if ($verbose) {
print "checking for GeoIP Country IPv6 support\n";
}
my $geoip_inc = qq(/I "$geoip_path");
my $geoip_libs = qq("$geoip_lib" ws2_32.lib);
open F, ">testgeoip1.c" || die $!;
print F << 'EOF';
#include <GeoIP.h>
struct in6_addr in6;
int flag = 1;
int main() {
if (flag)
return 1;
return GeoIP_country_name_by_ipnum_v6(NULL, in6) != NULL;
}
EOF
close F;
$compret = `cl /nologo $geoip_inc /MD testgeoip1.c $geoip_libs`;
if (grep { -f and -x } ".\\testgeoip1.exe") {
`.\\testgeoip1.exe`;
if ($? == 0) {
die "GeoIP Country IPv6 test failed\n";
}
} else {
die "can't compile GeoIP Country IPv6 test: $compret\n";
}
$configdefh{"HAVE_GEOIP_V6"} = 1;
if ($verbose) {
print "checking for GeoIP City IPv6 support\n";
} }
open F, ">testgeoip2.c" || die $!; open F, ">testgeoip2.c" || die $!;
print F << 'EOF'; print F << 'EOF';
#include <GeoIP.h> #include <maxminddb.h>
#include <GeoIPCity.h> int main(void) {
return MMDB_lib_version() != 0;
struct in6_addr in6;
int i = GEOIP_CITY_EDITION_REV0_V6;
int flag = 1;
int main() {
if (flag)
return 1;
return GeoIP_record_by_ipnum_v6(NULL, in6) != NULL;
} }
EOF EOF
close F; close F;
$compret = `cl /nologo $geoip_inc /MD testgeoip2.c $geoip_libs`; $compret = `cl /nologo $geoip_inc /MD testgeoip2.c $geoip2_libs`;
if (grep { -f and -x } ".\\testgeoip2.exe") { if (grep { -f and -x } ".\\testgeoip2.exe") {
`.\\testgeoip2.exe`; `.\\testgeoip2.exe`;
if ($? == 0) { if ($? == 0) {
die "GeoIP City IPv6 test failed\n"; die "GeoIP2 test failed\n";
} }
} else { } else {
die "can't compile GeoIP City IPv6 test: $compret\n"; die "can't compile GeoIP2 test: $compret\n";
} }
$configdefh{"HAVE_GEOIP_CITY_V6"} = 1; $configdefh{"HAVE_GEOIP2"} = 1;
} }
# with-readline # with-readline
@ -2746,9 +2681,6 @@ sub makeinstallfile {
print LOUT "krb5_32.dll-BCFT\n"; print LOUT "krb5_32.dll-BCFT\n";
} }
} }
if ($use_geoip eq "yes") {
print LOUT "libgeoip.dll-BCFT\n";
}
if ($use_idn eq "yes") { if ($use_idn eq "yes") {
print LOUT "idnkit.dll-BCFT\n"; print LOUT "idnkit.dll-BCFT\n";
print LOUT "iconv.dll-BCFT\n"; print LOUT "iconv.dll-BCFT\n";
@ -2950,7 +2882,7 @@ exit 0;
# --with-aes supported # --with-aes supported
# --with-cc-alg supported # --with-cc-alg supported
# --with-randomdev not supported on WIN32 (makes no sense) # --with-randomdev not supported on WIN32 (makes no sense)
# --with-geoip supported # --with-geoip2 supported
# --with-gssapi supported with MIT (K)erberos (f)or (W)indows # --with-gssapi supported with MIT (K)erberos (f)or (W)indows
# --with-lmdb no supported on WIN32 (port is not reliable) # --with-lmdb no supported on WIN32 (port is not reliable)
# --with-libxml2 supported # --with-libxml2 supported