Skip to content

Commit db50035

Browse files
authored
Merge pull request #5 from marten-seemann/fix-zone-requests
fix handling of zone requests
2 parents 1d1ebf5 + 2b27a0f commit db50035

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mysql.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ func (handler *CoreDNSMySql) findRecord(zone string, name string, types ...strin
1515
}
1616
defer db.Close()
1717

18-
query := strings.TrimSuffix(name, "." + zone)
18+
var query string
19+
if name != zone {
20+
query = strings.TrimSuffix(name, "."+zone)
21+
}
1922
sqlQuery := fmt.Sprintf("SELECT name, zone, ttl, record_type, content FROM %s WHERE zone = ? AND name = ? AND record_type IN ('%s')",
2023
handler.tableName,
2124
strings.Join(types, "','"))
@@ -37,12 +40,12 @@ func (handler *CoreDNSMySql) findRecord(zone string, name string, types ...strin
3740
}
3841

3942
records = append(records, &Record{
40-
Name: recordName,
41-
Zone: recordZone,
43+
Name: recordName,
44+
Zone: recordZone,
4245
RecordType: recordType,
43-
Ttl: ttl,
44-
Content: content,
45-
handler: handler,
46+
Ttl: ttl,
47+
Content: content,
48+
handler: handler,
4649
})
4750
}
4851

types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,8 @@ func split255(s string) []string {
327327
}
328328

329329
func (rec *Record) fqdn() string {
330+
if rec.Name == "" {
331+
return rec.Zone
332+
}
330333
return rec.Name + "." + rec.Zone
331334
}

0 commit comments

Comments
 (0)