aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2022-08-21 22:06:37 +0200
committerSergey Poznyakoff <gray@gnu.org>2022-08-21 22:06:37 +0200
commit323510401b322d79e33066c5b8f0842a0e03a5e5 (patch)
treee41b231a2a29e4a04435f6f1f3c4c9bfcb3213cc
parent73dca6056e7b20f08f28b155c4e6706a7e93940a (diff)
downloadvmod-geoip-master.tar.gz
vmod-geoip-master.tar.bz2
Version 1.2: support for Varnish 7.1HEADv1.2master
-rw-r--r--NEWS5
m---------acvmod0
-rw-r--r--configure.ac6
-rw-r--r--src/vmod_geoip.c46
4 files changed, 38 insertions, 19 deletions
diff --git a/NEWS b/NEWS
index 3a6efa9..0a51673 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
-Vmod-geoip NEWS -- history of user-visible changes. 2020-03-27
+Vmod-geoip NEWS -- history of user-visible changes. 2022-08-21
See the end of file for copying conditions.
Please send Vmod-geoip bug reports to <gray@gnu.org>
-Version 1.1.90 (git)
+Version 1.2, 2022-08-21
+* Support for Varnish 7.1
* Drop support for Varnish versions prior to 6.0.0
diff --git a/acvmod b/acvmod
-Subproject 82d8dc6b0c0f316acb7f9b4f351fbd8cb1f85e9
+Subproject 0516e2461e8f2e3b33a7fffa13705cdb1de77c5
diff --git a/configure.ac b/configure.ac
index 06538a2..ae94346 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# This file is part of vmod-geoip -*- autoconf -*-
-# Copyright (C) 2017-2020 Sergey Poznyakoff
+# Copyright (C) 2017-2022 Sergey Poznyakoff
#
# Vmod-geoip is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with vmod-geoip. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
-AC_INIT([vmod-geoip], 1.1.90, [gray@gnu.org])
+AC_INIT([vmod-geoip], 1.2, [gray@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vmod_geoip.vcc)
@@ -42,7 +42,7 @@ AC_PROG_MAKE_SET
AC_HEADER_STDC
AC_CHECK_HEADERS([sys/stdlib.h])
-AM_VARNISHAPI([6.0.0], [6.3.2])
+AM_VARNISHAPI([6.0.0], [7.1.0])
AC_DEFINE_UNQUOTED([VARNISHAPI_MAJOR],[$VARNISHAPI_MAJOR],
[Varnish API major version number])
diff --git a/src/vmod_geoip.c b/src/vmod_geoip.c
index d704915..8af0ba8 100644
--- a/src/vmod_geoip.c
+++ b/src/vmod_geoip.c
@@ -34,12 +34,26 @@ struct geoip_config {
char *database;
};
+#if (VARNISHAPI_MAJOR == 6 && VARNISHAPI_MINOR >= 6) || VARNISHAPI_MAJOR > 6
+static void
+free_conf(VRT_CTX, void *data)
+{
+ free(data);
+}
+
+static const struct vmod_priv_methods free_conf_methods[1] = {{
+ .magic = VMOD_PRIV_METHODS_MAGIC,
+ .type = "vmod_geoip",
+ .fini = free_conf
+}};
+#else
static void
free_conf(void *data)
{
struct geoip_config *cfg = data;
free(data);
}
+#endif
int
VEVENT(geoip_event)(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
@@ -48,7 +62,11 @@ VEVENT(geoip_event)(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
struct geoip_config *conf = calloc(1, sizeof(*conf));
AN(conf);
priv->priv = conf;
+#if (VARNISHAPI_MAJOR == 6 && VARNISHAPI_MINOR >= 6) || VARNISHAPI_MAJOR > 6
+ priv->methods = free_conf_methods;
+#else
priv->free = free_conf;
+#endif
}
return 0;
}
@@ -107,7 +125,7 @@ open_geoip_database(VRT_CTX, struct geoip_config *conf, MMDB_s *dbptr)
return 0;
}
-static char *
+static const char *
conv_utf_string (struct ws *ws, MMDB_entry_data_s *dptr)
{
char *retval = WS_Alloc(ws, dptr->data_size + 1);
@@ -117,43 +135,43 @@ conv_utf_string (struct ws *ws, MMDB_entry_data_s *dptr)
return retval;
}
-static char *
+static const char *
conv_uint16(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%" PRIu16, dptr->uint16);
}
-static char *
+static const char *
conv_uint32(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%" PRIu32, dptr->uint32);
}
-static char *
+static const char *
conv_int32(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%" PRIi32, dptr->int32);
}
-static char *
+static const char *
conv_bool(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%01d", dptr->boolean ? 1 : 0);
}
-static char *
+static const char *
conv_double(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%g", dptr->double_value);
}
-static char *
+static const char *
conv_float(struct ws *ws, MMDB_entry_data_s *dptr)
{
return WS_Printf(ws, "%g", dptr->float_value);
}
-static char *(*entry_conv[]) (struct ws *, MMDB_entry_data_s *) = {
+static const char *(*entry_conv[]) (struct ws *, MMDB_entry_data_s *) = {
[MMDB_DATA_TYPE_UTF8_STRING] = conv_utf_string,
[MMDB_DATA_TYPE_UINT16] = conv_uint16,
[MMDB_DATA_TYPE_UINT32] = conv_uint32,
@@ -163,7 +181,7 @@ static char *(*entry_conv[]) (struct ws *, MMDB_entry_data_s *) = {
[MMDB_DATA_TYPE_FLOAT] = conv_float
};
-static char *
+static const char *
lookup_geoip_database(VRT_CTX,
MMDB_s *dbfile, VCL_IP ip,
char const *pathstr, char **path)
@@ -172,7 +190,7 @@ lookup_geoip_database(VRT_CTX,
int mmdb_error;
int rc;
MMDB_entry_data_s entry_data;
- char *retval;
+ const char *retval;
const struct sockaddr *sa;
socklen_t sl;
char ipstr[VTCP_ADDRBUFSIZE];
@@ -255,7 +273,7 @@ vmod_get(VRT_CTX, struct vmod_priv *priv, VCL_IP ip, VCL_STRING path)
{
struct geoip_config *conf = priv->priv;
MMDB_s dbfile;
- char *retval = NULL;
+ const char *retval = NULL;
char **pathv;
if (open_geoip_database(ctx, conf, &dbfile))
@@ -272,7 +290,7 @@ vmod_country_code(VRT_CTX, struct vmod_priv *priv, VCL_IP ip)
{
struct geoip_config *conf = priv->priv;
MMDB_s dbfile;
- char *retval = NULL;
+ char const *retval = NULL;
static char *country_code_path[] = {
"country",
"iso_code",
@@ -292,7 +310,7 @@ vmod_country_name(VRT_CTX, struct vmod_priv *priv, VCL_IP ip)
{
struct geoip_config *conf = priv->priv;
MMDB_s dbfile;
- char *retval = NULL;
+ const char *retval = NULL;
static char *country_name_path[] = {
"country",
"names",
@@ -314,7 +332,7 @@ vmod_city_name(VRT_CTX, struct vmod_priv *priv, VCL_IP ip)
{
struct geoip_config *conf = priv->priv;
MMDB_s dbfile;
- char *retval = NULL;
+ const char *retval = NULL;
static char *city_name_path[] = {
"city",
"names",

Return to:

Send suggestions and report system problems to the System administrator.