root/trunk/pdns/modules/luabackend/README

Revision 3048, 5.9 KB (checked in by peter, 4 months ago)

document ldap and lua fork status

Line 
1====================================
2This is the luabackend for PowerDNS!
3====================================
4
5Note: shortly before the 3.2 release of PowerDNS, Fredrik Danerklinkt
6(author of this Luabackend) opened https://github.com/fredan/luabackend
7and is doing development there.
8
9
10http://www.lua.org for more information about what Lua really is.
11
12
13This backend is just a "glue" between PowerDNS and your own Lua application.
14
15What this means is that you can not have a working setup that can serve you
16dns-questions directly from start. What you need to do is to program your own
17backend completely in Lua! Which database server to use etc is now up to you!
18
19What you have here is the possibility to make your own "dns-server" without the
20knowledge of programming in c/c++.
21
22There is one thing that needs to be said. Remember that each thread
23PowerDNS launches of this backend is completely different so they cannot
24share information between each other!
25
26You will need some kind of a database that can be shared for this.
27
28All the functionnames that PowerDNS accept for a backend should be the same
29in your Lua script, in lowercase. Also, the parameters should be in the same
30order. Where there is a structure in c/c++ there is a table in the Lua backend.
31This is also true for return values. A few functions expect that you return a
32table in a table.
33
34
35=============
36NEW FUNCTIONS
37=============
38
39There is a couple of new functions for you to use in Lua:
40
41----------------------------------------
42logger(log_facility, "your", "messages")
43----------------------------------------
44
45All these log_facilities is available:
46log_all, log_ntlog, log_alert, log_critical, log_error, log_warning, log_notice,
47log_info, log_debug, log_none
48
49
50-----------
51dnspacket()
52-----------
53
54This will give you back three parameters with
55remote_ip, remote_port and local_ip in that order.
56
57Can only be used in the functions list() and getsoa().
58
59
60------------------------
61getarg("your_parameter")
62------------------------
63
64This one tries to get the value of the name "lua-your_parameter" from the
65pdns.conf file.
66
67
68------------------------
69mustdo("your_parameter")
70------------------------
71
72This is the same as getarg() but return a boolean instead of a string.
73
74
75You also have all the different QTypes in a table called 'QTypes'.
76
77
78====================
79WHAT HAS BEEN TESTED
80====================
81
82The only functionality of the minimal functions except zone-transfer has
83been tested.
84
85In the included powerdns-luabackend.lua file there is a example of how
86this can be done. Note that this is more or less a static example since
87there is no possibility for each thread to know when something has changed.
88
89However, you can run 'pdns_control reload' and it should reload the hole thing
90from scratch (does not work for the moment, PowerDNS only calls two thread with
91the reload command - not all of them).
92
93
94===========================================
95WHAT YOU WILL FIND UNDER THE TEST DIRECTORY
96===========================================
97
98The script 'pdns' is used to test the server on the ip address '127.0.0.1' with
99the port 5300. You should be able to run the following test with the included
100'powerdns-luabackend.lua' file:
101
102$dig any www.test.com @127.0.0.1 -p5300 +multiline
103; <<>> DiG 9.7.3 <<>> any www.test.com @127.0.0.1 -p5300 +multiline
104;; global options: +cmd
105;; Got answer:
106;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1001
107;; flags: qr aa rd; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
108;; WARNING: recursion requested but not available
109
110;; QUESTION SECTION:
111;www.test.com.          IN ANY
112
113;; ANSWER SECTION:
114www.test.com.           120 IN CNAME host.test.com.
115host.test.com.          120 IN A 10.11.12.13
116host.test.com.          120 IN AAAA 1:2:3:4:5:6:7:8
117
118;; Query time: 1 msec
119;; SERVER: 127.0.0.1#5300(127.0.0.1)
120;; WHEN: Thu Jun  2 22:19:56 2011
121;; MSG SIZE  rcvd: 93
122
123
124=============================
125OPTIONS IN THE CONFIGURE FILE
126=============================
127
128The default values is:
129
130lua-filename = powerdns-luabackend.lua
131lua-logging-query = no
132
133You can also override all the default functionsnames for the luafunctions if you
134want. The prefix is lua-f_<functionname>=mynewfunction. For example:
135
136lua-f_lookup = mynewfunction
137
138will call the function 'mynewfunction' for the lookup-routine.
139
140If you want your own configuration parameters you can have that too.
141Just call the function getarg("my_parameter") and it will return the value
142of 'lua-my_parameter'. For boolean you use the function mustdo("my_parameter").
143
144
145==============================
146YOUR OWN ERROR FUNCTION IN LUA
147==============================
148
149You can have an error function in Lua when Lua gives back a error.
150
151First make your error function then you put this in pdns.conf:
152
153lua-f_exec_error = <your_name_of_the_error_function_in_lua>
154
155
156======
157DNSSEC
158======
159
160You can have full dnssec support in our Lua application. You should note the
161following regarding this:
162
163You don't have to implement the function 'updateDNSSECOrderAndAuth' since the
164default code will work correctly for you via the backend itself.
165
166The functions activateDomainKey and deactivateDomainKey can be implemented via a
167new function called updateDomainKey, which has three parameters (the other two
168has only two parameters) where the third is a boolean which is true or false
169depending on which function that was called from the beginning.
170
171
172=======================
173INFORMATION FOR LOGGING
174=======================
175
176If you have the parameter 'query-logging' or 'lua-logging-query' set to
177true/yes/on, then you will see what is happening in each function when PowerDNS
178calls them.
179
180This can, hopefully, help you with some debugging if you run into some kind of
181trouble with your Lua application.
182
183
184===============
185ASKING QUESTION
186===============
187
188You can send question about this backend to >dev/null first and if you don't get any
189answer from that you can try to send them to me at fredan-pdns@fredan.org
190
191Fredrik Danerklint.
Note: See TracBrowser for help on using the browser.