Skip to content

dnsdist: Add more Lua bindings for network-related operations #11994

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

Merged
merged 9 commits into from
Oct 10, 2022

Conversation

rgacogne
Copy link
Member

Short description

  • getListOfRangesOfNetworkInterface: returns the list of network ranges configured on a given interface, which is useful to define dynamic ACLs from Lua
  • getResolvers: parses an /etc/resolv.conf-like file and returns a list of IP addresses (with ports)
  • vinfolog: log a line if dnsdist is running in verbose mode
  • Network endpoint bindings: allows connecting to a remote network endpoint, and send datagrams to that endpoint
  • Network listener bindings: allows listening for incoming datagrams on a given local address and port, and calling a Lua callback when such a datagram has been received

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)

@rgacogne rgacogne added this to the dnsdist-1.8.0 milestone Sep 21, 2022
@rgacogne rgacogne force-pushed the ddist-more-lua-net-bindings branch from 807f156 to 8786f37 Compare September 30, 2022 14:14
@rgacogne
Copy link
Member Author

rgacogne commented Oct 3, 2022

CI failure is unrelated.

});

luaCtx.registerFunction<bool (std::shared_ptr<dnsdist::NetworkListener>::*)(const std::string&, uint16_t, std::function<void(uint16_t, std::string & dgram, const std::string& from)>)>("addUnixListeningEndpoint", [client](std::shared_ptr<dnsdist::NetworkListener>& listener, const std::string& path, uint16_t endpointID, std::function<void(uint16_t endpoint, std::string & dgram, const std::string& from)> cb) {
if (client) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (client) {
if (client || !cb) {


#if HAVE_GETIFADDRS
static uint8_t convertNetmaskToBits(const struct in_addr* mask, socklen_t len)
{
Copy link
Member

Choose a reason for hiding this comment

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

Maybe check mask isn't null before accessing it's content

@rgacogne rgacogne force-pushed the ddist-more-lua-net-bindings branch from 8786f37 to dbe1fe7 Compare October 7, 2022 16:01
@rgacogne rgacogne merged commit 087c32d into PowerDNS:master Oct 10, 2022
@rgacogne rgacogne deleted the ddist-more-lua-net-bindings branch October 10, 2022 07:54
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