fix: fix logic on p.Data.Ip
All checks were successful
golangci-lint / lint (push) Successful in 41s

This commit is contained in:
Fijxu 2025-02-05 17:00:28 -03:00
parent 303193751b
commit 3a2be02e0a
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4

View file

@ -89,6 +89,12 @@ func getIpAddress() string {
func (p *Porkbun) updateIp() { func (p *Porkbun) updateIp() {
dnsIp, err := resolver.LookupHost(context.Background(), p.Domain) dnsIp, err := resolver.LookupHost(context.Background(), p.Domain)
p.Data.Ip = getIpAddress()
if p.Data.Ip == "" {
log.Print("Failed to retrieve current public IP address")
return
}
if err != nil { if err != nil {
log.Print("Failed to retrieve IP address for domain " + p.Domain + ": " + err.Error()) log.Print("Failed to retrieve IP address for domain " + p.Domain + ": " + err.Error())
return return
@ -102,12 +108,6 @@ func (p *Porkbun) updateIp() {
} }
log.Print("Current IP of the record '" + p.Domain + "' is " + dnsIp[0]) log.Print("Current IP of the record '" + p.Domain + "' is " + dnsIp[0])
p.Data.Ip = getIpAddress()
if p.Data.Ip == "" {
log.Print("Failed to retrieve current public IP address")
return
}
// Porkbun uses a string for the `"ttl"` key. // Porkbun uses a string for the `"ttl"` key.
p.Data.Ttl = string(p.Ttl) p.Data.Ttl = string(p.Ttl)
p.Data.ApiKey = &p.ApiKey p.Data.ApiKey = &p.ApiKey