package tools

import (
	"github.com/ipipdotnet/ipdb-go"
)

const CITY_DB_FILE = "./data/city.free.ipdb"

func ParseIp(myip string) *ipdb.CityInfo {
	db, err := ipdb.NewCity(CITY_DB_FILE)
	if err != nil {
		return nil
	}
	db.Reload(CITY_DB_FILE)
	c, err := db.FindInfo(myip, "CN")
	if err != nil {
		return nil
	}
	return c
}
