Skip to content

Commit

Permalink
Changed response decoding to the correct struct. closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrobison committed Mar 11, 2018
1 parent 23b0e61 commit 8335088
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *cloudflareManager) updateDNSRecord(record cloudflareDNSRecord, ipAddres
logger.Fatalln(err)
}
defer dnsResponse.Body.Close()
var updatedRecord cloudflareDNSResponse
var updatedRecord cloudflareDNSUpdateResponse
err = json.NewDecoder(dnsResponse.Body).Decode(&updatedRecord)
if err != nil {
logger.Fatalln(err)
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ func handleInterrupt(signalChannel chan os.Signal, cfm *cloudflareManager) {
func updateCloudflareRecord(cfm *cloudflareManager) {

// Get an updated record
updatedIpAddress, err := getCurrentIPAddress(cfm.Client)
updatedIPAddress, err := getCurrentIPAddress(cfm.Client)
if err != nil {
logger.Println(err)
return
}

if updatedIpAddress != cfm.CurrentIPAddress {
logger.Printf("IP Address changed from %v, to %v\n", cfm.CurrentIPAddress, updatedIpAddress)
cfm.CurrentIPAddress = updatedIpAddress
if updatedIPAddress != cfm.CurrentIPAddress {
logger.Printf("IP Address changed from %v, to %v\n", cfm.CurrentIPAddress, updatedIPAddress)
cfm.CurrentIPAddress = updatedIPAddress

// Get the cloudflare DNS records
records, err := cfm.GetDNSRecords()
Expand Down
2 changes: 1 addition & 1 deletion structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type cloudflareDNSResponse struct {

type cloudflareDNSUpdateResponse struct {
cloudflareResponse
Result map[string]interface{}
Result cloudflareDNSRecord
}

type newCloudflareDNSRecord struct {
Expand Down

0 comments on commit 8335088

Please sign in to comment.