Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.4 KB

README.md

File metadata and controls

47 lines (37 loc) · 1.4 KB

geolocation-iptoasn-go

go-test-badge

Webservice for getting geolocation and ASN information from IP addresses. This service can be easily run using docker. It has been implemented using Golang Gin Gonic.

The source of the database is https://iptoasn.com/. The service has a scheduler that downloads the database every week. However, you can easily integrate any database of your liking.

This service loads the database into memory and uses binary search to get desired data. You can connect the KeyValueStore struct to any database of your liking if you have a bigger database of GeoIp Information.

Usage

$ curl 'http://localhost:9000/geo/?ip=103.84.159.230'
{
  "ip": "103.84.159.230",
  "country": "BD",
  "asn_number": "133168",
  "asn_description": "SUOSAT-AS-AP Shahjalal University of Science and Technology"
}

Getting Started

Option 1:

Prerequisite go

$ cd geolink-go
$ go mod download
$ go build -o main main.go
$ ./main

Option 2:

Prerequisite docker, docker-compose

docker-compose up

Acknowledgement & Inspiration