Skip to content

Commit

Permalink
Merge pull request #119 from quakenet/geoip
Browse files Browse the repository at this point in the history
GEOIP: use system libgeoip
  • Loading branch information
retropc authored Oct 2, 2022
2 parents f7b293e + 1edc852 commit 6bfb17b
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 17,714 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install git gcc make python2.7 python-minimal flex bison liblua5.1-0-dev libmariadbclient-dev libpq-dev libpcre3-dev zlib1g-dev
run: sudo apt-get install git gcc make python2.7 python-minimal flex bison liblua5.1-0-dev libmariadbclient-dev libpq-dev libpcre3-dev zlib1g-dev libgeoip-dev
- name: configure
run: ./configure -R -v
- name: make
Expand Down
7 changes: 5 additions & 2 deletions configure.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# libraries we're gonna search for
[core]
libs=pgsql mariadb lua pcre sqlite z
libs=pgsql mariadb lua pcre sqlite z geoip

# dummy libraries, if a module requires one of these then it needs one of the supplied libraries
# the first one will be chosen by default, override with --with-key=value
Expand Down Expand Up @@ -35,7 +35,7 @@ tutorbot=
fsck=
nterfacer=pcre
pqsql=pgsql
geoip=
geoip=geoip
clonehistogram=
lua=lua
versionscan=
Expand Down Expand Up @@ -133,6 +133,9 @@ alwayspresent=1
[libz]
pkgconfig=zlib

[libgeoip]
pkgconfig=geoip

# additional variables for various systems
[osvars]
FreeBSD=CFLAGS+=-fgnu89-inline
Expand Down
22 changes: 5 additions & 17 deletions geoip/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
include ../build.mk

GEOIPDIRS=libGeoIP
LDFLAGS+=-lc
CFLAGS+=$(INCGEOIP)
LDFLAGS+=$(LIBGEOIP)

.PHONY: all clean distclean $(GEOIPDIRS) dirs
.PHONY: all
all: geoip.so

all: dirs geoip.so

libGeoIP/libgeoip.a: dirs

geoip.so: geoip.o libGeoIP/libgeoip.a

dirs: $(GEOIPDIRS)

$(GEOIPDIRS):
cd $@ && $(MAKE) $(MFLAGS) all

clean:
rm -f */*.o */*.so *.o *.so */*.a
rm -rf .deps */.deps
geoip.so: geoip.o
11 changes: 7 additions & 4 deletions geoip/geoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <strings.h>

#include "libGeoIP/GeoIP.h"
#include <GeoIP.h>
#include "geoip.h"

MODULE_VERSION("");
Expand All @@ -33,11 +33,14 @@ void _init(void) {
sstring *filename;

filename = getcopyconfigitem("geoip", "db", "GeoIP.dat", 256);
gi = GeoIP_open(filename->content, GEOIP_MEMORY_CACHE);
freesstring(filename);

if(!gi)
gi = GeoIP_open(filename->content, GEOIP_MEMORY_CACHE);
if(!gi) {
Error("geoip", ERR_WARNING, "Unable to load geoip database [filename: %s]", filename->content);
freesstring(filename);
return;
}
freesstring(filename);

geoip_nickext = registernickext("geoip");
if(geoip_nickext == -1)
Expand Down
Loading

0 comments on commit 6bfb17b

Please sign in to comment.