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

Update to the demo db #389

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified coredns/examples/GeoLite2-City-demo.mmdb
Binary file not shown.
33 changes: 25 additions & 8 deletions coredns/examples/db-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import (
)

const (
cdirIE = "127.0.100.100/24"
cidrUS = "127.0.200.200/24"
cdirIE127 = "127.0.100.100/24"
cidrIE10 = "10.89.100.100/24"

cidrUS127 = "127.0.200.200/24"
cidrUS10 = "10.89.200.200/24"
)

// Create new mmdb database fixtures in this directory.
Expand All @@ -32,13 +35,20 @@ func createCityDB(dbName, dbType string) {
}

// Define and insert the new data.
_, ipIE, err := net.ParseCIDR(cdirIE)
_, ipIE127, err := net.ParseCIDR(cdirIE127)
if err != nil {
log.Fatal(err)
}
_, ipIE10, err := net.ParseCIDR(cidrIE10)
if err != nil {
log.Fatal(err)
}

// Define and insert the new data.
_, ipUS, err := net.ParseCIDR(cidrUS)
_, ipUS124, err := net.ParseCIDR(cidrUS127)
if err != nil {
log.Fatal(err)
}
_, ipUS10, err := net.ParseCIDR(cidrUS10)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -77,10 +87,16 @@ func createCityDB(dbName, dbType string) {
},
}

if err := writer.InsertFunc(ipIE, inserter.TopLevelMergeWith(recordIE)); err != nil {
if err := writer.InsertFunc(ipIE127, inserter.TopLevelMergeWith(recordIE)); err != nil {
log.Fatal(err)
}
if err := writer.InsertFunc(ipIE10, inserter.TopLevelMergeWith(recordIE)); err != nil {
log.Fatal(err)
}
if err := writer.InsertFunc(ipUS, inserter.TopLevelMergeWith(recordUS)); err != nil {
if err := writer.InsertFunc(ipUS124, inserter.TopLevelMergeWith(recordUS)); err != nil {
log.Fatal(err)
}
if err := writer.InsertFunc(ipUS10, inserter.TopLevelMergeWith(recordUS)); err != nil {
log.Fatal(err)
}

Expand All @@ -93,4 +109,5 @@ func createCityDB(dbName, dbType string) {
if err != nil {
log.Fatal(err)
}
}*/
}
*/
2 changes: 1 addition & 1 deletion coredns/plugin/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (z *Zone) parseWeightedAnswers(_ context.Context, _ request.Request, wrrs [
// parseGeoAnswers takes a slice of answers for a dns name and reduces it down to a single answer based on geo.
func (z *Zone) parseGeoAnswers(ctx context.Context, request request.Request, grrs []dns.RR) []dns.RR {
log.Debugf("parsing geo answers for %s", grrs[0].Header().Name)
log.Debugf("source ip is %s", request.IP())
var answer *dns.RR
var geoRRs []geodRR

Expand All @@ -182,7 +183,6 @@ func (z *Zone) parseGeoAnswers(ctx context.Context, request request.Request, grr
}

if geoRRs != nil {
// ToDo calculate answer here!!
geoCountryCode := metadata.ValueFunc(ctx, "geoip/country/code")
geoContinetCode := metadata.ValueFunc(ctx, "geoip/continent/code")
for _, geoRR := range geoRRs {
Expand Down
Loading