New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

github.phpd.cn/paysuper/geoip-service

Package Overview
Dependencies
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.phpd.cn/paysuper/geoip-service

Go Modules
Version
v1.2.4
Version published
Created
Source

geoip-service

License: MIT Build Status Go Report Card

A fast Go-Micro based microservice for looking up MaxMind GeoIP2 and GeoLite2 database.

Prerequisites

Requires a go installation.

A Database (choose one):

  • Free GeoLite 2 database. Download the "MaxMind DB binary, gzipped" and unpack it.
  • GeoIP2 Downloadable Database. This is a more detailed database and should be compatible, but since I don't have access to that, I have been unable to verify this.

Running the service

This service works as Go-Micro microservice. You may want to setup your own registry with MICRO_REGISTRY/MICRO_REGISTRY_ADDRESS or use other go-micro flags.

Download it

go get github.com/paysuper/geoip-service

If you need it uou can rebuild proto file with protoc

protoc --proto_path=. --micro_out=. --go_out=. geoip.proto

Setup environment variable MAXMIND_GEOIP_DB_PATH with path to the maxmind database path. The path can be local file path like /application/assets/GeoLite2-City.mmdb, or it can be AWS S3 object path like s3://bucketName/GeoLite2-City.mmdb. In the latter case it is required to provide S3 access credentials with the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

By default service will be executed with declared by MICRO_REGISTRY registry and GRPC as a transport.

Using Docker

The docker file in this project used to launch geoip-service in Protocol One environment. You may change it in any way you need it.

Using the service

Once the service is running you can use go-micro to make requests

package main

import (
    "context"
    "fmt"
    "github.com/paysuper/geoip-service/pkg"
    "github.com/paysuper/geoip-service/pkg/proto"
    "github.com/micro/go-micro"
)

func main() {
    // create a new service
    service := micro.NewService()

    // parse command line flags
    service.Init()

    // Create new greeter client
    client := proto.NewGeoIpService(geoip.ServiceName, service.Client())

    // Call it
    rsp, err := client.GetIpData(context.TODO(), &proto.GeoIpDataRequest{IP: "8.8.8.8"})
    if err != nil {
        fmt.Println(err)
    }

    // Print response
    fmt.Println(rsp)
}

FAQs

Package last updated on 04 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts