Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
compiler: [clang, gcc]

steps:
- uses: varnishcache-friends/setup-varnish@v1
- uses: varnishcache-friends/setup-vinyl@v2
- run: |
sudo apt-get update
sudo apt-get install -y python3-docutils libmaxminddb-dev
sudo apt-get install -y pkg-config python3-docutils libmaxminddb-dev
- uses: actions/checkout@v4
with:
submodules: recursive
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## unreleased

* Move repository to varnishcache-friends
* Rebrand the build to Vinyl Cache.

## 1.3.0 - 2022-06-16

Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 -I ${VARNISH_DATAROOT}/aclocal
ACLOCAL_AMFLAGS = -I m4 -I ${VINYLAPI_DATAROOT}/aclocal

SUBDIRS = src

DISTCHECK_CONFIGURE_FLAGS = VMOD_DIR='$${libdir}/varnish/vmods'
DISTCHECK_CONFIGURE_FLAGS = VMOD_DIR='$${libdir}/vinyl-cache/vmods'

dist_doc_DATA = LICENSE
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ libvmod-geoip2

## About

A Varnish master VMOD to query MaxMind GeoIP2 DB files.
A Vinyl main VMOD to query MaxMind GeoIP2 DB files.

For Varnish 6.0, 7.4 and 7.5 refer to main branch. Older Varnish
versions are no longer supported.
For Varnish 6.0, 8.0 and Vinyl 9.0 refer to main branch. Other versions are
no longer supported.

## Requirements

Expand All @@ -19,9 +19,9 @@ To build this VMOD you will need:
* a C compiler, e.g. GCC or clang
* pkg-config
* python3-docutils or docutils in macOS [1]
* Varnish master built from sources
* Vinyl master built from sources
* libmaxminddb-dev in recent Debian/Ubuntu releases, maxminddb in
macOS [1]. See also https://github.com/maxmind/libmaxminddb
macOS [1]. See also <https://github.com/maxmind/libmaxminddb>

If you are building from Git, you will also need:

Expand All @@ -30,15 +30,15 @@ If you are building from Git, you will also need:
* libtool

You will also need to set `PKG_CONFIG_PATH` to the directory where
**varnishapi.pc** is located before running `autogen.sh` and
**vinylapi.pc** is located before running `autogen.sh` and
`configure`. For example:

```
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
```

Finally, to use it you will need one or more GeoIP2 or GeoLite2
binary databases. See https://dev.maxmind.com/.
binary databases. See <https://dev.maxmind.com/>.

## Installation

Expand Down Expand Up @@ -69,36 +69,36 @@ installing from a tarball.

### Packages

See https://github.com/varnishcache-friends/libvmod-geoip2/wiki#packages.
See <https://github.com/varnishcache-friends/libvmod-geoip2/wiki#packages>.

## Example

```
import geoip2;

sub vcl_init {
new country = geoip2.geoip2("/path/to/GeoLite2-Country.mmdb");
new country = geoip2.geoip2("/path/to/GeoLite2-Country.mmdb");
}

sub vcl_recv {
if (country.lookup("country/names/en", client.ip) != "Japan") {
...
}
if (country.lookup("country/names/en", client.ip) != "Japan") {
...
}
}
```

More examples available at https://github.com/varnishcache-friends/libvmod-geoip2/wiki.
More examples available at <https://github.com/varnishcache-friends/libvmod-geoip2/wiki>.

## DB updates

To update the GeoIP2 DB, download the new file on the same filesystem
as the old one and move it over. See also
https://github.com/maxmind/geoipupdate.
<https://github.com/maxmind/geoipupdate>.

## License

This VMOD is licensed under BSD license. See LICENSE for details.

### Note

1. Using Homebrew, https://github.com/Homebrew/brew/.
1. Using Homebrew, <https://github.com/Homebrew/brew/>.
6 changes: 3 additions & 3 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh

dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
dataroot=$(pkg-config --variable=datarootdir vinylapi 2>/dev/null)
if [ -z "$dataroot" ] ; then
cat <<_EOF

No package 'varnishapi' found
No package 'vinylapi' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

_EOF
exit 1
fi
export VARNISH_DATAROOT=${dataroot}
export VINYLAPI_DATAROOT=${dataroot}
autoreconf -vif -I${dataroot}/aclocal
22 changes: 11 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR(src/vmod_geoip2.vcc)
AM_CONFIG_HEADER(config.h)
m4_ifndef([VARNISH_VMOD_INCLUDES], AC_MSG_ERROR([varnish.m4 is required.]))
m4_ifndef([VINYL_VMOD_INCLUDES], AC_MSG_ERROR([vinyl.m4 is required.]))

AM_INIT_AUTOMAKE([foreign color-tests parallel-tests])

Expand Down Expand Up @@ -38,19 +38,19 @@ AM_PATH_PYTHON([3.4], [], [
AC_PATH_PROGS([RST2MAN], [rst2man rst2man.py])
test -z "$RST2MAN" && AC_MSG_ERROR([rst2man is required.])

PKG_CHECK_VAR([VARNISH_PREFIX], [varnishapi], [prefix])
PKG_CHECK_VAR([VARNISH_BINDIR], [varnishapi], [bindir])
PKG_CHECK_VAR([VARNISH_SBINDIR], [varnishapi], [sbindir])
PKG_CHECK_VAR([VARNISH_DATAROOT], [varnishapi], [datarootdir])
PKG_CHECK_VAR([VINYLAPI_PREFIX], [vinylapi], [prefix])
PKG_CHECK_VAR([VINYLAPI_BINDIR], [vinylapi], [bindir])
PKG_CHECK_VAR([VINYLAPI_SBINDIR], [vinylapi], [sbindir])
PKG_CHECK_VAR([VINYLAPI_DATAROOT], [vinylapi], [datarootdir])

VARNISH_VMOD_INCLUDES
VARNISH_VMOD_DIR
VARNISH_VMODTOOL
VINYL_VMOD_INCLUDES
VINYL_VMOD_DIR
VINYL_VMODTOOL

ac_default_prefix=$VARNISH_PREFIX
ac_default_prefix=$VINYLAPI_PREFIX

AC_PATH_PROG([VARNISHTEST], [varnishtest], [], [$VARNISH_BINDIR:$PATH])
AC_PATH_PROG([VARNISHD], [varnishd], [], [$VARNISH_SBINDIR:$PATH])
AC_PATH_PROG([VINYLTEST], [vinyltest], [], [$VINYLAPI_BINDIR:$PATH])
AC_PATH_PROG([VINYLD], [vinyld], [], [$VINYLAPI_SBINDIR:$PATH])

VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
AC_SUBST(VMOD_TESTS)
Expand Down
7 changes: 4 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

TESTS_ENVIRONMENT = PATH=$(VARNISH_BINDIR):$(VARNISH_SBINDIR):$$PATH
TESTS_ENVIRONMENT = PATH=$(VINYLAPI_BINDIR):$(VINYLAPI_SBINDIR):$$PATH

vmoddir = $(VMOD_DIR)
vmod_LTLIBRARIES = libvmod_geoip2.la
Expand All @@ -16,7 +16,7 @@ nodist_libvmod_geoip2_la_SOURCES = \

dist_man_MANS = vmod_geoip2.3

VTC_LOG_COMPILER = $(VARNISHTEST) -v \
VTC_LOG_COMPILER = $(VINYLTEST) -v \
-Dvmod_topbuild=$(abs_top_builddir) -Dvmod_topsrc=$(abs_top_srcdir)
TEST_EXTENSIONS = .vtc
TESTS = @VMOD_TESTS@
Expand All @@ -39,7 +39,8 @@ CLEANFILES = $(builddir)/vcc_if.c \
$(builddir)/vcc_if.h \
$(builddir)/vmod_geoip2.man.rst \
$(builddir)/vmod_geoip2.rst \
$(builddir)/$(dist_man_MANS)
$(builddir)/$(dist_man_MANS) \
$(builddir)/vmod_vcs_version.txt

if USE_LCOV
check-local:
Expand Down
4 changes: 2 additions & 2 deletions src/tests/b00000.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test supported types"
vtest "Test supported types"

server s1 {
rxreq
Expand All @@ -7,7 +7,7 @@ server s1 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import std;

Expand Down
4 changes: 2 additions & 2 deletions src/tests/b00001.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test various lookups"
vtest "Test various lookups"

server s1 {
rxreq
Expand All @@ -7,7 +7,7 @@ server s1 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import std;

Expand Down
14 changes: 7 additions & 7 deletions src/tests/b00002.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test error cases"
vtest "Test error cases"

server s1 -repeat 2 {
rxreq
Expand All @@ -7,9 +7,9 @@ server s1 -repeat 2 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -arg "-p thread_pools=1" -vcl+backend { } -start
vinyl v1 -arg "-p thread_pools=1" -vcl+backend { } -start

varnish v1 -errvcl "Error opening the specified MaxMind DB file" {
vinyl v1 -errvcl "Error opening the specified MaxMind DB file" {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
backend default {
.host = "127.0.0.1";
Expand All @@ -20,7 +20,7 @@ varnish v1 -errvcl "Error opening the specified MaxMind DB file" {
}
}

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import std;

Expand Down Expand Up @@ -77,12 +77,12 @@ client c1 {

logexpect l1 -wait

varnish v1 -vcl+backend { }
vinyl v1 -vcl+backend { }

client c1 {
txreq
rxresp
} -run

varnish v1 -cliok "vcl.discard vcl1"
varnish v1 -cliok "vcl.discard vcl3"
vinyl v1 -cliok "vcl.discard vcl1"
vinyl v1 -cliok "vcl.discard vcl3"
4 changes: 2 additions & 2 deletions src/tests/b00003.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test workspace exhaustion"
vtest "Test workspace exhaustion"

server s1 {
rxreq
Expand All @@ -7,7 +7,7 @@ server s1 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import vtc;

Expand Down
4 changes: 2 additions & 2 deletions src/tests/b00004.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test logging from vcl_init{}"
vtest "Test logging from vcl_init{}"

server s1 {
rxreq
Expand All @@ -7,7 +7,7 @@ server s1 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import std;

Expand Down
4 changes: 2 additions & 2 deletions src/tests/b00005.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test passing a null ip fails gracefully"
vtest "Test passing a null ip fails gracefully"

server s1 {
rxreq
Expand All @@ -7,7 +7,7 @@ server s1 {

shell "cp ${vmod_topsrc}/src/tests/libvmod-geoip2.mmdb ${tmpdir}"

varnish v1 -vcl+backend {
vinyl v1 -vcl+backend {
import geoip2 from "${vmod_topbuild}/src/.libs/libvmod_geoip2.so";
import std;
import vtc;
Expand Down
4 changes: 2 additions & 2 deletions src/vmod_geoip2.vcc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

$Module geoip2 3 "Varnish GeoIP2 Lookup Module"
$Module geoip2 3 "Vinyl GeoIP2 Lookup Module"

DESCRIPTION
===========
Expand Down Expand Up @@ -90,7 +90,7 @@ SEE ALSO
========

* `mmdblookup(1)`
* `varnishlog(1)`
* `vinyllog(1)`
* `vsl(7)`
* `GeoIP2 Databases <https://www.maxmind.com/en/geoip2-databases>`
* `GeoIP2 Update program <https://github.com/maxmind/geoipupdate>`
Loading