diff --git a/Config b/Config index adbb8bd00..079053a0e 100755 --- a/Config +++ b/Config @@ -113,8 +113,8 @@ ARG="$ARG--enable-dynamic-linking " if [ "$GEOIP" = "classic" ]; then ARG="$ARG--enable-geoip-classic " fi -if [ "$GEOIP" = "libmaxminddb" ]; then - ARG="$ARG--enable-libmaxminddb " +if [ "$GEOIP" = "mmdb" -o "$GEOIP" = "libmaxminddb" ]; then + ARG="$ARG--enable-mmdb " fi if [ "$SANITIZER" = "asan" ]; then ARG="$ARG--enable-asan " @@ -281,7 +281,7 @@ OPEROVERRIDEVERIFY="" GENCERTIFICATE="1" EXTRAPARA="" SANITIZER="" -GEOIP="classic" +GEOIP="mmdb" if [ "`eval echo -n 'a'`" = "-n a" ] ; then c="\c" else @@ -773,12 +773,12 @@ while [ -z "$TEST" ] ; do echo "" echo "GeoIP is a feature that allows converting an IP address to a location (country)" echo "Possible build options:" - echo " classic: This is the DEFAULT geoip engine. It should work on all systems" - echo " and receives automatic updates." - echo "libmaxminddb: This uses the libmaxminddb library. If you want to use this, then" - echo " you need to install the libmaxminddb library on your system first" - echo " none: Don't build with any geoip library (geoip-csv is still built)" - echo "Choose one of: classic, libmaxminddb, none" + echo "classic: This is the classic (OLD) geoip engine. Slowly being phased out." + echo " It receives automatic updates." + echo " mmdb: This uses the build-in mmdb library. It is the NEW geoip engine." + echo " It receives automatic updates as well." + echo " none: Don't build classic, and load neither classic nor mmdb by default." + echo "Choose one of: classic, mmdb, none" echo $n "[$TEST] -> $c" read cc if [ -z "$cc" ] ; then @@ -789,7 +789,7 @@ while [ -z "$TEST" ] ; do classic) GEOIP="$cc" ;; - libmaxminddb) + mmdb) GEOIP="$cc" ;; none) diff --git a/autoconf/m4/unreal.m4 b/autoconf/m4/unreal.m4 index 69899da97..411c093ab 100644 --- a/autoconf/m4/unreal.m4 +++ b/autoconf/m4/unreal.m4 @@ -467,5 +467,6 @@ AC_DEFUN([CHECK_GEOIP_CLASSIC], GEOIP_CLASSIC_OBJECTS="geoip_classic.so" AC_SUBST(GEOIP_CLASSIC_OBJECTS) + AC_DEFINE([GEOIP_ENGINE], ["geoip_classic"], [Classic GeoIP engine]) ]) dnl AS_IF(enable_geoip_classic) ]) diff --git a/configure b/configure index 2e73c3c8b..80bed0770 100755 --- a/configure +++ b/configure @@ -784,6 +784,7 @@ enable_werror enable_asan enable_libcurl enable_geoip_classic +enable_mmdb ' ac_precious_vars='build_alias host_alias @@ -1446,6 +1447,7 @@ Optional Features: --enable-libcurl=DIR enable libcurl (remote include) support --enable-geoip-classic=no/yes enable GeoIP Classic support + --enable-mmdb=no/yes enable GeoIP mmdb support Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -10133,6 +10135,25 @@ fi GEOIP_CLASSIC_OBJECTS="geoip_classic.so" +printf "%s\n" "#define GEOIP_ENGINE \"geoip_classic\"" >>confdefs.h + + +fi + +# Check whether --enable-mmdb was given. +if test ${enable_mmdb+y} +then : + enableval=$enable_mmdb; enable_mmdb=$enableval +else case e in #( + e) enable_mmdb=no ;; +esac +fi + +if test "x$enable_mmdb" = "xyes" +then : + +printf "%s\n" "#define GEOIP_ENGINE \"geoip_mmdb\"" >>confdefs.h + fi UNRLINCDIR="`pwd`/include" diff --git a/configure.ac b/configure.ac index 910c46ecf..c665625a3 100644 --- a/configure.ac +++ b/configure.ac @@ -930,6 +930,15 @@ CHECK_LIBCURL CHECK_GEOIP_CLASSIC +dnl This does not do much anymore but.. +AC_ARG_ENABLE(mmdb, +[AC_HELP_STRING([--enable-mmdb=no/yes],[enable GeoIP mmdb support])], +[enable_mmdb=$enableval], +[enable_mmdb=no]) +AS_IF([test "x$enable_mmdb" = "xyes"], +[AC_DEFINE([GEOIP_ENGINE], ["geoip_mmdb"], [MMDB GeoIP engine])]) + +dnl Set to include dir UNRLINCDIR="`pwd`/include" dnl This is at the end so the (potential) -std=gnu17 is not used diff --git a/doc/RELEASE-NOTES.md b/doc/RELEASE-NOTES.md index 57b46c9e1..3a10f729c 100644 --- a/doc/RELEASE-NOTES.md +++ b/doc/RELEASE-NOTES.md @@ -7,8 +7,14 @@ This is work in progress and may not always be a stable version. ### Enhancements: ### Changes: -* [GeoIP](https://www.unrealircd.org/docs/GeoIP): Move from `geoip_classic` - to `geoip_mmdb` as the default backend, at least for new installations. +* [GeoIP](https://www.unrealircd.org/docs/GeoIP): + * We now ship with our own mmdb engine and `geoip_mmdb` (replacement for + `geoip_maxmind`). + * The `./Config` question on GeoIP now defaults to `mmdb`. Existing users + who upgrade will keep their current setting (usually `classic`) for now. + * Both `geoip_classic` and `geoip_mmdb` now receive automatic updates + * You can `@define $NO_GEOIP_CONFIG "1"` to disable auto configuration + and updates. ### Fixes: diff --git a/doc/conf/modules.default.conf b/doc/conf/modules.default.conf index 85debc135..978ebd446 100644 --- a/doc/conf/modules.default.conf +++ b/doc/conf/modules.default.conf @@ -313,8 +313,21 @@ loadmodule "utf8only"; /* UTF8ONLY via set::utf8-only */ loadmodule "portinfo"; /* storing local_port and server_port of users */ loadmodule "isupport"; /* ISUPPORT / numeric 005 handling */ -loadmodule "geoip_mmdb"; +@if $GEOIP_ENGINE != "none" +loadmodule "$GEOIP_ENGINE"; +@endif + @if !defined(NO_GEOIP_CONFIG) +@if module-loaded("geoip_classic") +set { + geoip-classic { + ipv4-database "https://www.unrealircd.org/files/geo/classic/GeoIP.dat" { url-refresh 14d; url-fail warn; } + ipv6-database "https://www.unrealircd.org/files/geo/classic/GeoIPv6.dat" { url-refresh 14d; url-fail warn; } + asn-ipv4-database "https://www.unrealircd.org/files/geo/classic/GeoIPASNum.dat" { url-refresh 14d; url-fail warn; } + asn-ipv6-database "https://www.unrealircd.org/files/geo/classic/GeoIPASNumv6.dat" { url-refresh 14d; url-fail warn; } + } +} +@endif @if module-loaded("geoip_mmdb") set { geoip-mmdb { diff --git a/include/setup.h.in b/include/setup.h.in index 84ec3822f..e98f7bae2 100644 --- a/include/setup.h.in +++ b/include/setup.h.in @@ -25,6 +25,9 @@ /* Define the location of the documentation */ #undef DOCDIR +/* MMDB GeoIP engine */ +#undef GEOIP_ENGINE + /* Define if you have getrusage */ #undef GETRUSAGE_2 diff --git a/src/conf_preprocessor.c b/src/conf_preprocessor.c index ac36f2ce4..d0115e05f 100644 --- a/src/conf_preprocessor.c +++ b/src/conf_preprocessor.c @@ -433,6 +433,11 @@ void init_config_defines(void) add_nvplist(&config_defines, 0, "UNREALIRCD_VERSION_MAJOR", PATCH2); add_nvplist(&config_defines, 0, "UNREALIRCD_VERSION_MINOR", PATCH3); add_nvplist(&config_defines, 0, "UNREALIRCD_VERSION_SUFFIX", PATCH4); +#ifdef GEOIP_ENGINE + add_nvplist(&config_defines, 0, "GEOIP_ENGINE", GEOIP_ENGINE); +#else + add_nvplist(&config_defines, 0, "GEOIP_ENGINE", "none"); +#endif } /** Return the complete struct for a defined value */