zgrzyt 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/check.js +5 -2
- package/lib/config.js +10 -0
- package/lib/report.js +5 -5
- package/package.json +1 -1
package/lib/check.js
CHANGED
|
@@ -32,7 +32,7 @@ async function checkService(server, api) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async function checkApi({ url, timeout, method = 'HEAD', retry = 2 }, address) {
|
|
35
|
+
async function checkApi({ url, timeout, method = 'HEAD', headers = {}, retry = 2 }, address) {
|
|
36
36
|
debug('Checking %s on %s with timeout %dms', url, address, timeout);
|
|
37
37
|
|
|
38
38
|
const { protocol } = new URL(url);
|
|
@@ -58,7 +58,10 @@ async function checkApi({ url, timeout, method = 'HEAD', retry = 2 }, address) {
|
|
|
58
58
|
method,
|
|
59
59
|
agent,
|
|
60
60
|
timeout,
|
|
61
|
-
headers: {
|
|
61
|
+
headers: {
|
|
62
|
+
'User-Agent': USER_AGENT,
|
|
63
|
+
...headers
|
|
64
|
+
}
|
|
62
65
|
})
|
|
63
66
|
.on('timeout', function () {
|
|
64
67
|
debug('Timeout for %s on %s', url, address);
|
package/lib/config.js
CHANGED
|
@@ -54,11 +54,21 @@ function prepareConfig(config) {
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
if (api.header && !Array.isArray(api.header)) {
|
|
58
|
+
api.header = [ api.header ];
|
|
59
|
+
}
|
|
60
|
+
const headers = (api.header || []).reduce((headers, str) => {
|
|
61
|
+
const [ name, value ] = str.split('=', 2);
|
|
62
|
+
headers[name] = value;
|
|
63
|
+
return headers;
|
|
64
|
+
}, {});
|
|
65
|
+
|
|
57
66
|
return {
|
|
58
67
|
servers,
|
|
59
68
|
api: {
|
|
60
69
|
url: api.url,
|
|
61
70
|
method: api.method || 'HEAD',
|
|
71
|
+
headers,
|
|
62
72
|
timeout,
|
|
63
73
|
retry,
|
|
64
74
|
domain,
|
package/lib/report.js
CHANGED
|
@@ -34,16 +34,16 @@ function reportAll(collected) {
|
|
|
34
34
|
let exitCode = 0;
|
|
35
35
|
const lines = [];
|
|
36
36
|
|
|
37
|
-
if (
|
|
38
|
-
lines.push('No
|
|
37
|
+
if (missing.length > 0) {
|
|
38
|
+
lines.push('No good servers for:\n', ...missing, '\n');
|
|
39
|
+
exitCode += 2;
|
|
39
40
|
}
|
|
40
41
|
if (switched.length > 0) {
|
|
41
42
|
lines.push('Switched DNS for:\n', ...switched, '\n');
|
|
42
43
|
exitCode += 1;
|
|
43
44
|
}
|
|
44
|
-
if (
|
|
45
|
-
lines.push('No
|
|
46
|
-
exitCode += 2;
|
|
45
|
+
if (noops.length > 0) {
|
|
46
|
+
lines.push('No changes:\n', ...noops, '\n');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return { exitCode, lines: lines.slice(0, -1) };
|