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