]>
git.ipfire.org Git - thirdparty/pdns.git/blob - modules/luabackend/master.cc
9b5293fdd121f666c31b5707cc423be6c21ca1a5
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 void LUABackend::getUpdatedMasters(vector
<DomainInfo
>* domains
) {
33 if (f_lua_getupdatedmasters
== 0)
37 L
<< Logger::Info
<< backend_name
<< "(getUpdatedMasters) BEGIN" << endl
;
39 lua_rawgeti(lua
, LUA_REGISTRYINDEX
, f_lua_getupdatedmasters
);
41 if(lua_pcall(lua
, 0, 1, f_lua_exec_error
) != 0) {
42 string e
= backend_name
+ lua_tostring(lua
, -1);
45 throw runtime_error(e
);
49 size_t returnedwhat
= lua_type(lua
, -1);
50 if (returnedwhat
!= LUA_TTABLE
) {
55 domains_from_table(domains
, "getUpdatedMasters");
58 L
<< Logger::Info
<< backend_name
<< "(getUpdatedMasters) END" << endl
;
61 void LUABackend::setNotified(uint32_t id
, uint32_t serial
) {
63 if (f_lua_setnotified
== 0)
67 L
<< Logger::Info
<< backend_name
<< "(setNotified) BEGIN" << endl
;
69 lua_rawgeti(lua
, LUA_REGISTRYINDEX
, f_lua_setnotified
);
71 lua_pushinteger(lua
, id
);
72 lua_pushinteger(lua
, serial
);
74 if(lua_pcall(lua
, 2, 0, f_lua_exec_error
) != 0) {
75 string e
= backend_name
+ lua_tostring(lua
, -1);
78 throw runtime_error(e
);
83 L
<< Logger::Info
<< backend_name
<< "(setNotified) END" << endl
;