Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create geoip plugin #4688

Merged
merged 23 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unused db types
Signed-off-by: Sven Nebel <nebel.sven@gmail.com>
  • Loading branch information
snebel29 committed Jul 13, 2021
commit 77ffd3fd53806ab1cad615eb8b964db1c2bd1f2d
9 changes: 1 addition & 8 deletions plugin/geoip/geoip.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,7 @@ type db struct {
}

const (
anonymousIP = 1 << iota
asn
city
connectionType
country
domain
enterprise
isp
city = 1 << iota
)

var probingIP = net.ParseIP("127.0.0.1")
Expand Down
9 changes: 6 additions & 3 deletions plugin/geoip/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ func TestGeoIPParse(t *testing.T) {
expectedDBType int
}{
// Valid
{false, fmt.Sprintf("%s %s\n", pluginName, enterpriseDBPath), "", enterprise},
{false, fmt.Sprintf("%s %s\n", pluginName, enterpriseDBPath), "", city},
{false, fmt.Sprintf("%s %s\n", pluginName, cityDBPath), "", city},
{false, fmt.Sprintf("%s %s\n", pluginName, countryDBPath), "", country},

{false, fmt.Sprintf("%s %s\n", pluginName, countryDBPath), "", city},

// Invalid
{true, pluginName, "Wrong argument count", 0},
Expand Down Expand Up @@ -93,6 +92,10 @@ func TestGeoIPParse(t *testing.T) {
if geoIP.db.Reader == nil {
t.Errorf("Test %d: after parsing database reader should be initialized", i)
}

if geoIP.db.provides&test.expectedDBType == 0 {
t.Errorf("Test %d: expected db type %d not found, database file provides %d", i, test.expectedDBType, geoIP.db.provides)
}
}

// Set nil probingIP to test unexpected validate error()
Expand Down