Skip to content
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

Deterministic ordering for CF_SINGLE_REDIRECT records #3150

Open
tlimoncelli opened this issue Oct 9, 2024 · 2 comments
Open

Deterministic ordering for CF_SINGLE_REDIRECT records #3150

tlimoncelli opened this issue Oct 9, 2024 · 2 comments

Comments

@tlimoncelli
Copy link
Contributor

Is your feature request related to a problem? Please describe.

We would like to control the order of CF_SINGLE_REDIRECT records.

For example, we might want to have redirects that match on:

          foo.com/bar?query=bang     redirects to X
          foo.com/*                  redirects to Y
          foo.com/                   redirects to Z

If we can't control the order, there's a chance everything gets redirected to "Z" because foo.com/

Describe the solution you'd like

The easy way would be for DNSControl to just abide by the order they appear in dnsconfig.js. The code might already do this.

@blackshadev: Is there any reason this might not be the case? Could you verify?

Describe alternatives you've considered

The hard way would be to add metadata for each record that lists a priority, and have dnssort/dnsgraph sort by that priority.

It would look something like this:

      CF_SINGLE_REDIRECT("foo", "bar", { priority: 1 } ),
      CF_SINGLE_REDIRECT("foo", "bar", { priority: 2 } ),

Additional context

CF_SINGLE_REDIRECT is described here:
https://docs.dnscontrol.org/language-reference/domain-modifiers/service-provider-specific/cloudflare-dns/cf_single_redirect

@blackshadev
Copy link
Contributor

There shouldn't be a reason for this to conflict with the recording, and I think you can add it quite easily. As long as you can group all of these "prioritized" records together.

The reordering algorithm adds changes to the record set based on the resolved dependencies of the records. Currently the only record types with dependencies are "NS", "SRV", "CNAME", "MX", "ALIAS", "AZURE_ALIAS", "R53_ALIAS" (see record.go:432). I am unsure if you can reuse the original ordering, because depending on the diff2 type you do not know the original ordering anymore. That was one of the reasons for me to start the reordering algorithm.

@tlimoncelli
Copy link
Contributor Author

Thanks for explaining that!

I now I've had more time to think about this, the Cloudflare "rule id" is unrelated to the order that the changes are done during "push". This becomes easier to implement than I had previously thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants