-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLOUDFLAREAPI: Enable CanUseLOC #2799
Draft
ConnorMcF
wants to merge
3
commits into
StackExchange:main
Choose a base branch
from
ConnorMcF:cloudflareapi-loc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+125
−26
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,40 +95,65 @@ type RecordConfig struct { | |
|
||
// If you add a field to this struct, also add it to the list in the UnmarshalJSON function. | ||
MxPreference uint16 `json:"mxpreference,omitempty"` | ||
|
||
SrvPriority uint16 `json:"srvpriority,omitempty"` | ||
SrvWeight uint16 `json:"srvweight,omitempty"` | ||
SrvPort uint16 `json:"srvport,omitempty"` | ||
|
||
CaaTag string `json:"caatag,omitempty"` | ||
CaaFlag uint8 `json:"caaflag,omitempty"` | ||
|
||
DsKeyTag uint16 `json:"dskeytag,omitempty"` | ||
DsAlgorithm uint8 `json:"dsalgorithm,omitempty"` | ||
DsDigestType uint8 `json:"dsdigesttype,omitempty"` | ||
DsDigest string `json:"dsdigest,omitempty"` | ||
|
||
LocVersion uint8 `json:"locversion,omitempty"` | ||
LocSize uint8 `json:"locsize,omitempty"` | ||
LocHorizPre uint8 `json:"lochorizpre,omitempty"` | ||
LocVertPre uint8 `json:"locvertpre,omitempty"` | ||
LocLatitude uint32 `json:"loclatitude,omitempty"` | ||
LocLongitude uint32 `json:"loclongitude,omitempty"` | ||
LocAltitude uint32 `json:"localtitude,omitempty"` | ||
|
||
LocLatDegrees uint8 `json:"loclatdegrees,omitempty"` | ||
LocLatMinutes uint8 `json:"lotlatminutes,omitempty"` | ||
LocLatSeconds float32 `json:"loclatseconds,omitempty"` | ||
LocLatDirection string `json:"loclatdirection,omitempty"` | ||
LocLongDegrees uint8 `json:"loclongdegrees,omitempty"` | ||
LocLongMinutes uint8 `json:"lotlongminutes,omitempty"` | ||
LocLongSeconds float32 `json:"loclongseconds,omitempty"` | ||
LocLongDirection string `json:"loclongdirection,omitempty"` | ||
|
||
LocOrigAltitude int32 `json:"locorigaltitude,omitempty"` | ||
LocOrigSize float32 `json:"locorigsize,omitempty"` | ||
LocOrigHorizPre float32 `json:"locorighorizpre,omitempty"` | ||
LocOrigVertPre float32 `json:"locorigvertpre,omitempty"` | ||
|
||
NaptrOrder uint16 `json:"naptrorder,omitempty"` | ||
NaptrPreference uint16 `json:"naptrpreference,omitempty"` | ||
NaptrFlags string `json:"naptrflags,omitempty"` | ||
NaptrService string `json:"naptrservice,omitempty"` | ||
NaptrRegexp string `json:"naptrregexp,omitempty"` | ||
|
||
SshfpAlgorithm uint8 `json:"sshfpalgorithm,omitempty"` | ||
SshfpFingerprint uint8 `json:"sshfpfingerprint,omitempty"` | ||
|
||
SoaMbox string `json:"soambox,omitempty"` | ||
SoaSerial uint32 `json:"soaserial,omitempty"` | ||
SoaRefresh uint32 `json:"soarefresh,omitempty"` | ||
SoaRetry uint32 `json:"soaretry,omitempty"` | ||
SoaExpire uint32 `json:"soaexpire,omitempty"` | ||
SoaMinttl uint32 `json:"soaminttl,omitempty"` | ||
|
||
TlsaUsage uint8 `json:"tlsausage,omitempty"` | ||
TlsaSelector uint8 `json:"tlsaselector,omitempty"` | ||
TlsaMatchingType uint8 `json:"tlsamatchingtype,omitempty"` | ||
|
||
R53Alias map[string]string `json:"r53_alias,omitempty"` | ||
|
||
AzureAlias map[string]string `json:"azure_alias,omitempty"` | ||
|
||
UnknownTypeName string `json:"unknown_type_name,omitempty"` | ||
} | ||
|
||
|
@@ -163,40 +188,65 @@ func (rc *RecordConfig) UnmarshalJSON(b []byte) error { | |
Original interface{} `json:"-"` // Store pointer to provider-specific record object. Used in diffing. | ||
|
||
MxPreference uint16 `json:"mxpreference,omitempty"` | ||
|
||
SrvPriority uint16 `json:"srvpriority,omitempty"` | ||
SrvWeight uint16 `json:"srvweight,omitempty"` | ||
SrvPort uint16 `json:"srvport,omitempty"` | ||
|
||
CaaTag string `json:"caatag,omitempty"` | ||
CaaFlag uint8 `json:"caaflag,omitempty"` | ||
|
||
DsKeyTag uint16 `json:"dskeytag,omitempty"` | ||
DsAlgorithm uint8 `json:"dsalgorithm,omitempty"` | ||
DsDigestType uint8 `json:"dsdigesttype,omitempty"` | ||
DsDigest string `json:"dsdigest,omitempty"` | ||
|
||
LocVersion uint8 `json:"locversion,omitempty"` | ||
LocSize uint8 `json:"locsize,omitempty"` | ||
LocHorizPre uint8 `json:"lochorizpre,omitempty"` | ||
LocVertPre uint8 `json:"locvertpre,omitempty"` | ||
LocLatitude int `json:"loclatitude,omitempty"` | ||
LocLongitude int `json:"loclongitude,omitempty"` | ||
LocAltitude uint32 `json:"localtitude,omitempty"` | ||
|
||
LocLatDegrees uint8 `json:"loclatdegrees,omitempty"` | ||
LocLatMinutes uint8 `json:"lotlatminutes,omitempty"` | ||
LocLatSeconds float32 `json:"loclatseconds,omitempty"` | ||
LocLatDirection string `json:"loclatdirection,omitempty"` | ||
LocLongDegrees uint8 `json:"loclongdegrees,omitempty"` | ||
LocLongMinutes uint8 `json:"lotlongminutes,omitempty"` | ||
LocLongSeconds float32 `json:"loclongseconds,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't see the LOC records at cloud flare link. So we assume only seconds will take decimal fractions ie floats. Degrees and minutes are whole integers. |
||
LocLongDirection string `json:"loclongdirection,omitempty"` | ||
|
||
LocOrigAltitude int32 `json:"locorigaltitude,omitempty"` | ||
LocOrigSize float32 `json:"locorigsize,omitempty"` | ||
LocOrigHorizPre float32 `json:"locorighorizpre,omitempty"` | ||
LocOrigVertPre float32 `json:"locorigvertpre,omitempty"` | ||
|
||
NaptrOrder uint16 `json:"naptrorder,omitempty"` | ||
NaptrPreference uint16 `json:"naptrpreference,omitempty"` | ||
NaptrFlags string `json:"naptrflags,omitempty"` | ||
NaptrService string `json:"naptrservice,omitempty"` | ||
NaptrRegexp string `json:"naptrregexp,omitempty"` | ||
|
||
SshfpAlgorithm uint8 `json:"sshfpalgorithm,omitempty"` | ||
SshfpFingerprint uint8 `json:"sshfpfingerprint,omitempty"` | ||
|
||
SoaMbox string `json:"soambox,omitempty"` | ||
SoaSerial uint32 `json:"soaserial,omitempty"` | ||
SoaRefresh uint32 `json:"soarefresh,omitempty"` | ||
SoaRetry uint32 `json:"soaretry,omitempty"` | ||
SoaExpire uint32 `json:"soaexpire,omitempty"` | ||
SoaMinttl uint32 `json:"soaminttl,omitempty"` | ||
|
||
TlsaUsage uint8 `json:"tlsausage,omitempty"` | ||
TlsaSelector uint8 `json:"tlsaselector,omitempty"` | ||
TlsaMatchingType uint8 `json:"tlsamatchingtype,omitempty"` | ||
|
||
R53Alias map[string]string `json:"r53_alias,omitempty"` | ||
|
||
AzureAlias map[string]string `json:"azure_alias,omitempty"` | ||
|
||
UnknownTypeName string `json:"unknown_type_name,omitempty"` | ||
|
||
EnsureAbsent bool `json:"ensure_absent,omitempty"` // Override NO_PURGE and delete this record | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this provider need new fields when multiple providers already support LOC without needing the extra fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Cloudflare API requires the original degrees, minutes, seconds values whereas to my knowledge the LOC model converts to decimal degrees, which doesn't fit into the request data Cloudflare asks for.
I'm trying to pass through both the DD and the original DMS values to the provider to allow either to be used.
https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-create-dns-record (Body -> LOC Record)
I may be wrong here, or there may be a better way about this - but this is just what I've come to so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! So if I understand it correctly: Some of the fields are what the user input. Those inputs are then massaged and stored as another set of fields.
If that's the situation, then please be clear in the comments which are the user-input fields and which are the derived fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to have RecordConfig contain a field called LOC which is a pointer to a LOCConfig. All those fields would be moved to LOCConfig. That would conserve memory. (You don't have to make this change right now. First let's see if the extra RAM causes problems. If we really want to save memory, we should come up with a solution that works for Naptr, Loc, and other fields too.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Tim. I recall implementing LOC for what was necessary in the final result. I referenced the original RFC. There are several ways to write coordinates, with a few which are commonly accepted everywhere. I tried handling the common ones in the js import, so there might need to be a bit of work there also. So be mindful of the import process done via the Javascript files (and test coverage) if those routes are necessary.
Might not be a bad idea to pass through components from the original js config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to my original commit or PR to find the js bits. Good to see Cloud Flare filling out their portfolio with LOC. 🥳