Skip to content

Commit 6c63631

Browse files
authored
Merge pull request #389 from Kuadrant/coredns-geo
Update to the demo db
2 parents 641b09a + dd98e5f commit 6c63631

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed
203 Bytes
Binary file not shown.

coredns/examples/db-generator.go

+25-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import (
1212
)
1313
1414
const (
15-
cdirIE = "127.0.100.100/24"
16-
cidrUS = "127.0.200.200/24"
15+
cdirIE127 = "127.0.100.100/24"
16+
cidrIE10 = "10.89.100.100/24"
17+
18+
cidrUS127 = "127.0.200.200/24"
19+
cidrUS10 = "10.89.200.200/24"
1720
)
1821
1922
// Create new mmdb database fixtures in this directory.
@@ -32,13 +35,20 @@ func createCityDB(dbName, dbType string) {
3235
}
3336
3437
// Define and insert the new data.
35-
_, ipIE, err := net.ParseCIDR(cdirIE)
38+
_, ipIE127, err := net.ParseCIDR(cdirIE127)
39+
if err != nil {
40+
log.Fatal(err)
41+
}
42+
_, ipIE10, err := net.ParseCIDR(cidrIE10)
3643
if err != nil {
3744
log.Fatal(err)
3845
}
3946
40-
// Define and insert the new data.
41-
_, ipUS, err := net.ParseCIDR(cidrUS)
47+
_, ipUS124, err := net.ParseCIDR(cidrUS127)
48+
if err != nil {
49+
log.Fatal(err)
50+
}
51+
_, ipUS10, err := net.ParseCIDR(cidrUS10)
4252
if err != nil {
4353
log.Fatal(err)
4454
}
@@ -77,10 +87,16 @@ func createCityDB(dbName, dbType string) {
7787
},
7888
}
7989
80-
if err := writer.InsertFunc(ipIE, inserter.TopLevelMergeWith(recordIE)); err != nil {
90+
if err := writer.InsertFunc(ipIE127, inserter.TopLevelMergeWith(recordIE)); err != nil {
91+
log.Fatal(err)
92+
}
93+
if err := writer.InsertFunc(ipIE10, inserter.TopLevelMergeWith(recordIE)); err != nil {
8194
log.Fatal(err)
8295
}
83-
if err := writer.InsertFunc(ipUS, inserter.TopLevelMergeWith(recordUS)); err != nil {
96+
if err := writer.InsertFunc(ipUS124, inserter.TopLevelMergeWith(recordUS)); err != nil {
97+
log.Fatal(err)
98+
}
99+
if err := writer.InsertFunc(ipUS10, inserter.TopLevelMergeWith(recordUS)); err != nil {
84100
log.Fatal(err)
85101
}
86102
@@ -93,4 +109,5 @@ func createCityDB(dbName, dbType string) {
93109
if err != nil {
94110
log.Fatal(err)
95111
}
96-
}*/
112+
}
113+
*/

coredns/plugin/zone.go

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func (z *Zone) parseWeightedAnswers(_ context.Context, _ request.Request, wrrs [
170170
// parseGeoAnswers takes a slice of answers for a dns name and reduces it down to a single answer based on geo.
171171
func (z *Zone) parseGeoAnswers(ctx context.Context, request request.Request, grrs []dns.RR) []dns.RR {
172172
log.Debugf("parsing geo answers for %s", grrs[0].Header().Name)
173+
log.Debugf("source ip is %s", request.IP())
173174
var answer *dns.RR
174175
var geoRRs []geodRR
175176

0 commit comments

Comments
 (0)