fixed bug ignoring proxy status on record creation

This commit is contained in:
Austin Archer 2024-11-25 00:41:33 -08:00
parent 4ae17d2348
commit 960c6b621c
2 changed files with 6 additions and 11 deletions

View file

@ -53,6 +53,7 @@ func checkAndUpdate(
Name: domain.Hostname, Name: domain.Hostname,
Content: address, Content: address,
Type: recordType, Type: recordType,
Proxied: domain.Proxied,
}) })
if err != nil { if err != nil {
return err return err
@ -70,7 +71,7 @@ func checkAndUpdate(
ctxTimeout, cancel = context.WithTimeout(ctx, timeout) ctxTimeout, cancel = context.WithTimeout(ctx, timeout)
defer cancel() defer cancel()
if record.Content == address { if record.Content == address && (record.Proxied == nil || domain.Proxied == nil || (*record.Proxied == *domain.Proxied)) {
log.Info(). log.Info().
Str("id", record.ID). Str("id", record.ID).
Str("hostname", record.Name). Str("hostname", record.Name).

View file

@ -23,12 +23,9 @@ func loop(ctx context.Context, api *cloudflare.API, cfg *config.Config) {
}() }()
if cfg.IPv4 { if cfg.IPv4 {
ipv4, err := GetPublicIPv4() if ipv4, err := GetPublicIPv4(); err != nil {
if err != nil {
log.Panic().Err(err).Msg("failed to get public ipv4") log.Panic().Err(err).Msg("failed to get public ipv4")
} } else if ipv4 != currentIPv4 {
if ipv4 != currentIPv4 {
currentIPv4 = ipv4 currentIPv4 = ipv4
log.Info().Msgf("updated ipv4 address: %s", ipv4) log.Info().Msgf("updated ipv4 address: %s", ipv4)
} }
@ -45,12 +42,9 @@ func loop(ctx context.Context, api *cloudflare.API, cfg *config.Config) {
} }
if cfg.IPv6 { if cfg.IPv6 {
ipv6, err := GetPublicIPv6() if ipv6, err := GetPublicIPv6(); err != nil {
if err != nil {
log.Panic().Err(err).Msg("failed to get public ipv6") log.Panic().Err(err).Msg("failed to get public ipv6")
} } else if ipv6 != currentIPv6 {
if ipv6 != currentIPv6 {
currentIPv6 = ipv6 currentIPv6 = ipv6
log.Info().Msgf("updated ipv6 address: %s", ipv6) log.Info().Msgf("updated ipv6 address: %s", ipv6)
} }