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

New Feature: HASH() adds hashing functions to dnsconfig.js language #3085

Merged

Conversation

fuero
Copy link
Contributor

@fuero fuero commented Aug 16, 2024

Having access to SHA1 would be great when managing catalog zones:

foo_name_suffix = HASH("sha1", "foo.name") + "zones"
D("catalog.example!int"
    , REG_NONE
	, DnsProvider(my_pdns_int)
    , TXT("version", "2")
    , PTR(foo_name_suffix, "foo.name.")
    , A("primaries.ext." + foo_name_suffix, "192.168.1.1")
)

So this PR adds a HASH function to Javascript following the above example.

@tlimoncelli
Copy link
Contributor

Sounds like a reasonable feature to add.

Some changes I'd like to see in the PR:

@fuero
Copy link
Contributor Author

fuero commented Aug 19, 2024

Thanks for the feedback, I've added your suggestions.

@tlimoncelli
Copy link
Contributor

Looks great! Thanks for the fast response.

Please run go generate ./... to regenerate the docs. (I forgot to mention that)

CC @cafferata to review the docs.

@cafferata
Copy link
Collaborator

CC @cafferata to review the docs.

@tlimoncelli, thanks for the mention.

@fuero, this new hash() function must be included within the table of content:

* [FETCH](language-reference/top-level-functions/FETCH.md)
* [IP](language-reference/top-level-functions/IP.md)
* [NewDnsProvider](language-reference/top-level-functions/NewDnsProvider.md)
* [NewRegistrar](language-reference/top-level-functions/NewRegistrar.md)
* [PANIC](language-reference/top-level-functions/PANIC.md)
* [REV](language-reference/top-level-functions/REV.md)

- algorithm
- value
parameter_types:
algorithm: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could provide TypeScript autocomplete with the possible algorithm:

Suggested change
algorithm: string
algorithm: '"SHA1" | "SHA256" | "SHA512"'

@fuero
Copy link
Contributor Author

fuero commented Aug 19, 2024

@cafferata done, thanks!

@cafferata
Copy link
Collaborator

Great when feedback is processed so quickly. Thank you. If you would like to view the preview yourself, you can do so at the URL below:

https://docs.dnscontrol.org/~/revisions/4tbkwLMlJN3iIh1FDebG/language-reference/top-level-functions/hash

@tlimoncelli
Copy link
Contributor

Looks good to me! Thanks for adding this feature!

@tlimoncelli tlimoncelli changed the title New Feature: expose hashing functions to JS New Feature: HASH() adds hashing functions to dnsconfig.js language Aug 21, 2024
@tlimoncelli tlimoncelli merged commit 94a0cfc into StackExchange:main Aug 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants