• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 20619367775

31 Dec 2025 12:52PM UTC coverage: 72.621% (-0.7%) from 73.336%
20619367775

Pull #16693

github

web-flow
Merge 6a1136865 into 65de281db
Pull Request #16693: auth: plumbing for structured logging

38996 of 65430 branches covered (59.6%)

Branch coverage included in aggregate %.

807 of 2400 new or added lines in 58 files covered. (33.63%)

196 existing lines in 40 files now uncovered.

129138 of 166092 relevant lines covered (77.75%)

5835960.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.82
/modules/lua2backend/lua2backend.cc
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTAPILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#ifdef HAVE_CONFIG_H
23
#include "config.h"
24
#endif
25
#include "pdns/logger.hh"
26
#include "pdns/arguments.hh"
27
#include "lua2backend.hh"
28

29
class Lua2Factory : public BackendFactory
30
{
31
public:
32
  Lua2Factory() :
33
    BackendFactory("lua2") {}
5,904✔
34

35
  void declareArguments(const string& suffix = "") override
36
  {
2✔
37
    declare(suffix, "filename", "Filename of the script for lua backend", "powerdns-luabackend.lua");
2✔
38
    declare(suffix, "query-logging", "Logging of the Lua2 Backend", "no");
2✔
39
    declare(suffix, "api", "Lua backend API version", "2");
2✔
40
  }
2✔
41

42
  DNSBackend* make(const string& suffix = "") override
43
  {
21✔
44
    const std::string apiSet = "lua2" + suffix + "-api";
21✔
45
    const int api = ::arg().asNum(apiSet);
21✔
46
    std::shared_ptr<Logr::Logger> slog;
21✔
47
    DNSBackend* be;
21✔
48
    switch (api) {
21✔
49
    case 1:
×
50
      throw PDNSException("Use luabackend for api version 1");
×
51
    case 2:
21!
52
      if (g_slogStructured) {
21!
NEW
53
        slog = g_slog->withName("lua2" + suffix);
×
NEW
54
      }
×
55
      be = new Lua2BackendAPIv2(slog, suffix);
21✔
56
      break;
21✔
57
    default:
×
58
      throw PDNSException("Unsupported ABI version " + ::arg()[apiSet]);
×
59
    }
21✔
60
    return be;
20✔
61
  }
21✔
62
};
63

64
class Lua2Loader
65
{
66
public:
67
  Lua2Loader()
68
  {
5,904✔
69
    BackendMakers().report(std::make_unique<Lua2Factory>());
5,904✔
70

71
    // If this module is not loaded dynamically at runtime, this code runs
72
    // as part of a global constructor, before the structured logger has a
73
    // chance to be set up, so fallback to simple logging in this case.
74
    if (!g_slogStructured || !g_slog) {
5,904!
75
      g_log << Logger::Info << "[lua2backend] This is the lua2 backend version " VERSION
5,904✔
76
#ifndef REPRODUCIBLE
5,904✔
77
            << " (" __DATE__ " " __TIME__ ")"
5,904✔
78
#endif
5,904✔
79
            << " reporting" << endl;
5,904✔
80
    }
5,904✔
NEW
81
    else {
×
NEW
82
      g_slog->withName("lua2backend")->info(Logr::Info, "lua2backend starting", "version", Logging::Loggable(VERSION)
×
NEW
83
#ifndef REPRODUCIBLE
×
NEW
84
                                                                                             ,
×
NEW
85
                                            "build date", Logging::Loggable(__DATE__ " " __TIME__)
×
NEW
86
#endif
×
NEW
87
      );
×
NEW
88
    }
×
89
  }
5,904✔
90
};
91

92
static Lua2Loader luaLoader;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc