Exemplo n.º 1
0
func parser(ip net.IP) bool {
	geo, err := gip.New()
	if err != nil {
		logger.Errorf("error when init db,%s", err)
		return false
	}
	country := geo.Lookup(ip)
	if country == nil {
		logger.Error("if address cannot find ,default from china")
		return true
	}
	if strings.Contains(country.String(), "CN") {
		return true
	}
	return false
}
Exemplo n.º 2
0
func init() {
	cache = make(map[*http.Request]*cacheItem, 0)
	geo, err = geoip.New()
	mutex = &sync.RWMutex{}
}