zoneparsing improvment and log newline

This commit is contained in:
Niklas 2020-12-26 21:56:51 +01:00
parent 0da61804f7
commit 1771ca2a53

View File

@ -77,7 +77,7 @@ func loadConfig(configPath string) (*config, error) {
func loadZones(configZones []configZone) (zoneMap, error) { func loadZones(configZones []configZone) (zoneMap, error) {
zones := make(zoneMap) zones := make(zoneMap)
for _, z := range configZones { for _, z := range configZones {
rrs, err := loadZonefile(z.File) rrs, err := loadZonefile(z.File, z.Zone)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -111,14 +111,14 @@ func createRRMap(rrs []dns.RR) rrMap {
return rrMap return rrMap
} }
func loadZonefile(filepath string) ([]dns.RR, error) { func loadZonefile(filepath, origin string) ([]dns.RR, error) {
file, err := os.Open(filepath) file, err := os.Open(filepath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
parser := dns.NewZoneParser(file, "", "") parser := dns.NewZoneParser(file, origin, filepath)
var rrs = make([]dns.RR, 0) var rrs = make([]dns.RR, 0)
@ -160,7 +160,7 @@ func createServer(zones zoneMap, config config, aclList map[string]*net.IPNet) *
remoteIP, _, err := net.SplitHostPort(w.RemoteAddr().String()) remoteIP, _, err := net.SplitHostPort(w.RemoteAddr().String())
ip := net.ParseIP(remoteIP) ip := net.ParseIP(remoteIP)
if err != nil && ip != nil { if err != nil && ip != nil {
log.Printf("Faild to parse remote IP WTF? :%s", err.Error()) log.Printf("Faild to parse remote IP WTF? :%s\n", err.Error())
return return
} }
@ -188,7 +188,7 @@ func createServer(zones zoneMap, config config, aclList map[string]*net.IPNet) *
ip := net.ParseIP(remoteIP) ip := net.ParseIP(remoteIP)
if err != nil && ip != nil { if err != nil && ip != nil {
log.Printf("Faild to parse remote IP WTF? :%s", err.Error()) log.Printf("Faild to parse remote IP WTF? :%s\n", err.Error())
return return
} }