]>
git.ipfire.org Git - thirdparty/pdns.git/blob - modules/luabackend/private.cc
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 * originally authored by Fredrik Danerklint
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * In addition, for the avoidance of any doubt, permission is granted to
11 * link this program with OpenSSL and to (re)distribute the binaries
12 * produced as the result of such linking.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "luabackend.hh"
28 #include "pdns/logger.hh"
29 #include "pdns/arguments.hh"
31 string
LUABackend::my_getArg(string a
) {
35 bool LUABackend::my_mustDo(string a
) {
39 bool LUABackend::domaininfo_from_table(DomainInfo
*di
) {
43 if (!getValueFromTable(lua
, "id", di
->id
))
46 if (!getValueFromTable(lua
, "zone", di
->zone
))
49 if (!getValueFromTable(lua
, "serial", di
->serial
))
52 getValueFromTable(lua
, "notified_serial", di
->notified_serial
);
53 getValueFromTable(lua
, "last_check", di
->last_check
);
55 di
->kind
= DomainInfo::Native
;
58 if (getValueFromTable(lua
, "kind", kind
)) {
61 di
->kind
= DomainInfo::Master
;
62 else if (kind
== "SLAVE")
63 di
->kind
= DomainInfo::Slave
;
66 lua_pushstring(lua
, "masters");
67 lua_gettable(lua
, -2);
69 if(!lua_isnil(lua
, -1)) {
72 while (lua_next(lua
, -2)) {
73 value
= lua_tostring(lua
, -1);
75 di
->masters
.push_back(ComboAddress(value
, 53));
86 void LUABackend::domains_from_table(vector
<DomainInfo
>* domains
, const char *f_name
) {
91 while (lua_next(lua
, -2)) {
92 returnedwhat
= lua_type(lua
, -1);
93 if (returnedwhat
== LUA_TTABLE
) {
96 if (domaininfo_from_table(&di
))
97 domains
->push_back(di
);
105 void LUABackend::dnsrr_to_table(lua_State
*lua
, const DNSResourceRecord
*rr
) {
109 lua_pushliteral(lua
, "qtype");
110 lua_pushstring(lua
, rr
->qtype
.getName().c_str());
111 lua_settable(lua
, -3);
113 lua_pushliteral(lua
, "qclass");
114 lua_pushinteger(lua
, rr
->qclass
);
115 lua_settable(lua
, -3);
117 lua_pushliteral(lua
, "ttl");
118 lua_pushinteger(lua
, rr
->ttl
);
119 lua_settable(lua
, -3);
121 lua_pushliteral(lua
, "auth");
122 lua_pushboolean(lua
, rr
->auth
);
123 lua_settable(lua
, -3);
125 lua_pushliteral(lua
, "content");
126 lua_pushstring(lua
, rr
->content
.c_str());
127 lua_settable(lua
, -3);