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

Lua2 backend #6157

Merged
merged 6 commits into from Mar 8, 2018
Merged

Lua2 backend #6157

merged 6 commits into from Mar 8, 2018

Conversation

cmouse
Copy link
Contributor

@cmouse cmouse commented Jan 8, 2018

Short description

This is a rewrite of the lua backend. It uses AuthLua4 as basis and more strongly typed access using LuaContext.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled and 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

@Habbie Habbie left a comment

Choose a reason for hiding this comment

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

Not a full review, just some comments. Can do a better review later. To be clear, I am fine with merging this as is if it does not affect anything outside of the backend.

The backend uses AuthLua4 base class, and you can use same functions and types as in any other Lua script.

.. warning::
Some of the function calls and configuration settings have been changed, please review this document carefully.
Copy link
Member

Choose a reason for hiding this comment

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

changed compared to what?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compared to lua backend. Need to clarify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

All places which use DNS names now use DNSName class which cannot be compared directly to a string.
To compare them against a string use either ``tostring(dnsname)`` or ``newDN(string)``.

API description (v1)
Copy link
Member

Choose a reason for hiding this comment

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

maybe call this v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, not sure. I'm happy with any way you decide. =)

Copy link
Member

Choose a reason for hiding this comment

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

Let's go with v2 to avoid any confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. Also added check that if version 1 is used, it instructs to use luabackend instead.

Perform lookup of given resource record name and type.

INPUT:
- string qtype - Type of queried resource record
Copy link
Member

Choose a reason for hiding this comment

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

Why not an integer or a qtype type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uses QType now.

- DNSName name - resource record name (can also be string)
- string type - type of resource record
- string content - resource record content
- int ttl - time to live for this resource record (default: configured value)
Copy link
Member

Choose a reason for hiding this comment

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

How would one trigger the defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clarified documentation

- int ttl - time to live for this resource record (default: configured value)
- int domain_id - ID of associated domain (default: -1)
- bool auth - Whether data is authoritative or not (default: true)
- int last_modified - UNIX timestamp of last modification
Copy link
Member

Choose a reason for hiding this comment

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

What's this for, if not for autoserial?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i included all fields on the structure.

- int domain_id - ID of associated domain (default: -1)
- bool auth - Whether data is authoritative or not (default: true)
- int last_modified - UNIX timestamp of last modification
- int scope_mask - How many bytes of source IP netmask was used for this result
Copy link
Member

Choose a reason for hiding this comment

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

What use is this if lookup does not get passed the source IP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I could pass the DNSPacket here... or maybe a special table with values of interest?

Copy link
Member

Choose a reason for hiding this comment

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

Table makes more sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

special table added.

- DNSName domain - Domain to get info for

OUTPUT:
Return false if not supported or found, otherwise expects a table of:
Copy link
Member

Choose a reason for hiding this comment

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

This comment also applies to other functions: should I return a table with these things in this order, or do I return a table with keys account, kind, etc.?

@@ -80,6 +80,7 @@ void loadMainConfig(const std::string& configdir)
string configname=::arg()["config-dir"]+"/"+s_programname+".conf";
cleanSlashes(configname);

::arg().set("resolver","Use this resolver for ALIAS and the internal stub resolver")="no";
Copy link
Member

Choose a reason for hiding this comment

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

why add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this one is required by lua-auth4.cc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is ok..?

Copy link
Member

Choose a reason for hiding this comment

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

yes

- DNSName qname - DNS name to calculate

OUTPUT:
Table of three DNSNames, in order of Unhashed, before and after.
Copy link
Member

Choose a reason for hiding this comment

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

Regarding some previous comments, I see from the testing script that some functions indeed expect keyed tables. This one does not - suggest saying 'Array of three DNSNames' for clarity.

These are needed to implement lua2 backend
This is API version 1 of lua2 backend.

It provides improved interface for Lua script to act as backends.

Configuration
 - `lua2-filename` - path to script
 - `lua2-query-logging` - log lua queries and results
 - `lua2-api' - API version (default 2)
@Habbie Habbie merged commit 0c0c011 into PowerDNS:master Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants