Browse Source

geoip2: log errors for cases where the container could not evaluated and add docs

- log errors for cases where the container could not evaluated due to missing
  initialization of the pvc container because no actual access is done in the cfg
- add documentation describing that at least one access to the container is necessary
  for the match function to work correctly

(cherry picked from commit 0c16d6824fda729bf481e300992fb6bad057c89d)
Henning Westerholt 3 years ago
parent
commit
0c7abf1010
2 changed files with 4 additions and 2 deletions
  1. 2 0
      src/modules/geoip2/doc/geoip2_admin.xml
  2. 2 2
      src/modules/geoip2/geoip2_pv.c

+ 2 - 0
src/modules/geoip2/doc/geoip2_admin.xml

@@ -112,6 +112,8 @@ modparam("geoip2", "path", "/usr/local/share/GeoIP/GeoLite2-City.mmdb")
 	    <para>
 	    <para>
 			Match ipaddr against the GeoIP database and set the pvc container. The
 			Match ipaddr against the GeoIP database and set the pvc container. The
 			function has to be called before accessing a key via: $gip2(pvc=&gt;key).
 			function has to be called before accessing a key via: $gip2(pvc=&gt;key).
+			At least one function needs to be present that access the pvc container,
+			otherwise this function will not work.
 	    </para>
 	    </para>
 		<example>
 		<example>
 		<title><function>geoip2_match</function> usage</title>
 		<title><function>geoip2_match</function> usage</title>

+ 2 - 2
src/modules/geoip2/geoip2_pv.c

@@ -565,14 +565,14 @@ int geoip2_update_pv(str *tomatch, str *name)
 
 
 	if(tomatch->len>255)
 	if(tomatch->len>255)
 	{
 	{
-		LM_DBG("target too long (max 255): %s\n", tomatch->s);
+		LM_ERR("target too long (max 255): %s\n", tomatch->s);
 		return -3;
 		return -3;
 	}
 	}
 
 
 	gr = sr_geoip2_get_record(name);
 	gr = sr_geoip2_get_record(name);
 	if(gr==NULL)
 	if(gr==NULL)
 	{
 	{
-		LM_DBG("container not found: %s\n", tomatch->s);
+		LM_ERR("container not found: %s\n", tomatch->s);
 		return - 4;
 		return - 4;
 	}
 	}