Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/iputil
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-02-10 19:52:55 +0300
committerMartin Polden <mpolden@mpolden.no>2018-02-10 19:52:55 +0300
commit215cce290c3c6830efec3c03a3efe5f33550e46d (patch)
treec6378cd59828b1dafe628fc6b1e1dec918e0388d /iputil
parent811253612598c19cbf8d5491b4a1f2f087c88939 (diff)
Disable handlers for disabled features
Diffstat (limited to 'iputil')
-rw-r--r--iputil/db/db.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/iputil/db/db.go b/iputil/db/db.go
index 84fc765..72d3dfa 100644
--- a/iputil/db/db.go
+++ b/iputil/db/db.go
@@ -9,6 +9,7 @@ import (
type Database interface {
Country(net.IP) (Country, error)
City(net.IP) (string, error)
+ IsEmpty() bool
}
type Country struct {
@@ -25,6 +26,7 @@ type empty struct{}
func (d *empty) Country(ip net.IP) (Country, error) { return Country{}, nil }
func (d *empty) City(ip net.IP) (string, error) { return "", nil }
+func (d *empty) IsEmpty() bool { return true }
func Empty() Database { return &empty{} }
@@ -87,3 +89,7 @@ func (g *geoip) City(ip net.IP) (string, error) {
}
return "", nil
}
+
+func (g *geoip) IsEmpty() bool {
+ return g.country != nil || g.city != nil
+}