Skip to content

Commit d85ab13

Browse files
author
pry0cc
committed
added serious error checking hehe
1 parent 99ed61e commit d85ab13

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,18 @@ func ParseDnsx(filename string) map[string][]string {
132132
var result map[string]interface{}
133133
json.Unmarshal([]byte(scanner.Text()), &result)
134134
host := result["host"].(string)
135-
aRecords := result["a"].([]interface{})
136-
ip := ""
137135

138-
for _, record := range aRecords {
139-
ip = record.(string)
140-
}
136+
if val, ok := result["a"]; ok {
137+
aRecords := val.([]interface{})
138+
139+
ip := ""
141140

142-
data[ip] = append(data[ip], host)
141+
for _, record := range aRecords {
142+
ip = record.(string)
143+
}
144+
145+
data[ip] = append(data[ip], host)
146+
}
143147
}
144148

145149
if err := scanner.Err(); err != nil {

0 commit comments

Comments
 (0)