Skip to content

Commit

Permalink
chore(providers): change ttl type to uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 17, 2024
1 parent ca85596 commit d37f057
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions internal/provider/providers/cloudflare/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Provider struct {
userServiceKey string
zoneIdentifier string
proxied bool
ttl uint
ttl uint32
}

func New(data json.RawMessage, domain, host string,
Expand All @@ -44,7 +44,7 @@ func New(data json.RawMessage, domain, host string,
UserServiceKey string `json:"user_service_key"`
ZoneIdentifier string `json:"zone_identifier"`
Proxied bool `json:"proxied"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
Expand Down Expand Up @@ -243,7 +243,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net
Name string `json:"name"` // DNS record name i.e. example.com
Content string `json:"content"` // ip address
Proxied bool `json:"proxied"` // whether the record is receiving the performance and security benefits of Cloudflare
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{
Type: recordType,
Name: utils.BuildURLQueryHostname(p.host, p.domain),
Expand Down Expand Up @@ -335,7 +335,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
Name string `json:"name"` // DNS record name i.e. example.com
Content string `json:"content"` // ip address
Proxied bool `json:"proxied"` // whether the record is receiving the performance and security benefits of Cloudflare
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{
Type: recordType,
Name: utils.BuildURLQueryHostname(p.host, p.domain),
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/providers/gandi/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Provider struct {
host string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
ttl int
ttl uint32
// Authentication, either use the personal access token
// or the deprecated API key.
// See https://api.gandi.net/docs/authentication/
Expand All @@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string,
extraSettings := struct {
PersonalAccessToken string `json:"personal_access_token"`
APIKey string `json:"key"`
TTL int `json:"ttl"`
TTL uint32 `json:"ttl"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
Expand Down Expand Up @@ -118,14 +118,14 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add

buffer := bytes.NewBuffer(nil)
encoder := json.NewEncoder(buffer)
const defaultTTL = 3600
const defaultTTL uint32 = 3600
ttl := defaultTTL
if p.ttl != 0 {
ttl = p.ttl
}
requestData := struct {
Values [1]string `json:"rrset_values"`
TTL int `json:"rrset_ttl"`
TTL uint32 `json:"rrset_ttl"`
}{
Values: [1]string{ip.Unmap().String()},
TTL: ttl,
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/providers/gcp/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type recordResourceSet struct {
// Rrdatas, as defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)
Rrdatas []string `json:"rrdatas,omitempty"`
// TTL is the number of seconds that this RRSet can be cached by resolvers.
TTL int64 `json:"ttl"`
TTL uint32 `json:"ttl"`
// Type is the identifier of a record type. For example A or AAAA.
Type string `json:"type"`
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/providers/hetzner/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net
Name string `json:"name"`
Value string `json:"value"`
ZoneIdentifier string `json:"zone_id"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{
Type: recordType,
Name: p.host,
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/providers/hetzner/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Provider struct {
ipv6Suffix netip.Prefix
token string
zoneIdentifier string
ttl uint
ttl uint32
}

func New(data json.RawMessage, domain, host string,
Expand All @@ -31,7 +31,7 @@ func New(data json.RawMessage, domain, host string,
extraSettings := struct {
Token string `json:"token"`
ZoneIdentifier string `json:"zone_identifier"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/providers/hetzner/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client,
Name string `json:"name"`
Value string `json:"value"`
ZoneIdentifier string `json:"zone_id"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{
Type: recordType,
Name: p.host,
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/providers/luadns/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type luaDNSRecord struct {
Name string `json:"name"`
Type string `json:"type"`
Content string `json:"content"`
TTL int `json:"ttl"`
TTL uint32 `json:"ttl"`
}

type luaDNSError struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/providers/porkbun/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Provider struct {
host string
ipVersion ipversion.IPVersion
ipv6Suffix netip.Prefix
ttl uint
ttl uint32
apiKey string
secretAPIKey string
}
Expand All @@ -31,7 +31,7 @@ func New(data json.RawMessage, domain, host string,
extraSettings := struct {
SecretAPIKey string `json:"secret_api_key"`
APIKey string `json:"api_key"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{}
err = json.Unmarshal(data, &extraSettings)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/providers/servercow/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ type Provider struct {
username string
password string
useProviderIP bool
ttl uint
ttl uint32
}

func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
p *Provider, err error) {
extraSettings := struct {
Username string `json:"username"`
Password string `json:"password"`
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
UseProviderIP bool `json:"provider_ip"`
}{}
err = json.Unmarshal(data, &extraSettings)
Expand Down Expand Up @@ -128,7 +128,7 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
Type string `json:"type"` // constants.A or constants.AAAA depending on ip address given
Name string `json:"name"` // DNS record name (only the subdomain part)
Content string `json:"content"` // ip address
TTL uint `json:"ttl"`
TTL uint32 `json:"ttl"`
}{
Type: recordType,
Name: updateHost,
Expand Down

0 comments on commit d37f057

Please sign in to comment.