]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/version.cc
Sphinx 1.8.0 seems broken, use any other version available instead
[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
28 #ifdef HAVE_BOTAN
29 #include <botan/version.h>
30 #endif /* HAVE_BOTAN */
31
32 static ProductType productType;
33
34 string compilerVersion()
35 {
36 #if defined(__clang__)
37 return string("clang " __clang_version__ );
38 #elif defined(__GNUC__)
39 return string("gcc " __VERSION__ );
40 #else // add other compilers here
41 return string("Unknown compiler");
42 #endif
43 }
44
45 // Human-readable product name
46 string productName() {
47 switch (productType) {
48 case ProductAuthoritative:
49 return "PowerDNS Authoritative Server";
50 case ProductRecursor:
51 return "PowerDNS Recursor";
52 };
53 return "Unknown";
54 }
55
56 string getPDNSVersion()
57 {
58 return VERSION;
59 }
60
61 // REST API product type
62 string productTypeApiType() {
63 switch (productType) {
64 case ProductAuthoritative:
65 return "authoritative";
66 case ProductRecursor:
67 return "recursor";
68 };
69 return "unknown";
70 }
71
72 void showProductVersion()
73 {
74 theL()<<Logger::Warning<<productName()<<" "<< VERSION << " (C) 2001-2018 "
75 "PowerDNS.COM BV" << endl;
76 theL()<<Logger::Warning<<"Using "<<(sizeof(unsigned long)*8)<<"-bits mode. "
77 "Built using " << compilerVersion()
78 #ifndef REPRODUCIBLE
79 <<" on " __DATE__ " " __TIME__ " by " BUILD_HOST
80 #endif
81 <<"."<< endl;
82 theL()<<Logger::Warning<<"PowerDNS comes with ABSOLUTELY NO WARRANTY. "
83 "This is free software, and you are welcome to redistribute it "
84 "according to the terms of the GPL version 2." << endl;
85 }
86
87 void showBuildConfiguration()
88 {
89 theL()<<Logger::Warning<<"Features: "<<
90 #ifdef HAVE_BOTAN
91 "botan" << BOTAN_VERSION_MAJOR << "." << BOTAN_VERSION_MINOR << " " <<
92 #endif
93 #ifdef HAVE_LIBSODIUM
94 "sodium " <<
95 #endif
96 #ifdef HAVE_LIBDECAF
97 "decaf " <<
98 #endif
99 "openssl " <<
100 #ifdef HAVE_LIBDL
101 "libdl " <<
102 #endif
103 #ifdef HAVE_LUA
104 "lua " <<
105 #endif
106 #ifdef REMOTEBACKEND_ZEROMQ
107 "remotebackend-zeromq " <<
108 #endif
109 #ifdef HAVE_P11KIT1
110 "PKCS#11" <<
111 #endif
112 #ifdef VERBOSELOG
113 "verboselog" <<
114 #endif
115 endl;
116 #ifdef PDNS_MODULES
117 // Auth only
118 theL()<<Logger::Warning<<"Built-in modules: "<<PDNS_MODULES<<endl;
119 #endif
120 #ifdef PDNS_CONFIG_ARGS
121 #define double_escape(s) #s
122 #define escape_quotes(s) double_escape(s)
123 theL()<<Logger::Warning<<"Configured with: "<<escape_quotes(PDNS_CONFIG_ARGS)<<endl;
124 #undef escape_quotes
125 #undef double_escape
126 #endif
127 }
128
129 string fullVersionString()
130 {
131 ostringstream s;
132 s<<productName()<<" " VERSION;
133 #ifndef REPRODUCIBLE
134 s<<" (built " __DATE__ " " __TIME__ " by " BUILD_HOST ")";
135 #endif
136 return s.str();
137 }
138
139 void versionSetProduct(ProductType pt)
140 {
141 productType = pt;
142 }
143
144 ProductType versionGetProduct()
145 {
146 return productType;
147 }