示例#1
0
文件: filter.go 项目: wjybluse/fproxy
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
}
示例#2
0
文件: geo.go 项目: codeblanche/golibs
func init() {
	cache = make(map[*http.Request]*cacheItem, 0)
	geo, err = geoip.New()
	mutex = &sync.RWMutex{}
}