Skip to content

Commit

Permalink
fix for check missing record
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnoyes committed Dec 6, 2023
1 parent b62d601 commit 30a14a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ func reconcileExistingDNS(cli *client.Client){
}

func getExistingDNS(pihole_url string) ([][]string, error) {

// Make the API request to get existing DNS entries
apiURL := pihole_url + "?customdns"
if defaultTargetIP == "" {
apiURL = pihole_url + "?customcname"
}
apiURL += "&auth=" + authCode
apiURL += "&action=get"
resp, err := http.Get(apiURL)
Expand Down Expand Up @@ -207,8 +211,12 @@ func checkExistingContainers(pihole_url string, cli *client.Client, existingDNS

func isDNSMissing(labelValue string, existingDNS [][]string) bool {
// Check if the DNS entry already exists
searchRecord := defaultTargetIP
if defaultTargetIP == "" {
searchRecord = defaultTargetDomain
}
for _, existing := range existingDNS {
if len(existing) == 2 && existing[0] == labelValue && existing[1] == defaultTargetIP {
if len(existing) == 2 && existing[0] == labelValue && existing[1] == searchRecord {
return false
}
}
Expand Down

0 comments on commit 30a14a9

Please sign in to comment.