MCPcopy Index your code
hub / github.com/9seconds/topographer

github.com/9seconds/topographer @v1.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.2 ↗ · + Follow
495 symbols 1,515 edges 57 files 48 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Topographer

CI Code Coverage Go Reference

Fast and lenient self-hosted IP geolocation service.

Sometimes you need to detect regions and cities of different IPs. There are a bunch of databases and free services available but you need to have a code which works with these database or deal with limitations of these services. For example, ipinfo.io or freegeoip.net limit your queries.

Sometimes you need your own service which responds with country/city and does not have such limitations. Most of such services are based on free versions of geolocation databases so it makes sense to have a free self-hosted service which you can simply plug into your infrastructure.

Also, if you ever deal with IP geolocation you may know it is awfully imprecise. There are many situations when one database detects one city, another - slightly different location. Also, if you deal with non-residential IPs you may know that a lot of hosters and clouds have a weird route setup so you may have differences even in countries!

Just look at this example: https://bgpview.io/ip/191.96.13.80 Which country does this IP belong?

This service goes in slightly different way: it uses a couple of databases, collects their results, combine and consolidate results and return a final one.

It queries all providers (or a limited set of them), picks the most popular country. Within this country group, it picks the most popular city and returns this tuple as a result.

Building

Building is trivial.

  1. Install Golang;
  2. Run go get github.com/9seconds/topographer

or if you want to build from sources:

$ git clone https://github.com/9seconds/topographer
$ cd topographer
$ go build

or simple build Docker container

$ docker build -t topographer .

Installing

Installation is simple as

$ go get github.com/9seconds/topographer

(but if you want, you can find prebuilt binaries on releases page)

We also have Docker images in both DockerHub and Github Container Registry:

$ docker pull nineseconds/topographer

and

$ docker pull ghcr.io/9seconds/topographer:master

Running the application

A binary has a single cli flag: -config.

$ topographer -config /path/to/config.hjson

or if you run with docker, just put config as /config.hjson there:

$ docker run -v /path/to/local/config.hjson:/config.hjson -p 8000:80 nineseconds/topographer

API

Please see OpenAPI specification.

Extension points exported contracts — how you extend this code

Provider (Interface)
Provider represents an entity which can resolve geolocation of IP addresses. Each provider should work with its own ser [6 …
topolib/interfaces.go
HTTPClient (Interface)
HTTPClient is something which can do HTTP requests and returns HTTP responses. For example, topolib enrich default http [4 …
topolib/interfaces.go
OfflineProvider (Interface)
OfflineProvider is a special version of Provider which works with offline databases. A major difference is that these d [3 …
topolib/interfaces.go
Logger (Interface)
Logger is a logger interface used by Topographer. Each method accepts name parameter. name is a name of the provider. [2 …
topolib/interfaces.go

Core symbols most depended-on inside this repo

Error
called by 68
topolib/errors.go
Do
called by 56
topolib/interfaces.go
String
called by 47
topolib/country_codes.go
Lookup
called by 37
topolib/interfaces.go
Download
called by 37
topolib/interfaces.go
Open
called by 26
topolib/interfaces.go
Name
called by 23
topolib/interfaces.go
Alpha2ToCountryCode
called by 17
topolib/country_codes.go

Shape

Method 353
Struct 73
Function 63
Interface 4
FuncType 1
TypeAlias 1

Languages

Go100%

Modules by API surface

providers/software77_test.go27 symbols
providers/maxmind_lite_test.go22 symbols
providers/dbip_lite_test.go22 symbols
config.go22 symbols
providers/ip2location_test.go20 symbols
topolib/circuit_breaker_internal_test.go18 symbols
topolib/interfaces.go15 symbols
providers/software77.go15 symbols
topolib/init_test.go13 symbols
topolib/init_internal_test.go13 symbols
topolib/http_handler_test.go13 symbols
providers/ipstack_test.go13 symbols

For agents

$ claude mcp add topographer \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact