Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geoip: module relocated to archive #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions src/modules/geoip/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# WARNING: do not run this directly, it should be run by the main Makefile

include ../../Makefile.defs
auto_gen=
NAME=geoip.so
LIBS= -lGeoIP

include ../../Makefile.modules
166 changes: 166 additions & 0 deletions src/modules/geoip/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
geoip Module

Daniel-Constantin Mierla

asipto.com

Edited by

Daniel-Constantin Mierla

<[email protected]>

Alex Balashov

Evariste Systems LLC
<[email protected]>

Copyright © 2010 Daniel-Constantin Mierla (asipto.com)
__________________________________________________________________

Table of Contents

1. Admin Guide

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Parameters

3.1. path (string)

4. Functions

4.1. geoip_match(ipaddr, pvc)

5. Exported pseudo-variables

List of Examples

1.1. Set path parameter
1.2. geoip_match usage

Chapter 1. Admin Guide

Table of Contents

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Parameters

3.1. path (string)

4. Functions

4.1. geoip_match(ipaddr, pvc)

5. Exported pseudo-variables

1. Overview

This module allows real-time queries against the Max Mind GeoIP
database to be performed from the config script. It uses the old
version of API, still very common on OS distributions. For using the
new version of GeoIP API, see geoip2 module.

The Max Mind GeoIP database is a map of IP network address assignments
to geographical locales that can be useful -- though approximate -- in
identifying the physical location with which an IP host address is
associated on a relatively granular level.

This database itself can be obtained on a free or commercial basis from
http://www.maxmind.com/app/ip-location. The library that interfaces
with the Max Mind API, as well as scripts to automate downloading of
the on-disk version of the open-source database is also packaged by the
Debian Linux distribution and its derivatives as libgeoip, and probably
by other distributions as well.

Debian Linux squeeze includes already a database as dependency, but as
this contain the wrong data, it will not work correctly with the
module. More accurate, the module expect the GeoIP City Edition, and
will not work with the GeoIP Country Edition. In newer Debian Linux
releases the package geoip-database-contrib should contain the
necessary database. You can download the Lite edition of the DB from
http://www.maxmind.com/app/geolitecity.

This module exports a new class of pseudo-variables - $gip(pvc=>key) -
to enable access to the results of a query to the database.

Many queries can be done and store results in different containers to
be able to use in parallel. Database is loaded at startup in cache.

2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

2.1. Kamailio Modules

The following modules must be loaded before this module:
* none.

2.2. External Libraries or Applications

The following libraries or applications must be installed before
running Kamailio with this module loaded:
* libgeoip - the GeoIP library.

3. Parameters

3.1. path (string)

3.1. path (string)

Path to the GeoIP database file.

Default value is “null”.

Example 1.1. Set path parameter
...
modparam("geoip", "path", "/usr/local/share/GeoLiteCity.dat")
...

4. Functions

4.1. geoip_match(ipaddr, pvc)

4.1. geoip_match(ipaddr, pvc)

Match ipaddr against the GeoIP database and set the pvc container. The
function has to be called before accessing a key via: $gip(pvc=>key).

Example 1.2. geoip_match usage
...
if(geoip_match("$si", "src"))
xlog("SIP message from: $gip(src=>cc)\n");
...

5. Exported pseudo-variables

* $gip(pvc=>key) - pvc is an identifier for this query result; it is
designated by the second parameter of geoip_match(). The key can be
one of the following:
+ cc - country code
+ tz - time zone
+ zip - postal code
+ lat - latitude
+ lon - longitude
+ dma - dma code
+ ips - ip start
+ ipe - ip end
+ city - city
+ area - area code
+ regc - region
+ regn - region name
+ metro - metro code
+ contc - continent code

Exported pseudo-variables are documented at
https://www.kamailio.org/wikidocs/.
4 changes: 4 additions & 0 deletions src/modules/geoip/doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs = geoip.xml

docbook_dir = ../../../../doc/docbook
include $(docbook_dir)/Makefile.module
42 changes: 42 additions & 0 deletions src/modules/geoip/doc/geoip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
%docentities;

]>

<book xmlns:xi="http://www.w3.org/2001/XInclude">
<bookinfo>
<title>geoip Module</title>
<productname class="trade">&kamailioname;</productname>
<authorgroup>
<author>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<affiliation><orgname>asipto.com</orgname></affiliation>
</author>
<editor>
<firstname>Daniel-Constantin</firstname>
<surname>Mierla</surname>
<email>[email protected]</email>
</editor>
<editor>
<firstname>Alex</firstname>
<surname>Balashov</surname>
<email>[email protected]</email>
<affiliation><orgname>Evariste Systems LLC</orgname></affiliation>
</editor>
</authorgroup>
<copyright>
<year>2010</year>
<holder>Daniel-Constantin Mierla (asipto.com)</holder>
</copyright>
</bookinfo>
<toc></toc>

<xi:include href="geoip_admin.xml"/>

</book>
Loading