Fix dns_opnsense.sh for OPNsense 25.7 #6468
Open
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.
This PR fixes #6467.
Example API response value to test against:
In the following lines we want to search for "example.net" (secondy entry in the example API response above).
There are now additional values between
"type":"primary"
and"domainname":"<domain>"
in the API response.Therefore I added a
.*
in the_grep_o
regex string.Due to this and the current API response structure the grep result now not only contains the searched domain, but all others before it, too (=>
$string_with_searched_domain_and_others_before_it
).So, the "list entry" containing the searched domain is at the end of the string. Example:
We'd need to cut the string on the last occurence of a
{
(which is before theuuid
), but cut doesn't natively support that. To solve this, I reversed the string, then cut it on the first occurence of a{
, then reversed it again to get it back into the correct order.This selects only the last entry in the "list" from before, so only the domain we searched for (=>
$string_with_searched_domain_only
). Example:Then the UUID gets extracted from this string as before, no change from my side (
cut -d ':' -f 2 | cut -d '"' -f 2
).A test via the GitHub actions is not possible, as the OPNsense is a private instance only available in my internal network (as it should be).