-
Notifications
You must be signed in to change notification settings - Fork 922
dnsdist: Warn on unsupported parameters #10115
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
Conversation
This idea would be nice for the recursor as well. Some general thoughts:
are repeated over and over again.
to avoid the repeating. |
a0f2735
to
f9ee369
Compare
Tested that it does indeed print warning
|
4d10b80
to
ea1d2d3
Compare
2705f81
to
8bc710d
Compare
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.
Looks like we often pass a copy of the variables, so we need to fix that at least. The general concept is awesome and the code looks good.
fc8bf8c
to
31e4642
Compare
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 love the general idea, and the implementation looks good! A few issues remain and I would not mind a rebase on the current master to ensure the checks are still valid, but other than that I'd like to merge it soon!
pdns/dnsdist-lua.cc
Outdated
|
||
ComboAddress serverAddr; | ||
std::string serverAddressStr; | ||
if(auto addrStr = boost::get<string>(&pvars)) { | ||
serverAddressStr = *addrStr; | ||
if(qps) { | ||
vars["qps"] = std::to_string(*qps); | ||
(*vars)["qps"] = std::to_string(*qps); |
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.
Does that work? I would expect that de-referencing an unset boost::optional
would be a problem.
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 have to try.
pdns/dnsdist-lua.cc
Outdated
getOptionalValue<bool>(vars, "mustResolve", ret->mustResolve); | ||
getOptionalValue<bool>(vars, "useClientSubnet", ret->useECS); | ||
getOptionalValue<bool>(vars, "useProxyProtocol", ret->useProxyProtocol); | ||
getOptionalValue<bool>(vars, "disableZeroScoping", ret->disableZeroScope); |
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.
getOptionalValue<bool>(vars, "disableZeroScoping", ret->disableZeroScope); | |
getOptionalValue<bool>(vars, "disableZeroScope", ret->disableZeroScope); |
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.
hm. that would also change the parameter name no?
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 believe the name is currently disableZeroScope
?
pdns/dnsdist-lua.cc
Outdated
boost::algorithm::to_lower(frontend->d_provider); | ||
} | ||
|
||
getOptionalValue<std::string>(vars, "provider", frontend->d_provider); |
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 the to_lower
part gone?
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.
so it seems.
I'm in the process of (painfully, but that's on me) rebasing this pull request on master, just FYI. |
3a21cb1
to
c7abe16
Compare
Rebased to fix conflicts. |
Rebased on master, and ready to be merged. A second review would be nice to have to make sure I did not mess up :) |
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.
Maybe we could unify a bit some integer values processing. Otherwise this lgtm and feels like a really good feature.
pdns/dnsdist-lua.cc
Outdated
if (vars.count("checkTimeout")) { | ||
config.checkTimeout = std::stoi(boost::get<string>(vars["checkTimeout"])); | ||
if (getOptionalValue<std::string>(vars, "checkClass", valueStr) > 0) { | ||
config.checkClass = std::stoi(valueStr); |
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.
As done a bit later, do we want to guard potential conversion exceptions for optional values ?
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'm also wondering if there is a good reason to not directly getOptionalValue<int>(vars, "checkClass", config.checkClass)
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'm also wondering if there is a good reason to not directly
getOptionalValue<int>(vars, "checkClass", config.checkClass)
Wouldn't that fail because the Lua wrapper used the string
type for that variable? We could extend the variant to allow integers, but then we need to change all the existing types and make sure the conversion works properly. One drawback that I did not notice before with the new code is that if we pass a string when we expect an integer, it is no longer considered a parsing error and we don't even warn, except at the end to say something like newServer: Unknown key 'checkClass' given - ignored
, which is confusing: the key exists, but the type is wrong.
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 pushed a new commit with better handling of numerical values, comments welcome!
As suggested by Charles-Henri Bruyand (thanks!).
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.
lgtm!
Short description
Change behavior of many commands to actually check the passed in vars / parameters that they are consumed fully. If they are not, we assume that they were not supported, and indicate first failing var / parameter.
Checklist
I have: