-
Notifications
You must be signed in to change notification settings - Fork 916
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
dnsdist: Add Lua bindings for PB requestorID, deviceName and deviceID #12615
Conversation
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.
Two remarks, reads good.
|
||
.. versionadded:: 1.8.0 | ||
|
||
The identifier of the requestor, which will be exported via ProtoBuf if set. |
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.
in the from
field.
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.
Isn't that in the requestorId
field?
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.
Hmm, right. I mixed that field up with d_requestor
used in the m.setRequest
call. These names are too similar :-(
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.
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; |
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.
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.
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.
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.
Short description
I forgot to add these before, and they are already used by the recursor.
Checklist
I have: