]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/version.cc
rec: allow exception to proxy protocal usage for specific listen addresses
[thirdparty/pdns.git] / pdns / version.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 * 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 */
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 #include "logger.hh"
26 #include "version.hh"
27 #include "dnsbackend.hh"
28
29 #include <boost/algorithm/string/join.hpp>
30
31 static ProductType productType;
32
33 string compilerVersion()
34 {
35 #if defined(__clang__)
36 return string("clang " __clang_version__ );
37 #elif defined(__GNUC__)
38 return string("gcc " __VERSION__ );
39 #else // add other compilers here
40 return string("Unknown compiler");
41 #endif
42 }
43
44 // Human-readable product name
45 string productName() {
46 switch (productType) {
47 case ProductAuthoritative:
48 return "PowerDNS Authoritative Server";
49 case ProductRecursor:
50 return "PowerDNS Recursor";
51 };
52 return "Unknown";
53 }
54
55 string getPDNSVersion()
56 {
57 return VERSION;
58 }
59
60 // REST API product type
61 string productTypeApiType() {
62 switch (productType) {
63 case ProductAuthoritative:
64 return "authoritative";
65 case ProductRecursor:
66 return "recursor";
67 };
68 return "unknown";
69 }
70
71 void showProductVersion()
72 {
73 g_log<<Logger::Warning<<productName()<<" "<< VERSION << " (C) "
74 "PowerDNS.COM BV" << endl;
75 g_log<<Logger::Warning<<"Using "<<(sizeof(unsigned long)*8)<<"-bits mode. "
76 "Built using " << compilerVersion()
77 #ifndef REPRODUCIBLE
78 <<" on " __DATE__ " " __TIME__ " by " BUILD_HOST
79 #endif
80 <<"."<< endl;
81 g_log<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. "
82 "This is free software, and you are welcome to redistribute it "
83 "according to the terms of the GPL version 2." << endl;
84 }
85
86 void showBuildConfiguration()
87 {
88 g_log<<Logger::Warning<<"Features: "<<
89 #ifdef HAVE_LIBDECAF
90 "decaf " <<
91 #endif
92 #ifdef HAVE_BOOST_CONTEXT
93 "fcontext " <<
94 #endif
95 #ifdef HAVE_LIBCRYPTO_ECDSA
96 "libcrypto-ecdsa " <<
97 #endif
98 #ifdef HAVE_LIBCRYPTO_ED25519
99 "libcrypto-ed25519 " <<
100 #endif
101 #ifdef HAVE_LIBCRYPTO_ED448
102 "libcrypto-ed448 " <<
103 #endif
104 #ifdef HAVE_LIBCRYPTO_EDDSA
105 "libcrypto-eddsa " <<
106 #endif
107 #ifdef HAVE_LIBDL
108 "libdl " <<
109 #endif
110 #ifdef HAVE_GEOIP
111 "libgeoip " <<
112 #endif
113 #ifdef HAVE_MMDB
114 "libmaxminddb " <<
115 #endif
116 #ifdef HAVE_LUA
117 "lua " <<
118 #endif
119 #ifdef HAVE_LUA_RECORDS
120 "lua-records " <<
121 #endif
122 #ifdef NOD_ENABLED
123 "nod " <<
124 #endif
125 #ifdef HAVE_P11KIT1
126 "PKCS#11 " <<
127 #endif
128 "protobuf " <<
129 #ifdef HAVE_FSTRM
130 "dnstap-framestream " <<
131 #endif
132 #ifdef REMOTEBACKEND_ZEROMQ
133 "remotebackend-zeromq " <<
134 #endif
135 #ifdef HAVE_NET_SNMP
136 "snmp " <<
137 #endif
138 #ifdef HAVE_LIBSODIUM
139 "sodium " <<
140 #endif
141 #ifdef HAVE_LIBCURL
142 "curl " <<
143 #endif
144 #ifdef HAVE_DNS_OVER_TLS
145 "DoT " <<
146 #endif
147 #ifdef HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT
148 "scrypt " <<
149 #endif
150 #ifdef ENABLE_GSS_TSIG
151 "gss-tsig " <<
152 #endif
153 #ifdef VERBOSELOG
154 "verboselog" <<
155 #endif
156 endl;
157 #ifdef PDNS_MODULES
158 // Auth only
159 g_log << Logger::Warning << "Built-in modules: " << PDNS_MODULES << endl;
160 const auto& modules = BackendMakers().getModules();
161 g_log << Logger::Warning << "Loaded modules: " << boost::join(modules, " ") << endl;
162 #endif
163 #ifdef PDNS_CONFIG_ARGS
164 #define double_escape(s) #s
165 #define escape_quotes(s) double_escape(s)
166 g_log<<Logger::Warning<<"Configured with: "<<escape_quotes(PDNS_CONFIG_ARGS)<<endl;
167 #undef escape_quotes
168 #undef double_escape
169 #endif
170 }
171
172 string fullVersionString()
173 {
174 ostringstream s;
175 s<<productName()<<" " VERSION;
176 #ifndef REPRODUCIBLE
177 s<<" (built " __DATE__ " " __TIME__ " by " BUILD_HOST ")";
178 #endif
179 return s.str();
180 }
181
182 void versionSetProduct(ProductType pt)
183 {
184 productType = pt;
185 }
186
187 ProductType versionGetProduct()
188 {
189 return productType;
190 }