forked from StackExchange/dnscontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This unifies the logic for handling the dnscontrol-default TTL, and frees up the TTL value 0 for use by providers (e.g. Linode, which uses it as its sentinel for its default TTL). Closes StackExchange#2444.
- Loading branch information
Showing
78 changed files
with
369 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package models | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
) | ||
|
||
func TestRR(t *testing.T) { | ||
experiment := RecordConfig{ | ||
Type: "A", | ||
Name: "foo", | ||
NameFQDN: "foo.example.com", | ||
target: "1.2.3.4", | ||
TTL: 0, | ||
TTL: EmptyTTL(), | ||
MxPreference: 0, | ||
} | ||
expected := "foo.example.com.\t300\tIN\tA\t1.2.3.4" | ||
|
@@ -22,7 +24,7 @@ func TestRR(t *testing.T) { | |
Name: "@", | ||
NameFQDN: "example.com", | ||
target: "mailto:[email protected]", | ||
TTL: 300, | ||
TTL: NewTTL(300), | ||
CaaTag: "iodef", | ||
CaaFlag: 1, | ||
} | ||
|
@@ -37,7 +39,7 @@ func TestRR(t *testing.T) { | |
Name: "@", | ||
NameFQDN: "_443._tcp.example.com", | ||
target: "abcdef0123456789", | ||
TTL: 300, | ||
TTL: NewTTL(300), | ||
TlsaUsage: 0, | ||
TlsaSelector: 0, | ||
TlsaMatchingType: 1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package models | ||
|
||
// TTL implements an optional TTL field, with a default of DefaultTTL. | ||
type TTL struct { | ||
value *uint32 | ||
} | ||
|
||
func NewTTL(ttl uint32) TTL { | ||
value := new(uint32) | ||
*value = ttl | ||
return TTL{ | ||
value, | ||
} | ||
} | ||
|
||
// EmptyTTL returns a new TTL without an explicit value. | ||
func EmptyTTL() TTL { | ||
return TTL{ | ||
value: nil, | ||
} | ||
} | ||
|
||
func (ttl TTL) IsSet() bool { | ||
return ttl.value != nil | ||
} | ||
|
||
func (ttl TTL) Value() uint32 { | ||
if ttl.IsSet() { | ||
return *ttl.value | ||
} else { | ||
return DefaultTTL | ||
} | ||
} | ||
|
||
func (ttl *TTL) ValueRef() *uint32 { | ||
if ttl.IsSet() { | ||
return ttl.value | ||
} else { | ||
defaultTTL := new(uint32) | ||
*defaultTTL = DefaultTTL | ||
return defaultTTL | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.