]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/version.cc
Update and re-sort feature list in --version output
[thirdparty/pdns.git] / pdns / version.cc
CommitLineData
ba1a571d 1/*
6edbf68a
PL
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 * MERCHANTABILITY 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 */
870a0fe4
AT
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
ba1a571d
CH
25#include "logger.hh"
26#include "version.hh"
ba1a571d 27
3e135495 28static ProductType productType;
ba1a571d
CH
29
30string compilerVersion()
31{
32#if defined(__clang__)
e4a25816 33 return string("clang " __clang_version__ );
ba1a571d 34#elif defined(__GNUC__)
e4a25816 35 return string("gcc " __VERSION__ );
253cde09 36#else // add other compilers here
ba1a571d 37 return string("Unknown compiler");
253cde09 38#endif
ba1a571d
CH
39}
40
3e135495
CH
41// Human-readable product name
42string productName() {
43 switch (productType) {
44 case ProductAuthoritative:
45 return "PowerDNS Authoritative Server";
46 case ProductRecursor:
47 return "PowerDNS Recursor";
48 };
c4c9bcf6 49 return "Unknown";
3e135495
CH
50}
51
77b9f5ff 52string getPDNSVersion()
53{
ea1a7c39 54 return VERSION;
77b9f5ff 55}
56
3e135495
CH
57// REST API product type
58string productTypeApiType() {
59 switch (productType) {
60 case ProductAuthoritative:
61 return "authoritative";
62 case ProductRecursor:
63 return "recursor";
64 };
c4c9bcf6 65 return "unknown";
3e135495
CH
66}
67
ba1a571d
CH
68void showProductVersion()
69{
e6a9dde5 70 g_log<<Logger::Warning<<productName()<<" "<< VERSION << " (C) 2001-2018 "
ea1a7c39 71 "PowerDNS.COM BV" << endl;
e6a9dde5 72 g_log<<Logger::Warning<<"Using "<<(sizeof(unsigned long)*8)<<"-bits mode. "
5e6a3d93
PL
73 "Built using " << compilerVersion()
74#ifndef REPRODUCIBLE
75 <<" on " __DATE__ " " __TIME__ " by " BUILD_HOST
76#endif
77 <<"."<< endl;
e6a9dde5 78 g_log<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. "
ba1a571d
CH
79 "This is free software, and you are welcome to redistribute it "
80 "according to the terms of the GPL version 2." << endl;
81}
82
3613a51c
CH
83void showBuildConfiguration()
84{
e6a9dde5 85 g_log<<Logger::Warning<<"Features: "<<
21a8834a
KM
86#ifdef HAVE_LIBDECAF
87 "decaf " <<
fcc5d084 88#endif
9bdb77fa
CH
89#ifdef HAVE_BOOST_CONTEXT
90 "fcontext " <<
91#endif
92#ifdef HAVE_LIBCRYPTO_ECDSA
93 "libcrypto-ecdsa "
94#endif
95#ifdef HAVE_LIBCRYPTO_ED25519
96 "libcrypto-ed25519 "
97#endif
98#ifdef HAVE_LIBCRYPTO_ED448
99 "libcrypto-ed448 "
100#endif
101#ifdef HAVE_LIBCRYPTO_EDDSA
102 "libcrypto-eddsa "
103#endif
3613a51c
CH
104#ifdef HAVE_LIBDL
105 "libdl " <<
106#endif
107#ifdef HAVE_LUA
108 "lua " <<
109#endif
9bdb77fa
CH
110#ifdef HAVE_LUA_RECORDS
111 "lua-records " <<
112#endif
113#ifdef NOD_ENABLED
114 "nod " <<
115#endif
116#ifdef HAVE_P11KIT1
117 "PKCS#11 " <<
118#endif
119#ifdef HAVE_PROTOBUF
120 "protobuf " <<
121#endif
7404a2bd 122#ifdef REMOTEBACKEND_ZEROMQ
13f34f2e 123 "remotebackend-zeromq " <<
3613a51c 124#endif
9bdb77fa
CH
125#ifdef HAVE_NET_SNMP
126 "snmp " <<
127#endif
128#ifdef HAVE_LIBSODIUM
129 "sodium " <<
91bc549f 130#endif
3613a51c
CH
131#ifdef VERBOSELOG
132 "verboselog" <<
133#endif
134 endl;
135#ifdef PDNS_MODULES
136 // Auth only
e6a9dde5 137 g_log<<Logger::Warning<<"Built-in modules: "<<PDNS_MODULES<<endl;
3613a51c 138#endif
0060b613 139#ifdef PDNS_CONFIG_ARGS
4007a326
RK
140#define double_escape(s) #s
141#define escape_quotes(s) double_escape(s)
e6a9dde5 142 g_log<<Logger::Warning<<"Configured with: "<<escape_quotes(PDNS_CONFIG_ARGS)<<endl;
4007a326
RK
143#undef escape_quotes
144#undef double_escape
0060b613 145#endif
3613a51c
CH
146}
147
ba1a571d
CH
148string fullVersionString()
149{
05afd14a 150 ostringstream s;
ea1a7c39 151 s<<productName()<<" " VERSION;
5e6a3d93
PL
152#ifndef REPRODUCIBLE
153 s<<" (built " __DATE__ " " __TIME__ " by " BUILD_HOST ")";
154#endif
ba1a571d
CH
155 return s.str();
156}
157
3e135495
CH
158void versionSetProduct(ProductType pt)
159{
160 productType = pt;
161}
162
163ProductType versionGetProduct()
ba1a571d 164{
3e135495 165 return productType;
ba1a571d 166}