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

dnsdist: Add Lua bindings for PB requestorID, deviceName and deviceID #12615

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

rgacogne
Copy link
Member

@rgacogne rgacogne commented Mar 3, 2023

Short description

I forgot to add these before, and they are already used by the recursor.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

Copy link
Member

@omoerbeek omoerbeek left a comment

Choose a reason for hiding this comment

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

Two remarks, reads good.


.. versionadded:: 1.8.0

The identifier of the requestor, which will be exported via ProtoBuf if set.
Copy link
Member

Choose a reason for hiding this comment

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

in the from field.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that in the requestorId field?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, right. I mixed that field up with d_requestor used in the m.setRequest call. These names are too similar :-(

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, requestorId did not exist initially but now it's confusing indeed.

void dnsdist_ffi_dnsquestion_set_requestor_id(dnsdist_ffi_dnsquestion_t* dq, const char* value, size_t valueSize)
{
if (!dq || !dq->dq || !value) {
return;
Copy link
Member

Choose a reason for hiding this comment

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

I do not like this "do nothing silently" much. Wouldn't be better to indicate failure to set with a bool return value? I see that this void return value for setters is common, so something for the future to consider. Another thing to consider: the testing for dq and dq->value is not done in all setters.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree this isn't great. We have added these checks after noticing that crashing dnsdist because of a typo in the Lua code was terrible (a nil value becomes a nullptr).
Yielding an exception in the FFI API doesn't work well at the moment, so we could indeed return a boolean instead, but it would make handling the potential errors in the Lua code quite cumbersome.

@rgacogne rgacogne merged commit 97ec89c into PowerDNS:master Mar 8, 2023
@rgacogne rgacogne deleted the ddist-protobuf-device-id-name branch March 8, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants