1 |
|
|
#include "node_metadata.h" |
2 |
|
|
#include "ares.h" |
3 |
|
|
#include "brotli/encode.h" |
4 |
|
|
#include "llhttp.h" |
5 |
|
|
#include "nghttp2/nghttp2ver.h" |
6 |
|
|
#include "node.h" |
7 |
|
|
#include "util.h" |
8 |
|
|
#include "uv.h" |
9 |
|
|
#include "v8.h" |
10 |
|
|
#include "zlib.h" |
11 |
|
|
|
12 |
|
|
#if HAVE_OPENSSL |
13 |
|
|
#include <openssl/opensslv.h> |
14 |
|
|
#if NODE_OPENSSL_HAS_QUIC |
15 |
|
|
#include <openssl/quic.h> |
16 |
|
|
#endif |
17 |
|
|
#endif // HAVE_OPENSSL |
18 |
|
|
|
19 |
|
|
#ifdef OPENSSL_INFO_QUIC |
20 |
|
|
#include <ngtcp2/version.h> |
21 |
|
|
#include <nghttp3/version.h> |
22 |
|
|
#endif |
23 |
|
|
|
24 |
|
|
#ifdef NODE_HAVE_I18N_SUPPORT |
25 |
|
|
#include <unicode/timezone.h> |
26 |
|
|
#include <unicode/ulocdata.h> |
27 |
|
|
#include <unicode/uvernum.h> |
28 |
|
|
#include <unicode/uversion.h> |
29 |
|
|
#endif // NODE_HAVE_I18N_SUPPORT |
30 |
|
|
|
31 |
|
|
namespace node { |
32 |
|
|
|
33 |
|
|
namespace per_process { |
34 |
|
|
Metadata metadata; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
#if HAVE_OPENSSL |
38 |
|
|
static constexpr size_t search(const char* s, char c, size_t n = 0) { |
39 |
|
|
return *s == c ? n : search(s + 1, c, n + 1); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
5487 |
static inline std::string GetOpenSSLVersion() { |
43 |
|
|
// sample openssl version string format |
44 |
|
|
// for reference: "OpenSSL 1.1.0i 14 Aug 2018" |
45 |
|
5487 |
constexpr size_t start = search(OPENSSL_VERSION_TEXT, ' ') + 1; |
46 |
|
5487 |
constexpr size_t len = search(&OPENSSL_VERSION_TEXT[start], ' '); |
47 |
|
5487 |
return std::string(OPENSSL_VERSION_TEXT, start, len); |
48 |
|
|
} |
49 |
|
|
#endif // HAVE_OPENSSL |
50 |
|
|
|
51 |
|
|
#ifdef NODE_HAVE_I18N_SUPPORT |
52 |
|
5435 |
void Metadata::Versions::InitializeIntlVersions() { |
53 |
|
5435 |
UErrorCode status = U_ZERO_ERROR; |
54 |
|
|
|
55 |
|
5435 |
const char* tz_version = icu::TimeZone::getTZDataVersion(status); |
56 |
✓✗ |
5435 |
if (U_SUCCESS(status)) { |
57 |
|
5435 |
tz = tz_version; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
char buf[U_MAX_VERSION_STRING_LENGTH]; |
61 |
|
|
UVersionInfo versionArray; |
62 |
|
5435 |
ulocdata_getCLDRVersion(versionArray, &status); |
63 |
✓✗ |
5435 |
if (U_SUCCESS(status)) { |
64 |
|
5435 |
u_versionToString(versionArray, buf); |
65 |
|
5435 |
cldr = buf; |
66 |
|
|
} |
67 |
|
5435 |
} |
68 |
|
|
#endif // NODE_HAVE_I18N_SUPPORT |
69 |
|
|
|
70 |
|
5487 |
Metadata::Versions::Versions() { |
71 |
|
5487 |
node = NODE_VERSION_STRING; |
72 |
|
5487 |
v8 = v8::V8::GetVersion(); |
73 |
|
5487 |
uv = uv_version_string(); |
74 |
|
5487 |
zlib = ZLIB_VERSION; |
75 |
|
5487 |
ares = ARES_VERSION_STR; |
76 |
|
5487 |
modules = NODE_STRINGIFY(NODE_MODULE_VERSION); |
77 |
|
5487 |
nghttp2 = NGHTTP2_VERSION; |
78 |
|
5487 |
napi = NODE_STRINGIFY(NAPI_VERSION); |
79 |
|
|
llhttp = |
80 |
|
|
NODE_STRINGIFY(LLHTTP_VERSION_MAJOR) |
81 |
|
|
"." |
82 |
|
|
NODE_STRINGIFY(LLHTTP_VERSION_MINOR) |
83 |
|
|
"." |
84 |
|
5487 |
NODE_STRINGIFY(LLHTTP_VERSION_PATCH); |
85 |
|
|
|
86 |
|
|
brotli = |
87 |
|
10974 |
std::to_string(BrotliEncoderVersion() >> 24) + |
88 |
|
10974 |
"." + |
89 |
|
21948 |
std::to_string((BrotliEncoderVersion() & 0xFFF000) >> 12) + |
90 |
|
10974 |
"." + |
91 |
|
16461 |
std::to_string(BrotliEncoderVersion() & 0xFFF); |
92 |
|
|
|
93 |
|
|
#if HAVE_OPENSSL |
94 |
|
5487 |
openssl = GetOpenSSLVersion(); |
95 |
|
|
#endif |
96 |
|
|
|
97 |
|
|
#ifdef NODE_HAVE_I18N_SUPPORT |
98 |
|
5487 |
icu = U_ICU_VERSION; |
99 |
|
5487 |
unicode = U_UNICODE_VERSION; |
100 |
|
|
#endif // NODE_HAVE_I18N_SUPPORT |
101 |
|
|
|
102 |
|
|
#ifdef OPENSSL_INFO_QUIC |
103 |
|
5487 |
ngtcp2 = NGTCP2_VERSION; |
104 |
|
5487 |
nghttp3 = NGHTTP3_VERSION; |
105 |
|
|
#endif |
106 |
|
5487 |
} |
107 |
|
|
|
108 |
|
5487 |
Metadata::Release::Release() : name(NODE_RELEASE) { |
109 |
|
|
#if NODE_VERSION_IS_LTS |
110 |
|
|
lts = NODE_VERSION_LTS_CODENAME; |
111 |
|
|
#endif // NODE_VERSION_IS_LTS |
112 |
|
|
|
113 |
|
|
#ifdef NODE_HAS_RELEASE_URLS |
114 |
|
|
#define NODE_RELEASE_URLPFX NODE_RELEASE_URLBASE "v" NODE_VERSION_STRING "/" |
115 |
|
|
#define NODE_RELEASE_URLFPFX NODE_RELEASE_URLPFX "node-v" NODE_VERSION_STRING |
116 |
|
|
|
117 |
|
|
source_url = NODE_RELEASE_URLFPFX ".tar.gz"; |
118 |
|
|
headers_url = NODE_RELEASE_URLFPFX "-headers.tar.gz"; |
119 |
|
|
#ifdef _WIN32 |
120 |
|
|
lib_url = strcmp(NODE_ARCH, "ia32") ? NODE_RELEASE_URLPFX "win-" NODE_ARCH |
121 |
|
|
"/node.lib" |
122 |
|
|
: NODE_RELEASE_URLPFX "win-x86/node.lib"; |
123 |
|
|
#endif // _WIN32 |
124 |
|
|
|
125 |
|
|
#endif // NODE_HAS_RELEASE_URLS |
126 |
|
5487 |
} |
127 |
|
|
|
128 |
|
5487 |
Metadata::Metadata() : arch(NODE_ARCH), platform(NODE_PLATFORM) {} |
129 |
|
|
|
130 |
|
|
} // namespace node |