mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 08:54:09 -04:00
chore(providers): change ttl type to uint32
This commit is contained in:
@@ -31,7 +31,7 @@ type Provider struct {
|
|||||||
userServiceKey string
|
userServiceKey string
|
||||||
zoneIdentifier string
|
zoneIdentifier string
|
||||||
proxied bool
|
proxied bool
|
||||||
ttl uint
|
ttl uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(data json.RawMessage, domain, host string,
|
func New(data json.RawMessage, domain, host string,
|
||||||
@@ -44,7 +44,7 @@ func New(data json.RawMessage, domain, host string,
|
|||||||
UserServiceKey string `json:"user_service_key"`
|
UserServiceKey string `json:"user_service_key"`
|
||||||
ZoneIdentifier string `json:"zone_identifier"`
|
ZoneIdentifier string `json:"zone_identifier"`
|
||||||
Proxied bool `json:"proxied"`
|
Proxied bool `json:"proxied"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{}
|
}{}
|
||||||
err = json.Unmarshal(data, &extraSettings)
|
err = json.Unmarshal(data, &extraSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -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
|
Name string `json:"name"` // DNS record name i.e. example.com
|
||||||
Content string `json:"content"` // ip address
|
Content string `json:"content"` // ip address
|
||||||
Proxied bool `json:"proxied"` // whether the record is receiving the performance and security benefits of Cloudflare
|
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,
|
Type: recordType,
|
||||||
Name: utils.BuildURLQueryHostname(p.host, p.domain),
|
Name: utils.BuildURLQueryHostname(p.host, p.domain),
|
||||||
@@ -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
|
Name string `json:"name"` // DNS record name i.e. example.com
|
||||||
Content string `json:"content"` // ip address
|
Content string `json:"content"` // ip address
|
||||||
Proxied bool `json:"proxied"` // whether the record is receiving the performance and security benefits of Cloudflare
|
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,
|
Type: recordType,
|
||||||
Name: utils.BuildURLQueryHostname(p.host, p.domain),
|
Name: utils.BuildURLQueryHostname(p.host, p.domain),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type Provider struct {
|
|||||||
host string
|
host string
|
||||||
ipVersion ipversion.IPVersion
|
ipVersion ipversion.IPVersion
|
||||||
ipv6Suffix netip.Prefix
|
ipv6Suffix netip.Prefix
|
||||||
ttl int
|
ttl uint32
|
||||||
// Authentication, either use the personal access token
|
// Authentication, either use the personal access token
|
||||||
// or the deprecated API key.
|
// or the deprecated API key.
|
||||||
// See https://api.gandi.net/docs/authentication/
|
// See https://api.gandi.net/docs/authentication/
|
||||||
@@ -38,7 +38,7 @@ func New(data json.RawMessage, domain, host string,
|
|||||||
extraSettings := struct {
|
extraSettings := struct {
|
||||||
PersonalAccessToken string `json:"personal_access_token"`
|
PersonalAccessToken string `json:"personal_access_token"`
|
||||||
APIKey string `json:"key"`
|
APIKey string `json:"key"`
|
||||||
TTL int `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{}
|
}{}
|
||||||
err = json.Unmarshal(data, &extraSettings)
|
err = json.Unmarshal(data, &extraSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -118,14 +118,14 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
|
|||||||
|
|
||||||
buffer := bytes.NewBuffer(nil)
|
buffer := bytes.NewBuffer(nil)
|
||||||
encoder := json.NewEncoder(buffer)
|
encoder := json.NewEncoder(buffer)
|
||||||
const defaultTTL = 3600
|
const defaultTTL uint32 = 3600
|
||||||
ttl := defaultTTL
|
ttl := defaultTTL
|
||||||
if p.ttl != 0 {
|
if p.ttl != 0 {
|
||||||
ttl = p.ttl
|
ttl = p.ttl
|
||||||
}
|
}
|
||||||
requestData := struct {
|
requestData := struct {
|
||||||
Values [1]string `json:"rrset_values"`
|
Values [1]string `json:"rrset_values"`
|
||||||
TTL int `json:"rrset_ttl"`
|
TTL uint32 `json:"rrset_ttl"`
|
||||||
}{
|
}{
|
||||||
Values: [1]string{ip.Unmap().String()},
|
Values: [1]string{ip.Unmap().String()},
|
||||||
TTL: ttl,
|
TTL: ttl,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type recordResourceSet struct {
|
|||||||
// Rrdatas, as defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)
|
// Rrdatas, as defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)
|
||||||
Rrdatas []string `json:"rrdatas,omitempty"`
|
Rrdatas []string `json:"rrdatas,omitempty"`
|
||||||
// TTL is the number of seconds that this RRSet can be cached by resolvers.
|
// 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 is the identifier of a record type. For example A or AAAA.
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (p *Provider) createRecord(ctx context.Context, client *http.Client, ip net
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
ZoneIdentifier string `json:"zone_id"`
|
ZoneIdentifier string `json:"zone_id"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{
|
}{
|
||||||
Type: recordType,
|
Type: recordType,
|
||||||
Name: p.host,
|
Name: p.host,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type Provider struct {
|
|||||||
ipv6Suffix netip.Prefix
|
ipv6Suffix netip.Prefix
|
||||||
token string
|
token string
|
||||||
zoneIdentifier string
|
zoneIdentifier string
|
||||||
ttl uint
|
ttl uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(data json.RawMessage, domain, host string,
|
func New(data json.RawMessage, domain, host string,
|
||||||
@@ -31,7 +31,7 @@ func New(data json.RawMessage, domain, host string,
|
|||||||
extraSettings := struct {
|
extraSettings := struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
ZoneIdentifier string `json:"zone_identifier"`
|
ZoneIdentifier string `json:"zone_identifier"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{}
|
}{}
|
||||||
err = json.Unmarshal(data, &extraSettings)
|
err = json.Unmarshal(data, &extraSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func (p *Provider) updateRecord(ctx context.Context, client *http.Client,
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
ZoneIdentifier string `json:"zone_id"`
|
ZoneIdentifier string `json:"zone_id"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{
|
}{
|
||||||
Type: recordType,
|
Type: recordType,
|
||||||
Name: p.host,
|
Name: p.host,
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ type luaDNSRecord struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
TTL int `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type luaDNSError struct {
|
type luaDNSError struct {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type Provider struct {
|
|||||||
host string
|
host string
|
||||||
ipVersion ipversion.IPVersion
|
ipVersion ipversion.IPVersion
|
||||||
ipv6Suffix netip.Prefix
|
ipv6Suffix netip.Prefix
|
||||||
ttl uint
|
ttl uint32
|
||||||
apiKey string
|
apiKey string
|
||||||
secretAPIKey string
|
secretAPIKey string
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ func New(data json.RawMessage, domain, host string,
|
|||||||
extraSettings := struct {
|
extraSettings := struct {
|
||||||
SecretAPIKey string `json:"secret_api_key"`
|
SecretAPIKey string `json:"secret_api_key"`
|
||||||
APIKey string `json:"api_key"`
|
APIKey string `json:"api_key"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{}
|
}{}
|
||||||
err = json.Unmarshal(data, &extraSettings)
|
err = json.Unmarshal(data, &extraSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type Provider struct {
|
|||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
useProviderIP bool
|
useProviderIP bool
|
||||||
ttl uint
|
ttl uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
|
func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersion, ipv6Suffix netip.Prefix) (
|
||||||
@@ -34,7 +34,7 @@ func New(data json.RawMessage, domain, host string, ipVersion ipversion.IPVersio
|
|||||||
extraSettings := struct {
|
extraSettings := struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
UseProviderIP bool `json:"provider_ip"`
|
UseProviderIP bool `json:"provider_ip"`
|
||||||
}{}
|
}{}
|
||||||
err = json.Unmarshal(data, &extraSettings)
|
err = json.Unmarshal(data, &extraSettings)
|
||||||
@@ -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
|
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)
|
Name string `json:"name"` // DNS record name (only the subdomain part)
|
||||||
Content string `json:"content"` // ip address
|
Content string `json:"content"` // ip address
|
||||||
TTL uint `json:"ttl"`
|
TTL uint32 `json:"ttl"`
|
||||||
}{
|
}{
|
||||||
Type: recordType,
|
Type: recordType,
|
||||||
Name: updateHost,
|
Name: updateHost,
|
||||||
|
|||||||
Reference in New Issue
Block a user