nodestatus-server 1.2.0-alpha.3 → 1.2.0-alpha.4

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/build/app.js CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  var require$$1$2 = require('path');
4
4
  var require$$0$4 = require('tty');
5
- var require$$0$5 = require('util');
6
- var require$$1$1 = require('os');
7
- var require$$0$6 = require('buffer');
8
- var require$$1$3 = require('fs');
9
- var require$$1$4 = require('stream');
5
+ var require$$1$1 = require('util');
6
+ var require$$0$5 = require('buffer');
7
+ var require$$0$6 = require('fs');
8
+ var require$$1$3 = require('stream');
10
9
  var require$$5$2 = require('assert');
11
10
  var require$$0$7 = require('events');
12
11
  var require$$0$8 = require('crypto');
@@ -14,28 +13,25 @@ var require$$2$1 = require('http');
14
13
  var require$$0$9 = require('url');
15
14
  var require$$3$1 = require('net');
16
15
  var require$$5$3 = require('querystring');
17
- var require$$3$2 = require('cluster');
16
+ var require$$1$4 = require('os');
18
17
  var require$$0$a = require('constants');
19
18
  var require$$0$b = require('zlib');
20
19
  var require$$1$5 = require('string_decoder');
21
20
  var dotenv = require('dotenv');
22
21
  var require$$1$6 = require('child_process');
23
22
  var client = require('@prisma/client');
24
- var require$$1$8 = require('https');
23
+ var require$$1$7 = require('https');
25
24
  var require$$4$1 = require('tls');
26
- var require$$1$7 = require('bufferutil');
27
- var require$$0$c = require('utf-8-validate');
28
25
  var telegraf = require('telegraf');
29
26
 
30
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
31
28
 
32
29
  var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
33
30
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
34
- var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
35
31
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
32
+ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
36
33
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
37
34
  var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
38
- var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
39
35
  var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5$2);
40
36
  var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
41
37
  var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
@@ -43,16 +39,14 @@ var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
43
39
  var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
44
40
  var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
45
41
  var require$$5__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$5$3);
46
- var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$2);
42
+ var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
47
43
  var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
48
44
  var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$b);
49
45
  var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
50
46
  var dotenv__default = /*#__PURE__*/_interopDefaultLegacy(dotenv);
51
47
  var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
52
- var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$8);
53
- var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
54
48
  var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
55
- var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$c);
49
+ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
56
50
 
57
51
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
58
52
 
@@ -747,155 +741,13 @@ function localstorage() {
747
741
 
748
742
  var node$2 = {exports: {}};
749
743
 
750
- var hasFlag$1 = (flag, argv = process.argv) => {
751
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
752
- const position = argv.indexOf(prefix + flag);
753
- const terminatorPosition = argv.indexOf('--');
754
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
755
- };
756
-
757
- const os$7 = require$$1__default["default"];
758
- const tty = require$$0__default["default"];
759
- const hasFlag = hasFlag$1;
760
-
761
- const {env} = process;
762
-
763
- let forceColor;
764
- if (hasFlag('no-color') ||
765
- hasFlag('no-colors') ||
766
- hasFlag('color=false') ||
767
- hasFlag('color=never')) {
768
- forceColor = 0;
769
- } else if (hasFlag('color') ||
770
- hasFlag('colors') ||
771
- hasFlag('color=true') ||
772
- hasFlag('color=always')) {
773
- forceColor = 1;
774
- }
775
-
776
- if ('FORCE_COLOR' in env) {
777
- if (env.FORCE_COLOR === 'true') {
778
- forceColor = 1;
779
- } else if (env.FORCE_COLOR === 'false') {
780
- forceColor = 0;
781
- } else {
782
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
783
- }
784
- }
785
-
786
- function translateLevel(level) {
787
- if (level === 0) {
788
- return false;
789
- }
790
-
791
- return {
792
- level,
793
- hasBasic: true,
794
- has256: level >= 2,
795
- has16m: level >= 3
796
- };
797
- }
798
-
799
- function supportsColor(haveStream, streamIsTTY) {
800
- if (forceColor === 0) {
801
- return 0;
802
- }
803
-
804
- if (hasFlag('color=16m') ||
805
- hasFlag('color=full') ||
806
- hasFlag('color=truecolor')) {
807
- return 3;
808
- }
809
-
810
- if (hasFlag('color=256')) {
811
- return 2;
812
- }
813
-
814
- if (haveStream && !streamIsTTY && forceColor === undefined) {
815
- return 0;
816
- }
817
-
818
- const min = forceColor || 0;
819
-
820
- if (env.TERM === 'dumb') {
821
- return min;
822
- }
823
-
824
- if (process.platform === 'win32') {
825
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
826
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
827
- const osRelease = os$7.release().split('.');
828
- if (
829
- Number(osRelease[0]) >= 10 &&
830
- Number(osRelease[2]) >= 10586
831
- ) {
832
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
833
- }
834
-
835
- return 1;
836
- }
837
-
838
- if ('CI' in env) {
839
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
840
- return 1;
841
- }
842
-
843
- return min;
844
- }
845
-
846
- if ('TEAMCITY_VERSION' in env) {
847
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
848
- }
849
-
850
- if (env.COLORTERM === 'truecolor') {
851
- return 3;
852
- }
853
-
854
- if ('TERM_PROGRAM' in env) {
855
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
856
-
857
- switch (env.TERM_PROGRAM) {
858
- case 'iTerm.app':
859
- return version >= 3 ? 3 : 2;
860
- case 'Apple_Terminal':
861
- return 2;
862
- // No default
863
- }
864
- }
865
-
866
- if (/-256(color)?$/i.test(env.TERM)) {
867
- return 2;
868
- }
869
-
870
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
871
- return 1;
872
- }
873
-
874
- if ('COLORTERM' in env) {
875
- return 1;
876
- }
877
-
878
- return min;
879
- }
880
-
881
- function getSupportLevel(stream) {
882
- const level = supportsColor(stream, stream && stream.isTTY);
883
- return translateLevel(level);
884
- }
885
-
886
- var supportsColor_1 = {
887
- supportsColor: getSupportLevel,
888
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
889
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
890
- };
891
-
892
744
  /**
893
745
  * Module dependencies.
894
746
  */
895
747
 
896
748
  (function (module, exports) {
897
749
  var tty = require$$0__default["default"];
898
- var util = require$$0__default$1["default"];
750
+ var util = require$$1__default["default"];
899
751
 
900
752
  /**
901
753
  * This is the Node.js implementation of `debug()`.
@@ -918,7 +770,7 @@ exports.useColors = useColors;
918
770
  exports.colors = [ 6, 2, 3, 4, 5, 1 ];
919
771
 
920
772
  try {
921
- var supportsColor = supportsColor_1;
773
+ var supportsColor = require('supports-color');
922
774
  if (supportsColor && supportsColor.level >= 2) {
923
775
  exports.colors = [
924
776
  20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
@@ -1389,7 +1241,7 @@ var safeBuffer$1 = {exports: {}};
1389
1241
  /* eslint-disable node/no-deprecated-api */
1390
1242
 
1391
1243
  (function (module, exports) {
1392
- var buffer = require$$0__default$2["default"];
1244
+ var buffer = require$$0__default$1["default"];
1393
1245
  var Buffer = buffer.Buffer;
1394
1246
 
1395
1247
  // alternative to using Object.keys for old browsers
@@ -13611,8 +13463,8 @@ function status (code) {
13611
13463
  * @private
13612
13464
  */
13613
13465
 
13614
- var ReadStream = require$$1__default$2["default"].ReadStream;
13615
- var Stream$6 = require$$1__default$3["default"];
13466
+ var ReadStream = require$$0__default$2["default"].ReadStream;
13467
+ var Stream$6 = require$$1__default$2["default"];
13616
13468
 
13617
13469
  /**
13618
13470
  * Module exports.
@@ -13910,9 +13762,9 @@ const assert = require$$5__default["default"];
13910
13762
  const extname = require$$1__default$1["default"].extname;
13911
13763
  const vary = vary$1.exports;
13912
13764
  const only = only$1;
13913
- const util = require$$0__default$1["default"];
13765
+ const util = require$$1__default["default"];
13914
13766
  const encodeUrl = encodeurl;
13915
- const Stream = require$$1__default$3["default"];
13767
+ const Stream = require$$1__default$2["default"];
13916
13768
 
13917
13769
  /**
13918
13770
  * Prototype.
@@ -15309,7 +15161,7 @@ if (typeof Object.create === 'function') {
15309
15161
  }
15310
15162
 
15311
15163
  try {
15312
- var util$d = require$$0__default$1["default"];
15164
+ var util$d = require('util');
15313
15165
  /* istanbul ignore next */
15314
15166
  if (typeof util$d.inherits !== 'function') throw '';
15315
15167
  inherits$1.exports = util$d.inherits;
@@ -16802,7 +16654,7 @@ var cookies = Cookies;
16802
16654
  * Module dependencies.
16803
16655
  */
16804
16656
 
16805
- const util = require$$0__default$1["default"];
16657
+ const util = require$$1__default["default"];
16806
16658
  const createError = httpErrors$2.exports;
16807
16659
  const httpAssert$1 = httpAssert;
16808
16660
  const delegate = delegates;
@@ -18772,7 +18624,7 @@ const qs = require$$5__default$1["default"];
18772
18624
  const typeis = typeIs.exports;
18773
18625
  const fresh = fresh_1;
18774
18626
  const only = only$1;
18775
- const util = require$$0__default$1["default"];
18627
+ const util = require$$1__default["default"];
18776
18628
 
18777
18629
  const IP = Symbol('context#ip');
18778
18630
 
@@ -20017,8 +19869,8 @@ const context = context$1.exports;
20017
19869
  const request = request$1.exports;
20018
19870
  const statuses = statuses$1;
20019
19871
  const Emitter = require$$0__default$3["default"];
20020
- const util$c = require$$0__default$1["default"];
20021
- const Stream$5 = require$$1__default$3["default"];
19872
+ const util$c = require$$1__default["default"];
19873
+ const Stream$5 = require$$1__default$2["default"];
20022
19874
  const http$3 = require$$2__default["default"];
20023
19875
  const only = only$1;
20024
19876
  const convert = koaConvert;
@@ -20901,7 +20753,7 @@ var node$1 = {exports: {}};
20901
20753
  */
20902
20754
  var tty = require$$0__default["default"];
20903
20755
 
20904
- var util = require$$0__default$1["default"];
20756
+ var util = require$$1__default["default"];
20905
20757
  /**
20906
20758
  * This is the Node.js implementation of `debug()`.
20907
20759
  */
@@ -20922,7 +20774,7 @@ exports.colors = [6, 2, 3, 4, 5, 1];
20922
20774
  try {
20923
20775
  // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
20924
20776
  // eslint-disable-next-line import/no-extraneous-dependencies
20925
- var supportsColor = supportsColor_1;
20777
+ var supportsColor = require('supports-color');
20926
20778
 
20927
20779
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
20928
20780
  exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
@@ -21803,7 +21655,7 @@ var node = {exports: {}};
21803
21655
 
21804
21656
  (function (module, exports) {
21805
21657
  const tty = require$$0__default["default"];
21806
- const util = require$$0__default$1["default"];
21658
+ const util = require$$1__default["default"];
21807
21659
 
21808
21660
  /**
21809
21661
  * This is the Node.js implementation of `debug()`.
@@ -21829,7 +21681,7 @@ exports.colors = [6, 2, 3, 4, 5, 1];
21829
21681
  try {
21830
21682
  // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
21831
21683
  // eslint-disable-next-line import/no-extraneous-dependencies
21832
- const supportsColor = supportsColor_1;
21684
+ const supportsColor = require('supports-color');
21833
21685
 
21834
21686
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
21835
21687
  exports.colors = [
@@ -22121,7 +21973,7 @@ if (typeof Object.create === 'function') {
22121
21973
  }
22122
21974
 
22123
21975
  try {
22124
- var util$b = require$$0__default$1["default"];
21976
+ var util$b = require('util');
22125
21977
  if (typeof util$b.inherits !== 'function') throw '';
22126
21978
  inherits.exports = util$b.inherits;
22127
21979
  } catch (e) {
@@ -22502,8 +22354,8 @@ function resolvePath$1 (rootPath, relativePath) {
22502
22354
  * Module dependencies.
22503
22355
  */
22504
22356
 
22505
- const fs$r = require$$1__default$2["default"];
22506
- const util$a = require$$0__default$1["default"];
22357
+ const fs$r = require$$0__default$2["default"];
22358
+ const util$a = require$$1__default["default"];
22507
22359
  const debug$k = src$2.exports('koa-send');
22508
22360
  const resolvePath = resolvePath_1;
22509
22361
  const createError$1 = httpErrors$2.exports;
@@ -23090,7 +22942,7 @@ function rfdcCircles (opts) {
23090
22942
  }
23091
22943
  }
23092
22944
 
23093
- const util$9 = require$$0__default$1["default"];
22945
+ const util$9 = require$$1__default["default"];
23094
22946
  const debug$i = src$2.exports('log4js:configuration');
23095
22947
 
23096
22948
  const preProcessingListeners = [];
@@ -23372,8 +23224,8 @@ module.exports.ABSOLUTETIME_FORMAT = "hh:mm:ss.SSS";
23372
23224
  }(lib$7));
23373
23225
 
23374
23226
  const dateFormat = lib$7.exports;
23375
- const os$6 = require$$1__default["default"];
23376
- const util$8 = require$$0__default$1["default"];
23227
+ const os$6 = require$$1__default$3["default"];
23228
+ const util$8 = require$$1__default["default"];
23377
23229
  const path$p = require$$1__default$1["default"];
23378
23230
 
23379
23231
  const styles = {
@@ -24108,7 +23960,7 @@ const configuration$4 = configuration$6;
24108
23960
  let disabled = false;
24109
23961
  let cluster = null;
24110
23962
  try {
24111
- cluster = require$$3__default$1["default"]; //eslint-disable-line
23963
+ cluster = require("cluster"); //eslint-disable-line
24112
23964
  } catch (e) {
24113
23965
  debug$h("cluster module not present");
24114
23966
  disabled = true;
@@ -24774,7 +24626,7 @@ function patch$1 (fs) {
24774
24626
  }
24775
24627
  }
24776
24628
 
24777
- var Stream$4 = require$$1__default$3["default"].Stream;
24629
+ var Stream$4 = require$$1__default$2["default"].Stream;
24778
24630
 
24779
24631
  var legacyStreams = legacy$1;
24780
24632
 
@@ -24915,12 +24767,12 @@ function clone$1 (obj) {
24915
24767
  return copy
24916
24768
  }
24917
24769
 
24918
- var fs$p = require$$1__default$2["default"];
24770
+ var fs$p = require$$0__default$2["default"];
24919
24771
  var polyfills = polyfills$1;
24920
24772
  var legacy = legacyStreams;
24921
24773
  var clone = clone_1;
24922
24774
 
24923
- var util$7 = require$$0__default$1["default"];
24775
+ var util$7 = require$$1__default["default"];
24924
24776
 
24925
24777
  /* istanbul ignore next - node 0.x polyfill */
24926
24778
  var gracefulQueue;
@@ -25610,7 +25462,7 @@ var mkdirs_1 = {
25610
25462
  };
25611
25463
 
25612
25464
  const fs$m = gracefulFs;
25613
- const os$5 = require$$1__default["default"];
25465
+ const os$5 = require$$1__default$3["default"];
25614
25466
  const path$l = require$$1__default$1["default"];
25615
25467
 
25616
25468
  // HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
@@ -26955,9 +26807,9 @@ var ensure = {
26955
26807
 
26956
26808
  var _fs;
26957
26809
  try {
26958
- _fs = gracefulFs;
26810
+ _fs = require('graceful-fs');
26959
26811
  } catch (_) {
26960
- _fs = require$$1__default$2["default"];
26812
+ _fs = require$$0__default$2["default"];
26961
26813
  }
26962
26814
 
26963
26815
  function readFile (file, options, callback) {
@@ -27337,7 +27189,7 @@ module.exports = Object.assign(
27337
27189
 
27338
27190
  // Export fs.promises as a getter property so that we don't trigger
27339
27191
  // ExperimentalWarning before fs.promises is actually accessed.
27340
- const fs = require$$1__default$2["default"];
27192
+ const fs = require$$0__default$2["default"];
27341
27193
  if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
27342
27194
  Object.defineProperty(module.exports, 'promises', {
27343
27195
  get () { return fs.promises }
@@ -27745,7 +27597,7 @@ const fs$5 = lib$6.exports;
27745
27597
  const path$5 = require$$1__default$1["default"];
27746
27598
  const newNow = now;
27747
27599
  const format$4 = lib$5.exports;
27748
- const { Writable: Writable$1 } = require$$1__default$3["default"];
27600
+ const { Writable: Writable$1 } = require$$1__default$2["default"];
27749
27601
  const fileNameFormatter = fileNameFormatter$1;
27750
27602
  const fileNameParser = fileNameParser$1;
27751
27603
  const moveAndMaybeCompressFile = moveAndMaybeCompressFile_1;
@@ -28079,7 +27931,7 @@ var lib$4 = {
28079
27931
  const debug$9 = src$2.exports('log4js:file');
28080
27932
  const path$4 = require$$1__default$1["default"];
28081
27933
  const streams$2 = lib$4;
28082
- const os$4 = require$$1__default["default"];
27934
+ const os$4 = require$$1__default$3["default"];
28083
27935
 
28084
27936
  const eol$2 = os$4.EOL;
28085
27937
 
@@ -28187,7 +28039,7 @@ file$3.configure = configure$3;
28187
28039
  var dateFile = {};
28188
28040
 
28189
28041
  const streams$1 = lib$4;
28190
- const os$3 = require$$1__default["default"];
28042
+ const os$3 = require$$1__default$3["default"];
28191
28043
 
28192
28044
  const eol$1 = os$3.EOL;
28193
28045
 
@@ -28261,8 +28113,8 @@ var fileSync = {};
28261
28113
 
28262
28114
  const debug$8 = src$2.exports('log4js:fileSync');
28263
28115
  const path$3 = require$$1__default$1["default"];
28264
- const fs$4 = require$$1__default$2["default"];
28265
- const os$2 = require$$1__default["default"];
28116
+ const fs$4 = require$$0__default$2["default"];
28117
+ const os$2 = require$$1__default$3["default"];
28266
28118
 
28267
28119
  const eol = os$2.EOL || '\n';
28268
28120
 
@@ -28544,7 +28396,7 @@ const createAppender = (name, config) => {
28544
28396
  }
28545
28397
 
28546
28398
  debug$7(`${name}: clustering.isMaster ? ${clustering$2.isMaster()}`);
28547
- debug$7(`${name}: appenderModule is ${require$$0__default$1["default"].inspect(appenderModule)}`); // eslint-disable-line
28399
+ debug$7(`${name}: appenderModule is ${require$$1__default["default"].inspect(appenderModule)}`); // eslint-disable-line
28548
28400
  return clustering$2.onlyOnMaster(() => {
28549
28401
  debug$7(`calling appenderModule.configure for ${name} / ${appenderConfig.type}`);
28550
28402
  return appenderModule.configure(
@@ -29270,7 +29122,7 @@ var connectLogger$1 = function getLogger(logger4js, options) {
29270
29122
  */
29271
29123
 
29272
29124
  const debug$4 = src$2.exports("log4js:main");
29273
- const fs$3 = require$$1__default$2["default"];
29125
+ const fs$3 = require$$0__default$2["default"];
29274
29126
  const deepClone = rfdc_1({ proto: true });
29275
29127
  const configuration = configuration$6;
29276
29128
  const layouts = layouts$2;
@@ -29472,7 +29324,7 @@ var indentString$1 = (string, count = 1, options) => {
29472
29324
  return string.replace(regex, options.indent.repeat(count));
29473
29325
  };
29474
29326
 
29475
- const os$1 = require$$1__default["default"];
29327
+ const os$1 = require$$1__default$3["default"];
29476
29328
 
29477
29329
  const extractPathRegex = /\s+at.*(?:\(|\s)(.*)\)?/;
29478
29330
  const pathRegex = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/;
@@ -29902,7 +29754,7 @@ var safeBuffer = {exports: {}};
29902
29754
 
29903
29755
  (function (module, exports) {
29904
29756
  /* eslint-disable node/no-deprecated-api */
29905
- var buffer = require$$0__default$2["default"];
29757
+ var buffer = require$$0__default$1["default"];
29906
29758
  var Buffer = buffer.Buffer;
29907
29759
 
29908
29760
  // alternative to using Object.keys for old browsers
@@ -29970,8 +29822,8 @@ SafeBuffer.allocUnsafeSlow = function (size) {
29970
29822
  /*global module, process*/
29971
29823
 
29972
29824
  var Buffer$g = safeBuffer.exports.Buffer;
29973
- var Stream$3 = require$$1__default$3["default"];
29974
- var util$6 = require$$0__default$1["default"];
29825
+ var Stream$3 = require$$1__default$2["default"];
29826
+ var util$6 = require$$1__default["default"];
29975
29827
 
29976
29828
  function DataStream$2(data) {
29977
29829
  this.buffer = null;
@@ -30025,8 +29877,8 @@ DataStream$2.prototype.end = function end(data) {
30025
29877
  var dataStream = DataStream$2;
30026
29878
 
30027
29879
  /*jshint node:true */
30028
- var Buffer$f = require$$0__default$2["default"].Buffer; // browserify
30029
- var SlowBuffer = require$$0__default$2["default"].SlowBuffer;
29880
+ var Buffer$f = require$$0__default$1["default"].Buffer; // browserify
29881
+ var SlowBuffer = require$$0__default$1["default"].SlowBuffer;
30030
29882
 
30031
29883
  var bufferEqualConstantTime = bufferEq;
30032
29884
 
@@ -30277,7 +30129,7 @@ var bufferEqual = bufferEqualConstantTime;
30277
30129
  var Buffer$d = safeBuffer.exports.Buffer;
30278
30130
  var crypto$2 = require$$0__default$4["default"];
30279
30131
  var formatEcdsa = ecdsaSigFormatter;
30280
- var util$5 = require$$0__default$1["default"];
30132
+ var util$5 = require$$1__default["default"];
30281
30133
 
30282
30134
  var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
30283
30135
  var MSG_INVALID_SECRET = 'secret must be a string or buffer';
@@ -30526,7 +30378,7 @@ var jwa$2 = function jwa(algorithm) {
30526
30378
 
30527
30379
  /*global module*/
30528
30380
 
30529
- var Buffer$c = require$$0__default$2["default"].Buffer;
30381
+ var Buffer$c = require$$0__default$1["default"].Buffer;
30530
30382
 
30531
30383
  var tostring = function toString(obj) {
30532
30384
  if (typeof obj === 'string')
@@ -30541,9 +30393,9 @@ var tostring = function toString(obj) {
30541
30393
  var Buffer$b = safeBuffer.exports.Buffer;
30542
30394
  var DataStream$1 = dataStream;
30543
30395
  var jwa$1 = jwa$2;
30544
- var Stream$2 = require$$1__default$3["default"];
30396
+ var Stream$2 = require$$1__default$2["default"];
30545
30397
  var toString$1 = tostring;
30546
- var util$4 = require$$0__default$1["default"];
30398
+ var util$4 = require$$1__default["default"];
30547
30399
 
30548
30400
  function base64url(string, encoding) {
30549
30401
  return Buffer$b
@@ -30621,9 +30473,9 @@ var signStream = SignStream$1;
30621
30473
  var Buffer$a = safeBuffer.exports.Buffer;
30622
30474
  var DataStream = dataStream;
30623
30475
  var jwa = jwa$2;
30624
- var Stream$1 = require$$1__default$3["default"];
30476
+ var Stream$1 = require$$1__default$2["default"];
30625
30477
  var toString = tostring;
30626
- var util$3 = require$$0__default$1["default"];
30478
+ var util$3 = require$$1__default["default"];
30627
30479
  var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
30628
30480
 
30629
30481
  function isObject$3(thing) {
@@ -35082,7 +34934,7 @@ var lib$2 = {exports: {}};
35082
34934
 
35083
34935
  /* eslint-disable node/no-deprecated-api */
35084
34936
 
35085
- var buffer = require$$0__default$2["default"];
34937
+ var buffer = require$$0__default$1["default"];
35086
34938
  var Buffer$9 = buffer.Buffer;
35087
34939
 
35088
34940
  var safer = {};
@@ -45587,8 +45439,8 @@ for (var i = 0; i < modules.length; i++) {
45587
45439
  }
45588
45440
  }(encodings));
45589
45441
 
45590
- var Buffer$3 = require$$0__default$2["default"].Buffer,
45591
- Transform = require$$1__default$3["default"].Transform;
45442
+ var Buffer$3 = require$$0__default$1["default"].Buffer,
45443
+ Transform = require$$1__default$2["default"].Transform;
45592
45444
 
45593
45445
 
45594
45446
  // == Exports ==================================================================
@@ -45706,7 +45558,7 @@ IconvLiteDecoderStream.prototype.collect = function(cb) {
45706
45558
  return this;
45707
45559
  };
45708
45560
 
45709
- var Buffer$2 = require$$0__default$2["default"].Buffer;
45561
+ var Buffer$2 = require$$0__default$1["default"].Buffer;
45710
45562
  // Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer
45711
45563
 
45712
45564
  // == Extend Node primitives to use iconv-lite =================================
@@ -45739,7 +45591,7 @@ var extendNode = function (iconv) {
45739
45591
  };
45740
45592
 
45741
45593
  // -- SlowBuffer -----------------------------------------------------------
45742
- var SlowBuffer = require$$0__default$2["default"].SlowBuffer;
45594
+ var SlowBuffer = require$$0__default$1["default"].SlowBuffer;
45743
45595
 
45744
45596
  original.SlowBufferToString = SlowBuffer.prototype.toString;
45745
45597
  SlowBuffer.prototype.toString = function(encoding, start, end) {
@@ -45879,7 +45731,7 @@ var extendNode = function (iconv) {
45879
45731
 
45880
45732
  // -- Readable -------------------------------------------------------------
45881
45733
  if (iconv.supportsStreams) {
45882
- var Readable = require$$1__default$3["default"].Readable;
45734
+ var Readable = require$$1__default$2["default"].Readable;
45883
45735
 
45884
45736
  original.ReadableSetEncoding = Readable.prototype.setEncoding;
45885
45737
  Readable.prototype.setEncoding = function setEncoding(enc, options) {
@@ -45902,7 +45754,7 @@ var extendNode = function (iconv) {
45902
45754
 
45903
45755
  delete Buffer$2.isNativeEncoding;
45904
45756
 
45905
- var SlowBuffer = require$$0__default$2["default"].SlowBuffer;
45757
+ var SlowBuffer = require$$0__default$1["default"].SlowBuffer;
45906
45758
 
45907
45759
  SlowBuffer.prototype.toString = original.SlowBufferToString;
45908
45760
  SlowBuffer.prototype.write = original.SlowBufferWrite;
@@ -45913,7 +45765,7 @@ var extendNode = function (iconv) {
45913
45765
  Buffer$2.prototype.write = original.BufferWrite;
45914
45766
 
45915
45767
  if (iconv.supportsStreams) {
45916
- var Readable = require$$1__default$3["default"].Readable;
45768
+ var Readable = require$$1__default$2["default"].Readable;
45917
45769
 
45918
45770
  Readable.prototype.setEncoding = original.ReadableSetEncoding;
45919
45771
  delete Readable.prototype.collect;
@@ -47004,7 +46856,7 @@ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
47004
46856
  return intrinsic;
47005
46857
  };
47006
46858
 
47007
- var util_inspect = require$$0__default$1["default"].inspect;
46859
+ var util_inspect = require$$1__default["default"].inspect;
47008
46860
 
47009
46861
  var hasMap = typeof Map === 'function' && Map.prototype;
47010
46862
  var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
@@ -48588,8 +48440,8 @@ var incoming_form = {};
48588
48440
 
48589
48441
  if (commonjsGlobal.GENTLY) commonjsRequire = GENTLY.hijack(commonjsRequire);
48590
48442
 
48591
- var util$2 = require$$0__default$1["default"],
48592
- fs$2 = require$$1__default$2["default"],
48443
+ var util$2 = require$$1__default["default"],
48444
+ fs$2 = require$$0__default$2["default"],
48593
48445
  EventEmitter$5 = require$$0__default$3["default"].EventEmitter,
48594
48446
  crypto$1 = require$$0__default$4["default"];
48595
48447
 
@@ -48671,7 +48523,7 @@ File$1.prototype.end = function(cb) {
48671
48523
  var multipart_parser = {};
48672
48524
 
48673
48525
  (function (exports) {
48674
- var Buffer = require$$0__default$2["default"].Buffer,
48526
+ var Buffer = require$$0__default$1["default"].Buffer,
48675
48527
  s = 0,
48676
48528
  S =
48677
48529
  { PARSER_UNINITIALIZED: s++,
@@ -49037,7 +48889,7 @@ QuerystringParser$1.prototype.end = function() {
49037
48889
  var octet_parser = {};
49038
48890
 
49039
48891
  var EventEmitter$4 = require$$0__default$3["default"].EventEmitter
49040
- , util$1 = require$$0__default$1["default"];
48892
+ , util$1 = require$$1__default["default"];
49041
48893
 
49042
48894
  function OctetParser$1(options){
49043
48895
  if(!(this instanceof OctetParser$1)) return new OctetParser$1(options);
@@ -49061,7 +48913,7 @@ var json_parser = {};
49061
48913
 
49062
48914
  if (commonjsGlobal.GENTLY) commonjsRequire = GENTLY.hijack(commonjsRequire);
49063
48915
 
49064
- var Buffer$1 = require$$0__default$2["default"].Buffer;
48916
+ var Buffer$1 = require$$0__default$1["default"].Buffer;
49065
48917
 
49066
48918
  function JSONParser$1(parent) {
49067
48919
  this.parent = parent;
@@ -49093,8 +48945,8 @@ JSONParser$1.prototype.end = function() {
49093
48945
  if (commonjsGlobal.GENTLY) commonjsRequire = GENTLY.hijack(commonjsRequire);
49094
48946
 
49095
48947
  var crypto = require$$0__default$4["default"];
49096
- var fs$1 = require$$1__default$2["default"];
49097
- var util = require$$0__default$1["default"],
48948
+ var fs$1 = require$$0__default$2["default"];
48949
+ var util = require$$1__default["default"],
49098
48950
  path$1 = require$$1__default$1["default"],
49099
48951
  File = file,
49100
48952
  MultipartParser = multipart_parser.MultipartParser,
@@ -49103,8 +48955,8 @@ var util = require$$0__default$1["default"],
49103
48955
  JSONParser = json_parser.JSONParser,
49104
48956
  StringDecoder = require$$1__default$4["default"].StringDecoder,
49105
48957
  EventEmitter$3 = require$$0__default$3["default"].EventEmitter,
49106
- Stream = require$$1__default$3["default"].Stream,
49107
- os = require$$1__default["default"];
48958
+ Stream = require$$1__default$2["default"].Stream,
48959
+ os = require$$1__default$3["default"];
49108
48960
 
49109
48961
  function IncomingForm$1(opts) {
49110
48962
  if (!(this instanceof IncomingForm$1)) return new IncomingForm$1(opts);
@@ -52262,7 +52114,7 @@ suggestSimilar$2.suggestSimilar = suggestSimilar$1;
52262
52114
  const EventEmitter$2 = require$$0__default$3["default"].EventEmitter;
52263
52115
  const childProcess = require$$1__default$5["default"];
52264
52116
  const path = require$$1__default$1["default"];
52265
- const fs = require$$1__default$2["default"];
52117
+ const fs = require$$0__default$2["default"];
52266
52118
 
52267
52119
  const { Argument, humanReadableArgName } = argument;
52268
52120
  const { CommanderError } = error$1;
@@ -54211,22 +54063,23 @@ exports.InvalidOptionArgumentError = InvalidArgumentError; // Deprecated
54211
54063
  exports.Option = Option;
54212
54064
  }(commander, commander.exports));
54213
54065
 
54214
- dotenv__default["default"].config({ path: require$$1$2.resolve(require$$1$1.homedir(), ".nodestatus/.env.local") });
54215
- commander.exports.program.option("-db, --database <db>", "the path of database", require$$1$1.platform() === "win32" ? require$$1$2.resolve(require$$1$1.homedir(), ".nodestatus/db.sqlite") : "/usr/local/NodeStatus/server/db.sqlite").option("-p, --port <port>", "the port of NodeStatus", "35601").option("-i, --interval <interval>", "update interval", "1500").parse(process.argv);
54066
+ dotenv__default["default"].config({ path: require$$1$2.resolve(require$$1$4.homedir(), ".nodestatus/.env.local") });
54067
+ commander.exports.program.option("-db, --database <db>", "the path of database", require$$1$4.platform() === "win32" ? require$$1$2.resolve(require$$1$4.homedir(), ".nodestatus/db.sqlite") : "/usr/local/NodeStatus/server/db.sqlite").option("-p, --port <port>", "the port of NodeStatus", "35601").option("-i, --interval <interval>", "update interval", "1500").parse(process.argv);
54216
54068
  const options = commander.exports.program.opts();
54217
54069
  const config = {
54218
54070
  NODE_ENV: process.env.NODE_ENV,
54219
54071
  database: process.env.DATABASE || (process.env.NODE_ENV === "TEST" ? require$$1$2.resolve(__dirname, "../../db.base.sqlite") : options.database),
54220
- port: process.env.PORT || options.port,
54221
- interval: process.env.INTERVAL || options.interval,
54072
+ port: Number(process.env.PORT || options.port),
54073
+ interval: Number(process.env.INTERVAL || options.interval),
54222
54074
  useIpc: process.env.USE_IPC !== "false",
54223
54075
  useWeb: process.env.USE_WEB !== "false",
54224
54076
  usePush: process.env.USE_PUSH !== "false",
54225
54077
  webUsername: process.env.WEB_USERNAME || "admin",
54226
54078
  webPassword: process.env.WEB_PASSWORD || "",
54227
54079
  webSecret: process.env.WEB_SECRET || process.env.WEB_PASSWORD || "secret",
54228
- ipcAddress: process.env.IPC_ADDRESS || (require$$1$1.platform() !== "win32" ? "/tmp/status_unix.sock" : "\\\\.\\pipe\\status_ipc"),
54080
+ ipcAddress: process.env.IPC_ADDRESS || (require$$1$4.platform() !== "win32" ? "/tmp/status_unix.sock" : "\\\\.\\pipe\\status_ipc"),
54229
54081
  pushTimeOut: Number(process.env.PUSH_TIMEOUT) || 30,
54082
+ pushDelay: Number(process.env.PUSH_DELAY) || 15,
54230
54083
  telegram: {
54231
54084
  proxy: process.env.TGBOT_PROXY,
54232
54085
  bot_token: process.env.TGBOT_TOKEN || "",
@@ -54234,11 +54087,11 @@ const config = {
54234
54087
  web_hook: process.env.TGBOT_WEBHOOK
54235
54088
  }
54236
54089
  };
54237
- if (Number.isNaN(parseInt(config.port, 10))) {
54090
+ if (Number.isNaN(config.port)) {
54238
54091
  logger.fatal("Please enter the correct port number.");
54239
54092
  process.exit(1);
54240
54093
  }
54241
- if (Number.isNaN(parseInt(config.interval, 10))) {
54094
+ if (Number.isNaN(config.interval)) {
54242
54095
  logger.fatal("Please enter the correct interval.");
54243
54096
  process.exit(1);
54244
54097
  }
@@ -54355,7 +54208,7 @@ var bcrypt = {exports: {}};
54355
54208
  function random(len) {
54356
54209
  /* node */ if (module && module['exports'])
54357
54210
  try {
54358
- return require$$0__default$4["default"]['randomBytes'](len);
54211
+ return require("crypto")['randomBytes'](len);
54359
54212
  } catch (e) {}
54360
54213
  /* WCA */ try {
54361
54214
  var a; (self['crypto']||self['msCrypto'])['getRandomValues'](a = new Uint32Array(len));
@@ -55895,102 +55748,6 @@ router.put("/server", setServer$1);
55895
55748
  router.put("/server/order", modifyOrder);
55896
55749
  router.delete("/server/:username", delServer$1);
55897
55750
 
55898
- async function handleRequest(handler) {
55899
- let data;
55900
- try {
55901
- data = await handler;
55902
- } catch (error) {
55903
- return createRes(1, error.message);
55904
- }
55905
- return createRes({ data });
55906
- }
55907
- async function authServer(username, password) {
55908
- const res = await handleRequest(getServerPassword(username));
55909
- if (res.code || !res.data)
55910
- return false;
55911
- return bcryptjs.compare(password, res.data);
55912
- }
55913
- function addServer(obj) {
55914
- return handleRequest(createServer(obj));
55915
- }
55916
- function setServer(username, obj) {
55917
- return handleRequest(setServer$2(username, obj));
55918
- }
55919
- function delServer(username) {
55920
- return handleRequest(delServer$2(username));
55921
- }
55922
- async function getListServers() {
55923
- const result = await handleRequest(getListServers$1());
55924
- if (result.code)
55925
- return result;
55926
- const obj = {};
55927
- result.data.forEach((item) => {
55928
- const { username, disabled, ..._item } = item;
55929
- if (disabled)
55930
- return;
55931
- obj[username] = _item;
55932
- });
55933
- return createRes({ data: obj });
55934
- }
55935
- async function getServer(username) {
55936
- const result = await handleRequest(getServer$1(username));
55937
- if (result.code || !result.data)
55938
- return result;
55939
- const { data } = result;
55940
- const { username: _, disabled, ...item } = data;
55941
- if (disabled)
55942
- return createRes(1, "Server disabled");
55943
- return createRes({ data: item });
55944
- }
55945
- function getRawListServers() {
55946
- return handleRequest(getListServers$1());
55947
- }
55948
-
55949
- function createIpc() {
55950
- return require$$3__default["default"].createServer((client) => {
55951
- client.on("data", async (buf) => {
55952
- try {
55953
- const [method, payload] = buf.toString().trim().split(" @;@ ");
55954
- switch (method) {
55955
- case "add": {
55956
- const data = JSON.parse(payload);
55957
- const status = await addServer(data);
55958
- client.write(JSON.stringify(status));
55959
- break;
55960
- }
55961
- case "list": {
55962
- const status = await getRawListServers();
55963
- client.write(JSON.stringify(status));
55964
- break;
55965
- }
55966
- case "set": {
55967
- const obj = JSON.parse(payload);
55968
- const { username } = obj;
55969
- delete obj.username;
55970
- if (obj.newUserName) {
55971
- obj.username = obj.newUserName;
55972
- delete obj.newUserName;
55973
- }
55974
- const status = await setServer(username, obj);
55975
- client.write(JSON.stringify(status));
55976
- break;
55977
- }
55978
- case "del": {
55979
- const status = await delServer(payload);
55980
- client.write(JSON.stringify(status));
55981
- break;
55982
- }
55983
- default: {
55984
- client.write(JSON.stringify(createRes(1, "Unknown Method")));
55985
- }
55986
- }
55987
- } catch (error) {
55988
- client.write(JSON.stringify(createRes(1, error.message)));
55989
- }
55990
- });
55991
- });
55992
- }
55993
-
55994
55751
  var bufferUtil$1 = {exports: {}};
55995
55752
 
55996
55753
  var constants = {
@@ -56104,7 +55861,7 @@ function toBuffer$2(data) {
56104
55861
  }
56105
55862
 
56106
55863
  try {
56107
- const bufferUtil = require$$1__default$6["default"];
55864
+ const bufferUtil = require('bufferutil');
56108
55865
 
56109
55866
  bufferUtil$1.exports = {
56110
55867
  concat: concat$1,
@@ -56801,7 +56558,7 @@ function _isValidUTF8(buf) {
56801
56558
  }
56802
56559
 
56803
56560
  try {
56804
- const isValidUTF8 = require$$0__default$8["default"];
56561
+ const isValidUTF8 = require('utf-8-validate');
56805
56562
 
56806
56563
  validation.exports = {
56807
56564
  isValidStatusCode: isValidStatusCode$2,
@@ -56818,7 +56575,7 @@ try {
56818
56575
  };
56819
56576
  }
56820
56577
 
56821
- const { Writable } = require$$1__default$3["default"];
56578
+ const { Writable } = require$$1__default$2["default"];
56822
56579
 
56823
56580
  const PerMessageDeflate$3 = permessageDeflate;
56824
56581
  const {
@@ -58309,7 +58066,7 @@ var extension$1 = { format: format$1, parse: parse$2 };
58309
58066
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
58310
58067
 
58311
58068
  const EventEmitter$1 = require$$0__default$3["default"];
58312
- const https = require$$1__default$7["default"];
58069
+ const https = require$$1__default$6["default"];
58313
58070
  const http$1 = require$$2__default["default"];
58314
58071
  const net = require$$3__default["default"];
58315
58072
  const tls = require$$4__default["default"];
@@ -59453,7 +59210,7 @@ function socketOnError$1() {
59453
59210
  }
59454
59211
  }
59455
59212
 
59456
- const { Duplex } = require$$1__default$3["default"];
59213
+ const { Duplex } = require$$1__default$2["default"];
59457
59214
 
59458
59215
  /**
59459
59216
  * Emits the `'close'` event on a stream.
@@ -61314,643 +61071,161 @@ function decode(buffer, options) {
61314
61071
  return decoder.decode(buffer);
61315
61072
  }
61316
61073
 
61317
- var agent = {};
61074
+ var ipaddr = {exports: {}};
61318
61075
 
61319
- var promisify$1 = {};
61076
+ (function (module) {
61077
+ (function (root) {
61078
+ // A list of regular expressions that match arbitrary IPv4 addresses,
61079
+ // for which a number of weird notations exist.
61080
+ // Note that an address like 0010.0xa5.1.1 is considered legal.
61081
+ const ipv4Part = '(0?\\d+|0x[a-f0-9]+)';
61082
+ const ipv4Regexes = {
61083
+ fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, 'i'),
61084
+ threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, 'i'),
61085
+ twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, 'i'),
61086
+ longValue: new RegExp(`^${ipv4Part}$`, 'i')
61087
+ };
61320
61088
 
61321
- Object.defineProperty(promisify$1, "__esModule", { value: true });
61322
- function promisify(fn) {
61323
- return function (req, opts) {
61324
- return new Promise((resolve, reject) => {
61325
- fn.call(this, req, opts, (err, rtn) => {
61326
- if (err) {
61327
- reject(err);
61328
- }
61329
- else {
61330
- resolve(rtn);
61331
- }
61332
- });
61333
- });
61089
+ // Regular Expression for checking Octal numbers
61090
+ const octalRegex = new RegExp(`^0[0-7]+$`, 'i');
61091
+ const hexRegex = new RegExp(`^0x[a-f0-9]+$`, 'i');
61092
+
61093
+ const zoneIndex = '%[0-9a-z]{1,}';
61094
+
61095
+ // IPv6-matching regular expressions.
61096
+ // For IPv6, the task is simpler: it is enough to match the colon-delimited
61097
+ // hexadecimal IPv6 and a transitional variant with dotted-decimal IPv4 at
61098
+ // the end.
61099
+ const ipv6Part = '(?:[0-9a-f]+::?)+';
61100
+ const ipv6Regexes = {
61101
+ zoneIndex: new RegExp(zoneIndex, 'i'),
61102
+ 'native': new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, 'i'),
61103
+ deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, 'i'),
61104
+ transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, 'i')
61334
61105
  };
61335
- }
61336
- promisify$1.default = promisify;
61337
61106
 
61338
- var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
61339
- return (mod && mod.__esModule) ? mod : { "default": mod };
61340
- };
61341
- const events_1 = require$$0__default$3["default"];
61342
- const debug_1$2 = __importDefault$3(src$2.exports);
61343
- const promisify_1 = __importDefault$3(promisify$1);
61344
- const debug$2 = debug_1$2.default('agent-base');
61345
- function isAgent(v) {
61346
- return Boolean(v) && typeof v.addRequest === 'function';
61347
- }
61348
- function isSecureEndpoint() {
61349
- const { stack } = new Error();
61350
- if (typeof stack !== 'string')
61351
- return false;
61352
- return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
61353
- }
61354
- function createAgent(callback, opts) {
61355
- return new createAgent.Agent(callback, opts);
61356
- }
61357
- (function (createAgent) {
61358
- /**
61359
- * Base `http.Agent` implementation.
61360
- * No pooling/keep-alive is implemented by default.
61361
- *
61362
- * @param {Function} callback
61363
- * @api public
61364
- */
61365
- class Agent extends events_1.EventEmitter {
61366
- constructor(callback, _opts) {
61367
- super();
61368
- let opts = _opts;
61369
- if (typeof callback === 'function') {
61370
- this.callback = callback;
61371
- }
61372
- else if (callback) {
61373
- opts = callback;
61374
- }
61375
- // Timeout for the socket to be returned from the callback
61376
- this.timeout = null;
61377
- if (opts && typeof opts.timeout === 'number') {
61378
- this.timeout = opts.timeout;
61379
- }
61380
- // These aren't actually used by `agent-base`, but are required
61381
- // for the TypeScript definition files in `@types/node` :/
61382
- this.maxFreeSockets = 1;
61383
- this.maxSockets = 1;
61384
- this.maxTotalSockets = Infinity;
61385
- this.sockets = {};
61386
- this.freeSockets = {};
61387
- this.requests = {};
61388
- this.options = {};
61107
+ // Expand :: in an IPv6 address or address part consisting of `parts` groups.
61108
+ function expandIPv6 (string, parts) {
61109
+ // More than one '::' means invalid adddress
61110
+ if (string.indexOf('::') !== string.lastIndexOf('::')) {
61111
+ return null;
61389
61112
  }
61390
- get defaultPort() {
61391
- if (typeof this.explicitDefaultPort === 'number') {
61392
- return this.explicitDefaultPort;
61393
- }
61394
- return isSecureEndpoint() ? 443 : 80;
61113
+
61114
+ let colonCount = 0;
61115
+ let lastColon = -1;
61116
+ let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
61117
+ let replacement, replacementCount;
61118
+
61119
+ // Remove zone index and save it for later
61120
+ if (zoneId) {
61121
+ zoneId = zoneId.substring(1);
61122
+ string = string.replace(/%.+$/, '');
61395
61123
  }
61396
- set defaultPort(v) {
61397
- this.explicitDefaultPort = v;
61124
+
61125
+ // How many parts do we already have?
61126
+ while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {
61127
+ colonCount++;
61398
61128
  }
61399
- get protocol() {
61400
- if (typeof this.explicitProtocol === 'string') {
61401
- return this.explicitProtocol;
61402
- }
61403
- return isSecureEndpoint() ? 'https:' : 'http:';
61129
+
61130
+ // 0::0 is two parts more than ::
61131
+ if (string.substr(0, 2) === '::') {
61132
+ colonCount--;
61404
61133
  }
61405
- set protocol(v) {
61406
- this.explicitProtocol = v;
61134
+
61135
+ if (string.substr(-2, 2) === '::') {
61136
+ colonCount--;
61407
61137
  }
61408
- callback(req, opts, fn) {
61409
- throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
61138
+
61139
+ // The following loop would hang if colonCount > parts
61140
+ if (colonCount > parts) {
61141
+ return null;
61410
61142
  }
61411
- /**
61412
- * Called by node-core's "_http_client.js" module when creating
61413
- * a new HTTP request with this Agent instance.
61414
- *
61415
- * @api public
61416
- */
61417
- addRequest(req, _opts) {
61418
- const opts = Object.assign({}, _opts);
61419
- if (typeof opts.secureEndpoint !== 'boolean') {
61420
- opts.secureEndpoint = isSecureEndpoint();
61421
- }
61422
- if (opts.host == null) {
61423
- opts.host = 'localhost';
61424
- }
61425
- if (opts.port == null) {
61426
- opts.port = opts.secureEndpoint ? 443 : 80;
61427
- }
61428
- if (opts.protocol == null) {
61429
- opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
61430
- }
61431
- if (opts.host && opts.path) {
61432
- // If both a `host` and `path` are specified then it's most
61433
- // likely the result of a `url.parse()` call... we need to
61434
- // remove the `path` portion so that `net.connect()` doesn't
61435
- // attempt to open that as a unix socket file.
61436
- delete opts.path;
61437
- }
61438
- delete opts.agent;
61439
- delete opts.hostname;
61440
- delete opts._defaultAgent;
61441
- delete opts.defaultPort;
61442
- delete opts.createConnection;
61443
- // Hint to use "Connection: close"
61444
- // XXX: non-documented `http` module API :(
61445
- req._last = true;
61446
- req.shouldKeepAlive = false;
61447
- let timedOut = false;
61448
- let timeoutId = null;
61449
- const timeoutMs = opts.timeout || this.timeout;
61450
- const onerror = (err) => {
61451
- if (req._hadError)
61452
- return;
61453
- req.emit('error', err);
61454
- // For Safety. Some additional errors might fire later on
61455
- // and we need to make sure we don't double-fire the error event.
61456
- req._hadError = true;
61457
- };
61458
- const ontimeout = () => {
61459
- timeoutId = null;
61460
- timedOut = true;
61461
- const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
61462
- err.code = 'ETIMEOUT';
61463
- onerror(err);
61464
- };
61465
- const callbackError = (err) => {
61466
- if (timedOut)
61467
- return;
61468
- if (timeoutId !== null) {
61469
- clearTimeout(timeoutId);
61470
- timeoutId = null;
61471
- }
61472
- onerror(err);
61473
- };
61474
- const onsocket = (socket) => {
61475
- if (timedOut)
61476
- return;
61477
- if (timeoutId != null) {
61478
- clearTimeout(timeoutId);
61479
- timeoutId = null;
61480
- }
61481
- if (isAgent(socket)) {
61482
- // `socket` is actually an `http.Agent` instance, so
61483
- // relinquish responsibility for this `req` to the Agent
61484
- // from here on
61485
- debug$2('Callback returned another Agent instance %o', socket.constructor.name);
61486
- socket.addRequest(req, opts);
61487
- return;
61488
- }
61489
- if (socket) {
61490
- socket.once('free', () => {
61491
- this.freeSocket(socket, opts);
61492
- });
61493
- req.onSocket(socket);
61494
- return;
61495
- }
61496
- const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
61497
- onerror(err);
61498
- };
61499
- if (typeof this.callback !== 'function') {
61500
- onerror(new Error('`callback` is not defined'));
61501
- return;
61502
- }
61503
- if (!this.promisifiedCallback) {
61504
- if (this.callback.length >= 3) {
61505
- debug$2('Converting legacy callback function to promise');
61506
- this.promisifiedCallback = promisify_1.default(this.callback);
61507
- }
61508
- else {
61509
- this.promisifiedCallback = this.callback;
61510
- }
61511
- }
61512
- if (typeof timeoutMs === 'number' && timeoutMs > 0) {
61513
- timeoutId = setTimeout(ontimeout, timeoutMs);
61514
- }
61515
- if ('port' in opts && typeof opts.port !== 'number') {
61516
- opts.port = Number(opts.port);
61143
+
61144
+ // replacement = ':' + '0:' * (parts - colonCount)
61145
+ replacementCount = parts - colonCount;
61146
+ replacement = ':';
61147
+ while (replacementCount--) {
61148
+ replacement += '0:';
61149
+ }
61150
+
61151
+ // Insert the missing zeroes
61152
+ string = string.replace('::', replacement);
61153
+
61154
+ // Trim any garbage which may be hanging around if :: was at the edge in
61155
+ // the source strin
61156
+ if (string[0] === ':') {
61157
+ string = string.slice(1);
61158
+ }
61159
+
61160
+ if (string[string.length - 1] === ':') {
61161
+ string = string.slice(0, -1);
61162
+ }
61163
+
61164
+ parts = (function () {
61165
+ const ref = string.split(':');
61166
+ const results = [];
61167
+
61168
+ for (let i = 0; i < ref.length; i++) {
61169
+ results.push(parseInt(ref[i], 16));
61517
61170
  }
61518
- try {
61519
- debug$2('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
61520
- Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
61171
+
61172
+ return results;
61173
+ })();
61174
+
61175
+ return {
61176
+ parts: parts,
61177
+ zoneId: zoneId
61178
+ };
61179
+ }
61180
+
61181
+ // A generic CIDR (Classless Inter-Domain Routing) RFC1518 range matcher.
61182
+ function matchCIDR (first, second, partSize, cidrBits) {
61183
+ if (first.length !== second.length) {
61184
+ throw new Error('ipaddr: cannot match CIDR for objects with different lengths');
61185
+ }
61186
+
61187
+ let part = 0;
61188
+ let shift;
61189
+
61190
+ while (cidrBits > 0) {
61191
+ shift = partSize - cidrBits;
61192
+ if (shift < 0) {
61193
+ shift = 0;
61521
61194
  }
61522
- catch (err) {
61523
- Promise.reject(err).catch(callbackError);
61195
+
61196
+ if (first[part] >> shift !== second[part] >> shift) {
61197
+ return false;
61524
61198
  }
61199
+
61200
+ cidrBits -= partSize;
61201
+ part += 1;
61525
61202
  }
61526
- freeSocket(socket, opts) {
61527
- debug$2('Freeing socket %o %o', socket.constructor.name, opts);
61528
- socket.destroy();
61203
+
61204
+ return true;
61205
+ }
61206
+
61207
+ function parseIntAuto (string) {
61208
+ // Hexadedimal base 16 (0x#)
61209
+ if (hexRegex.test(string)) {
61210
+ return parseInt(string, 16);
61529
61211
  }
61530
- destroy() {
61531
- debug$2('Destroying agent %o', this.constructor.name);
61212
+ // While octal representation is discouraged by ECMAScript 3
61213
+ // and forbidden by ECMAScript 5, we silently allow it to
61214
+ // work only if the rest of the string has numbers less than 8.
61215
+ if (string[0] === '0' && !isNaN(parseInt(string[1], 10))) {
61216
+ if (octalRegex.test(string)) {
61217
+ return parseInt(string, 8);
61218
+ }
61219
+ throw new Error(`ipaddr: cannot parse ${string} as octal`);
61532
61220
  }
61221
+ // Always include the base 10 radix!
61222
+ return parseInt(string, 10);
61533
61223
  }
61534
- createAgent.Agent = Agent;
61535
- // So that `instanceof` works correctly
61536
- createAgent.prototype = createAgent.Agent.prototype;
61537
- })(createAgent || (createAgent = {}));
61538
- var src = createAgent;
61539
61224
 
61540
- var parseProxyResponse$1 = {};
61541
-
61542
- var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
61543
- return (mod && mod.__esModule) ? mod : { "default": mod };
61544
- };
61545
- Object.defineProperty(parseProxyResponse$1, "__esModule", { value: true });
61546
- const debug_1$1 = __importDefault$2(src$2.exports);
61547
- const debug$1 = debug_1$1.default('https-proxy-agent:parse-proxy-response');
61548
- function parseProxyResponse(socket) {
61549
- return new Promise((resolve, reject) => {
61550
- // we need to buffer any HTTP traffic that happens with the proxy before we get
61551
- // the CONNECT response, so that if the response is anything other than an "200"
61552
- // response code, then we can re-play the "data" events on the socket once the
61553
- // HTTP parser is hooked up...
61554
- let buffersLength = 0;
61555
- const buffers = [];
61556
- function read() {
61557
- const b = socket.read();
61558
- if (b)
61559
- ondata(b);
61560
- else
61561
- socket.once('readable', read);
61562
- }
61563
- function cleanup() {
61564
- socket.removeListener('end', onend);
61565
- socket.removeListener('error', onerror);
61566
- socket.removeListener('close', onclose);
61567
- socket.removeListener('readable', read);
61568
- }
61569
- function onclose(err) {
61570
- debug$1('onclose had error %o', err);
61571
- }
61572
- function onend() {
61573
- debug$1('onend');
61574
- }
61575
- function onerror(err) {
61576
- cleanup();
61577
- debug$1('onerror %o', err);
61578
- reject(err);
61579
- }
61580
- function ondata(b) {
61581
- buffers.push(b);
61582
- buffersLength += b.length;
61583
- const buffered = Buffer.concat(buffers, buffersLength);
61584
- const endOfHeaders = buffered.indexOf('\r\n\r\n');
61585
- if (endOfHeaders === -1) {
61586
- // keep buffering
61587
- debug$1('have not received end of HTTP headers yet...');
61588
- read();
61589
- return;
61590
- }
61591
- const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
61592
- const statusCode = +firstLine.split(' ')[1];
61593
- debug$1('got proxy server response: %o', firstLine);
61594
- resolve({
61595
- statusCode,
61596
- buffered
61597
- });
61598
- }
61599
- socket.on('error', onerror);
61600
- socket.on('close', onclose);
61601
- socket.on('end', onend);
61602
- read();
61603
- });
61604
- }
61605
- parseProxyResponse$1.default = parseProxyResponse;
61606
-
61607
- var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
61608
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
61609
- return new (P || (P = Promise))(function (resolve, reject) {
61610
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
61611
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
61612
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
61613
- step((generator = generator.apply(thisArg, _arguments || [])).next());
61614
- });
61615
- };
61616
- var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
61617
- return (mod && mod.__esModule) ? mod : { "default": mod };
61618
- };
61619
- Object.defineProperty(agent, "__esModule", { value: true });
61620
- const net_1 = __importDefault$1(require$$3__default["default"]);
61621
- const tls_1 = __importDefault$1(require$$4__default["default"]);
61622
- const url_1 = __importDefault$1(require$$0__default$5["default"]);
61623
- const assert_1 = __importDefault$1(require$$5__default["default"]);
61624
- const debug_1 = __importDefault$1(src$2.exports);
61625
- const agent_base_1 = src;
61626
- const parse_proxy_response_1 = __importDefault$1(parseProxyResponse$1);
61627
- const debug = debug_1.default('https-proxy-agent:agent');
61628
- /**
61629
- * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
61630
- * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
61631
- *
61632
- * Outgoing HTTP requests are first tunneled through the proxy server using the
61633
- * `CONNECT` HTTP request method to establish a connection to the proxy server,
61634
- * and then the proxy server connects to the destination target and issues the
61635
- * HTTP request from the proxy server.
61636
- *
61637
- * `https:` requests have their socket connection upgraded to TLS once
61638
- * the connection to the proxy server has been established.
61639
- *
61640
- * @api public
61641
- */
61642
- class HttpsProxyAgent extends agent_base_1.Agent {
61643
- constructor(_opts) {
61644
- let opts;
61645
- if (typeof _opts === 'string') {
61646
- opts = url_1.default.parse(_opts);
61647
- }
61648
- else {
61649
- opts = _opts;
61650
- }
61651
- if (!opts) {
61652
- throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
61653
- }
61654
- debug('creating new HttpsProxyAgent instance: %o', opts);
61655
- super(opts);
61656
- const proxy = Object.assign({}, opts);
61657
- // If `true`, then connect to the proxy server over TLS.
61658
- // Defaults to `false`.
61659
- this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
61660
- // Prefer `hostname` over `host`, and set the `port` if needed.
61661
- proxy.host = proxy.hostname || proxy.host;
61662
- if (typeof proxy.port === 'string') {
61663
- proxy.port = parseInt(proxy.port, 10);
61664
- }
61665
- if (!proxy.port && proxy.host) {
61666
- proxy.port = this.secureProxy ? 443 : 80;
61667
- }
61668
- // ALPN is supported by Node.js >= v5.
61669
- // attempt to negotiate http/1.1 for proxy servers that support http/2
61670
- if (this.secureProxy && !('ALPNProtocols' in proxy)) {
61671
- proxy.ALPNProtocols = ['http 1.1'];
61672
- }
61673
- if (proxy.host && proxy.path) {
61674
- // If both a `host` and `path` are specified then it's most likely
61675
- // the result of a `url.parse()` call... we need to remove the
61676
- // `path` portion so that `net.connect()` doesn't attempt to open
61677
- // that as a Unix socket file.
61678
- delete proxy.path;
61679
- delete proxy.pathname;
61680
- }
61681
- this.proxy = proxy;
61682
- }
61683
- /**
61684
- * Called when the node-core HTTP client library is creating a
61685
- * new HTTP request.
61686
- *
61687
- * @api protected
61688
- */
61689
- callback(req, opts) {
61690
- return __awaiter(this, void 0, void 0, function* () {
61691
- const { proxy, secureProxy } = this;
61692
- // Create a socket connection to the proxy server.
61693
- let socket;
61694
- if (secureProxy) {
61695
- debug('Creating `tls.Socket`: %o', proxy);
61696
- socket = tls_1.default.connect(proxy);
61697
- }
61698
- else {
61699
- debug('Creating `net.Socket`: %o', proxy);
61700
- socket = net_1.default.connect(proxy);
61701
- }
61702
- const headers = Object.assign({}, proxy.headers);
61703
- const hostname = `${opts.host}:${opts.port}`;
61704
- let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
61705
- // Inject the `Proxy-Authorization` header if necessary.
61706
- if (proxy.auth) {
61707
- headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
61708
- }
61709
- // The `Host` header should only include the port
61710
- // number when it is not the default port.
61711
- let { host, port, secureEndpoint } = opts;
61712
- if (!isDefaultPort(port, secureEndpoint)) {
61713
- host += `:${port}`;
61714
- }
61715
- headers.Host = host;
61716
- headers.Connection = 'close';
61717
- for (const name of Object.keys(headers)) {
61718
- payload += `${name}: ${headers[name]}\r\n`;
61719
- }
61720
- const proxyResponsePromise = parse_proxy_response_1.default(socket);
61721
- socket.write(`${payload}\r\n`);
61722
- const { statusCode, buffered } = yield proxyResponsePromise;
61723
- if (statusCode === 200) {
61724
- req.once('socket', resume);
61725
- if (opts.secureEndpoint) {
61726
- const servername = opts.servername || opts.host;
61727
- if (!servername) {
61728
- throw new Error('Could not determine "servername"');
61729
- }
61730
- // The proxy is connecting to a TLS server, so upgrade
61731
- // this socket connection to a TLS connection.
61732
- debug('Upgrading socket connection to TLS');
61733
- return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
61734
- servername }));
61735
- }
61736
- return socket;
61737
- }
61738
- // Some other status code that's not 200... need to re-play the HTTP
61739
- // header "data" events onto the socket once the HTTP machinery is
61740
- // attached so that the node core `http` can parse and handle the
61741
- // error status code.
61742
- // Close the original socket, and a new "fake" socket is returned
61743
- // instead, so that the proxy doesn't get the HTTP request
61744
- // written to it (which may contain `Authorization` headers or other
61745
- // sensitive data).
61746
- //
61747
- // See: https://hackerone.com/reports/541502
61748
- socket.destroy();
61749
- const fakeSocket = new net_1.default.Socket();
61750
- fakeSocket.readable = true;
61751
- // Need to wait for the "socket" event to re-play the "data" events.
61752
- req.once('socket', (s) => {
61753
- debug('replaying proxy buffer for failed request');
61754
- assert_1.default(s.listenerCount('data') > 0);
61755
- // Replay the "buffered" Buffer onto the fake `socket`, since at
61756
- // this point the HTTP module machinery has been hooked up for
61757
- // the user.
61758
- s.push(buffered);
61759
- s.push(null);
61760
- });
61761
- return fakeSocket;
61762
- });
61763
- }
61764
- }
61765
- agent.default = HttpsProxyAgent;
61766
- function resume(socket) {
61767
- socket.resume();
61768
- }
61769
- function isDefaultPort(port, secure) {
61770
- return Boolean((!secure && port === 80) || (secure && port === 443));
61771
- }
61772
- function isHTTPS(protocol) {
61773
- return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
61774
- }
61775
- function omit(obj, ...keys) {
61776
- const ret = {};
61777
- let key;
61778
- for (key in obj) {
61779
- if (!keys.includes(key)) {
61780
- ret[key] = obj[key];
61781
- }
61782
- }
61783
- return ret;
61784
- }
61785
-
61786
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
61787
- return (mod && mod.__esModule) ? mod : { "default": mod };
61788
- };
61789
- const agent_1 = __importDefault(agent);
61790
- function createHttpsProxyAgent(opts) {
61791
- return new agent_1.default(opts);
61792
- }
61793
- (function (createHttpsProxyAgent) {
61794
- createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
61795
- createHttpsProxyAgent.prototype = agent_1.default.prototype;
61796
- })(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
61797
- var dist = createHttpsProxyAgent;
61798
-
61799
- var ipaddr = {exports: {}};
61800
-
61801
- (function (module) {
61802
- (function (root) {
61803
- // A list of regular expressions that match arbitrary IPv4 addresses,
61804
- // for which a number of weird notations exist.
61805
- // Note that an address like 0010.0xa5.1.1 is considered legal.
61806
- const ipv4Part = '(0?\\d+|0x[a-f0-9]+)';
61807
- const ipv4Regexes = {
61808
- fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, 'i'),
61809
- threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, 'i'),
61810
- twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, 'i'),
61811
- longValue: new RegExp(`^${ipv4Part}$`, 'i')
61812
- };
61813
-
61814
- // Regular Expression for checking Octal numbers
61815
- const octalRegex = new RegExp(`^0[0-7]+$`, 'i');
61816
- const hexRegex = new RegExp(`^0x[a-f0-9]+$`, 'i');
61817
-
61818
- const zoneIndex = '%[0-9a-z]{1,}';
61819
-
61820
- // IPv6-matching regular expressions.
61821
- // For IPv6, the task is simpler: it is enough to match the colon-delimited
61822
- // hexadecimal IPv6 and a transitional variant with dotted-decimal IPv4 at
61823
- // the end.
61824
- const ipv6Part = '(?:[0-9a-f]+::?)+';
61825
- const ipv6Regexes = {
61826
- zoneIndex: new RegExp(zoneIndex, 'i'),
61827
- 'native': new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, 'i'),
61828
- deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, 'i'),
61829
- transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, 'i')
61830
- };
61831
-
61832
- // Expand :: in an IPv6 address or address part consisting of `parts` groups.
61833
- function expandIPv6 (string, parts) {
61834
- // More than one '::' means invalid adddress
61835
- if (string.indexOf('::') !== string.lastIndexOf('::')) {
61836
- return null;
61837
- }
61838
-
61839
- let colonCount = 0;
61840
- let lastColon = -1;
61841
- let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
61842
- let replacement, replacementCount;
61843
-
61844
- // Remove zone index and save it for later
61845
- if (zoneId) {
61846
- zoneId = zoneId.substring(1);
61847
- string = string.replace(/%.+$/, '');
61848
- }
61849
-
61850
- // How many parts do we already have?
61851
- while ((lastColon = string.indexOf(':', lastColon + 1)) >= 0) {
61852
- colonCount++;
61853
- }
61854
-
61855
- // 0::0 is two parts more than ::
61856
- if (string.substr(0, 2) === '::') {
61857
- colonCount--;
61858
- }
61859
-
61860
- if (string.substr(-2, 2) === '::') {
61861
- colonCount--;
61862
- }
61863
-
61864
- // The following loop would hang if colonCount > parts
61865
- if (colonCount > parts) {
61866
- return null;
61867
- }
61868
-
61869
- // replacement = ':' + '0:' * (parts - colonCount)
61870
- replacementCount = parts - colonCount;
61871
- replacement = ':';
61872
- while (replacementCount--) {
61873
- replacement += '0:';
61874
- }
61875
-
61876
- // Insert the missing zeroes
61877
- string = string.replace('::', replacement);
61878
-
61879
- // Trim any garbage which may be hanging around if :: was at the edge in
61880
- // the source strin
61881
- if (string[0] === ':') {
61882
- string = string.slice(1);
61883
- }
61884
-
61885
- if (string[string.length - 1] === ':') {
61886
- string = string.slice(0, -1);
61887
- }
61888
-
61889
- parts = (function () {
61890
- const ref = string.split(':');
61891
- const results = [];
61892
-
61893
- for (let i = 0; i < ref.length; i++) {
61894
- results.push(parseInt(ref[i], 16));
61895
- }
61896
-
61897
- return results;
61898
- })();
61899
-
61900
- return {
61901
- parts: parts,
61902
- zoneId: zoneId
61903
- };
61904
- }
61905
-
61906
- // A generic CIDR (Classless Inter-Domain Routing) RFC1518 range matcher.
61907
- function matchCIDR (first, second, partSize, cidrBits) {
61908
- if (first.length !== second.length) {
61909
- throw new Error('ipaddr: cannot match CIDR for objects with different lengths');
61910
- }
61911
-
61912
- let part = 0;
61913
- let shift;
61914
-
61915
- while (cidrBits > 0) {
61916
- shift = partSize - cidrBits;
61917
- if (shift < 0) {
61918
- shift = 0;
61919
- }
61920
-
61921
- if (first[part] >> shift !== second[part] >> shift) {
61922
- return false;
61923
- }
61924
-
61925
- cidrBits -= partSize;
61926
- part += 1;
61927
- }
61928
-
61929
- return true;
61930
- }
61931
-
61932
- function parseIntAuto (string) {
61933
- // Hexadedimal base 16 (0x#)
61934
- if (hexRegex.test(string)) {
61935
- return parseInt(string, 16);
61936
- }
61937
- // While octal representation is discouraged by ECMAScript 3
61938
- // and forbidden by ECMAScript 5, we silently allow it to
61939
- // work only if the rest of the string has numbers less than 8.
61940
- if (string[0] === '0' && !isNaN(parseInt(string[1], 10))) {
61941
- if (octalRegex.test(string)) {
61942
- return parseInt(string, 8);
61943
- }
61944
- throw new Error(`ipaddr: cannot parse ${string} as octal`);
61945
- }
61946
- // Always include the base 10 radix!
61947
- return parseInt(string, 10);
61948
- }
61949
-
61950
- function padPart (part, length) {
61951
- while (part.length < length) {
61952
- part = `0${part}`;
61953
- }
61225
+ function padPart (part, length) {
61226
+ while (part.length < length) {
61227
+ part = `0${part}`;
61228
+ }
61954
61229
 
61955
61230
  return part;
61956
61231
  }
@@ -62796,6 +62071,57 @@ var ipaddr = {exports: {}};
62796
62071
  }(commonjsGlobal));
62797
62072
  }(ipaddr));
62798
62073
 
62074
+ async function handleRequest(handler) {
62075
+ let data;
62076
+ try {
62077
+ data = await handler;
62078
+ } catch (error) {
62079
+ return createRes(1, error.message);
62080
+ }
62081
+ return createRes({ data });
62082
+ }
62083
+ async function authServer(username, password) {
62084
+ const res = await handleRequest(getServerPassword(username));
62085
+ if (res.code || !res.data)
62086
+ return false;
62087
+ return bcryptjs.compare(password, res.data);
62088
+ }
62089
+ function addServer(obj) {
62090
+ return handleRequest(createServer(obj));
62091
+ }
62092
+ function setServer(username, obj) {
62093
+ return handleRequest(setServer$2(username, obj));
62094
+ }
62095
+ function delServer(username) {
62096
+ return handleRequest(delServer$2(username));
62097
+ }
62098
+ async function getListServers() {
62099
+ const result = await handleRequest(getListServers$1());
62100
+ if (result.code)
62101
+ return result;
62102
+ const obj = {};
62103
+ result.data.forEach((item) => {
62104
+ const { username, disabled, ..._item } = item;
62105
+ if (disabled)
62106
+ return;
62107
+ obj[username] = _item;
62108
+ });
62109
+ return createRes({ data: obj });
62110
+ }
62111
+ async function getServer(username) {
62112
+ const result = await handleRequest(getServer$1(username));
62113
+ if (result.code || !result.data)
62114
+ return result;
62115
+ const { data } = result;
62116
+ const { username: _, disabled, ...item } = data;
62117
+ if (disabled)
62118
+ return createRes(1, "Server disabled");
62119
+ return createRes({ data: item });
62120
+ }
62121
+ function getRawListServers() {
62122
+ return handleRequest(getListServers$1());
62123
+ }
62124
+
62799
62125
  function callHook(instance, hook, ...args) {
62800
62126
  try {
62801
62127
  if (typeof instance[hook] === "function") {
@@ -62809,7 +62135,7 @@ class NodeStatus {
62809
62135
  constructor(server, options) {
62810
62136
  this.ioPub = new ws.Server({ noServer: true });
62811
62137
  this.ioConn = new ws.Server({ noServer: true });
62812
- this.map = new WeakMap();
62138
+ this.ipMap = new WeakMap();
62813
62139
  this.userMap = new Map();
62814
62140
  this.isBanned = new Map();
62815
62141
  this.servers = {};
@@ -62832,7 +62158,7 @@ class NodeStatus {
62832
62158
  const pathname = request.url;
62833
62159
  if (pathname === "/connect") {
62834
62160
  this.ioConn.handleUpgrade(request, socket, head, (ws2) => {
62835
- this.map.set(ws2, request.headers["x-forwarded-for"]?.split(",")?.[0]?.trim() || request.socket.remoteAddress);
62161
+ this.ipMap.set(ws2, request.headers["x-forwarded-for"]?.split(",")?.[0]?.trim() || request.socket.remoteAddress);
62836
62162
  this.ioConn.emit("connection", ws2);
62837
62163
  });
62838
62164
  } else if (pathname === "/public") {
@@ -62844,7 +62170,7 @@ class NodeStatus {
62844
62170
  }
62845
62171
  });
62846
62172
  this.ioConn.on("connection", (socket) => {
62847
- const address = this.map.get(socket);
62173
+ const address = this.ipMap.get(socket);
62848
62174
  if (typeof address === "undefined") {
62849
62175
  return socket.close();
62850
62176
  }
@@ -62904,7 +62230,6 @@ class NodeStatus {
62904
62230
  const id = setInterval(runPush, this.options.interval);
62905
62231
  socket.on("close", () => clearInterval(id));
62906
62232
  });
62907
- this.options.usePush && this.createPush();
62908
62233
  return this.updateStatus();
62909
62234
  }
62910
62235
  async updateStatus(username, shouldDisconnect = false) {
@@ -62937,153 +62262,684 @@ class NodeStatus {
62937
62262
  }
62938
62263
  this.serversPub = Object.values(this.servers).sort((x, y) => y.order - x.order);
62939
62264
  }
62940
- createPush() {
62941
- const pushList = [];
62942
- const timerMap = new Map();
62943
- const entities = new Set(["_", "*", "[", "]", "(", ")", "~", "`", ">", "#", "+", "-", "=", "|", "{", "}", ".", "!", "\\"]);
62944
- const parseEntities = (msg) => {
62945
- let str;
62946
- if (typeof msg !== "string")
62947
- str = msg.toString();
62948
- else
62949
- str = msg;
62950
- let newStr = "";
62951
- for (const char of str) {
62952
- if (entities.has(char)) {
62953
- newStr += "\\";
62265
+ }
62266
+
62267
+ function createIpc() {
62268
+ return require$$3__default["default"].createServer((client) => {
62269
+ client.on("data", async (buf) => {
62270
+ try {
62271
+ const [method, payload] = buf.toString().trim().split(" @;@ ");
62272
+ switch (method) {
62273
+ case "add": {
62274
+ const data = JSON.parse(payload);
62275
+ const status = await addServer(data);
62276
+ client.write(JSON.stringify(status));
62277
+ break;
62278
+ }
62279
+ case "list": {
62280
+ const status = await getRawListServers();
62281
+ client.write(JSON.stringify(status));
62282
+ break;
62283
+ }
62284
+ case "set": {
62285
+ const obj = JSON.parse(payload);
62286
+ const { username } = obj;
62287
+ delete obj.username;
62288
+ if (obj.newUserName) {
62289
+ obj.username = obj.newUserName;
62290
+ delete obj.newUserName;
62291
+ }
62292
+ const status = await setServer(username, obj);
62293
+ client.write(JSON.stringify(status));
62294
+ break;
62295
+ }
62296
+ case "del": {
62297
+ const status = await delServer(payload);
62298
+ client.write(JSON.stringify(status));
62299
+ break;
62300
+ }
62301
+ default: {
62302
+ client.write(JSON.stringify(createRes(1, "Unknown Method")));
62303
+ }
62954
62304
  }
62955
- newStr += char;
62305
+ } catch (error) {
62306
+ client.write(JSON.stringify(createRes(1, error.message)));
62956
62307
  }
62957
- return newStr;
62308
+ });
62309
+ });
62310
+ }
62311
+
62312
+ var agent = {};
62313
+
62314
+ var promisify$1 = {};
62315
+
62316
+ Object.defineProperty(promisify$1, "__esModule", { value: true });
62317
+ function promisify(fn) {
62318
+ return function (req, opts) {
62319
+ return new Promise((resolve, reject) => {
62320
+ fn.call(this, req, opts, (err, rtn) => {
62321
+ if (err) {
62322
+ reject(err);
62323
+ }
62324
+ else {
62325
+ resolve(rtn);
62326
+ }
62327
+ });
62328
+ });
62958
62329
  };
62959
- const getBotStatus = () => {
62960
- let str = "";
62961
- let online = 0;
62962
- this.serversPub.forEach((obj) => {
62963
- const item = new Proxy(obj, {
62964
- get(target, key) {
62965
- const value = Reflect.get(target, key);
62966
- return typeof value === "string" ? parseEntities(value) : value;
62967
- }
62330
+ }
62331
+ promisify$1.default = promisify;
62332
+
62333
+ var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
62334
+ return (mod && mod.__esModule) ? mod : { "default": mod };
62335
+ };
62336
+ const events_1 = require$$0__default$3["default"];
62337
+ const debug_1$2 = __importDefault$3(src$2.exports);
62338
+ const promisify_1 = __importDefault$3(promisify$1);
62339
+ const debug$2 = debug_1$2.default('agent-base');
62340
+ function isAgent(v) {
62341
+ return Boolean(v) && typeof v.addRequest === 'function';
62342
+ }
62343
+ function isSecureEndpoint() {
62344
+ const { stack } = new Error();
62345
+ if (typeof stack !== 'string')
62346
+ return false;
62347
+ return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
62348
+ }
62349
+ function createAgent(callback, opts) {
62350
+ return new createAgent.Agent(callback, opts);
62351
+ }
62352
+ (function (createAgent) {
62353
+ /**
62354
+ * Base `http.Agent` implementation.
62355
+ * No pooling/keep-alive is implemented by default.
62356
+ *
62357
+ * @param {Function} callback
62358
+ * @api public
62359
+ */
62360
+ class Agent extends events_1.EventEmitter {
62361
+ constructor(callback, _opts) {
62362
+ super();
62363
+ let opts = _opts;
62364
+ if (typeof callback === 'function') {
62365
+ this.callback = callback;
62366
+ }
62367
+ else if (callback) {
62368
+ opts = callback;
62369
+ }
62370
+ // Timeout for the socket to be returned from the callback
62371
+ this.timeout = null;
62372
+ if (opts && typeof opts.timeout === 'number') {
62373
+ this.timeout = opts.timeout;
62374
+ }
62375
+ // These aren't actually used by `agent-base`, but are required
62376
+ // for the TypeScript definition files in `@types/node` :/
62377
+ this.maxFreeSockets = 1;
62378
+ this.maxSockets = 1;
62379
+ this.maxTotalSockets = Infinity;
62380
+ this.sockets = {};
62381
+ this.freeSockets = {};
62382
+ this.requests = {};
62383
+ this.options = {};
62384
+ }
62385
+ get defaultPort() {
62386
+ if (typeof this.explicitDefaultPort === 'number') {
62387
+ return this.explicitDefaultPort;
62388
+ }
62389
+ return isSecureEndpoint() ? 443 : 80;
62390
+ }
62391
+ set defaultPort(v) {
62392
+ this.explicitDefaultPort = v;
62393
+ }
62394
+ get protocol() {
62395
+ if (typeof this.explicitProtocol === 'string') {
62396
+ return this.explicitProtocol;
62397
+ }
62398
+ return isSecureEndpoint() ? 'https:' : 'http:';
62399
+ }
62400
+ set protocol(v) {
62401
+ this.explicitProtocol = v;
62402
+ }
62403
+ callback(req, opts, fn) {
62404
+ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
62405
+ }
62406
+ /**
62407
+ * Called by node-core's "_http_client.js" module when creating
62408
+ * a new HTTP request with this Agent instance.
62409
+ *
62410
+ * @api public
62411
+ */
62412
+ addRequest(req, _opts) {
62413
+ const opts = Object.assign({}, _opts);
62414
+ if (typeof opts.secureEndpoint !== 'boolean') {
62415
+ opts.secureEndpoint = isSecureEndpoint();
62416
+ }
62417
+ if (opts.host == null) {
62418
+ opts.host = 'localhost';
62419
+ }
62420
+ if (opts.port == null) {
62421
+ opts.port = opts.secureEndpoint ? 443 : 80;
62422
+ }
62423
+ if (opts.protocol == null) {
62424
+ opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
62425
+ }
62426
+ if (opts.host && opts.path) {
62427
+ // If both a `host` and `path` are specified then it's most
62428
+ // likely the result of a `url.parse()` call... we need to
62429
+ // remove the `path` portion so that `net.connect()` doesn't
62430
+ // attempt to open that as a unix socket file.
62431
+ delete opts.path;
62432
+ }
62433
+ delete opts.agent;
62434
+ delete opts.hostname;
62435
+ delete opts._defaultAgent;
62436
+ delete opts.defaultPort;
62437
+ delete opts.createConnection;
62438
+ // Hint to use "Connection: close"
62439
+ // XXX: non-documented `http` module API :(
62440
+ req._last = true;
62441
+ req.shouldKeepAlive = false;
62442
+ let timedOut = false;
62443
+ let timeoutId = null;
62444
+ const timeoutMs = opts.timeout || this.timeout;
62445
+ const onerror = (err) => {
62446
+ if (req._hadError)
62447
+ return;
62448
+ req.emit('error', err);
62449
+ // For Safety. Some additional errors might fire later on
62450
+ // and we need to make sure we don't double-fire the error event.
62451
+ req._hadError = true;
62452
+ };
62453
+ const ontimeout = () => {
62454
+ timeoutId = null;
62455
+ timedOut = true;
62456
+ const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
62457
+ err.code = 'ETIMEOUT';
62458
+ onerror(err);
62459
+ };
62460
+ const callbackError = (err) => {
62461
+ if (timedOut)
62462
+ return;
62463
+ if (timeoutId !== null) {
62464
+ clearTimeout(timeoutId);
62465
+ timeoutId = null;
62466
+ }
62467
+ onerror(err);
62468
+ };
62469
+ const onsocket = (socket) => {
62470
+ if (timedOut)
62471
+ return;
62472
+ if (timeoutId != null) {
62473
+ clearTimeout(timeoutId);
62474
+ timeoutId = null;
62475
+ }
62476
+ if (isAgent(socket)) {
62477
+ // `socket` is actually an `http.Agent` instance, so
62478
+ // relinquish responsibility for this `req` to the Agent
62479
+ // from here on
62480
+ debug$2('Callback returned another Agent instance %o', socket.constructor.name);
62481
+ socket.addRequest(req, opts);
62482
+ return;
62483
+ }
62484
+ if (socket) {
62485
+ socket.once('free', () => {
62486
+ this.freeSocket(socket, opts);
62487
+ });
62488
+ req.onSocket(socket);
62489
+ return;
62490
+ }
62491
+ const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
62492
+ onerror(err);
62493
+ };
62494
+ if (typeof this.callback !== 'function') {
62495
+ onerror(new Error('`callback` is not defined'));
62496
+ return;
62497
+ }
62498
+ if (!this.promisifiedCallback) {
62499
+ if (this.callback.length >= 3) {
62500
+ debug$2('Converting legacy callback function to promise');
62501
+ this.promisifiedCallback = promisify_1.default(this.callback);
62502
+ }
62503
+ else {
62504
+ this.promisifiedCallback = this.callback;
62505
+ }
62506
+ }
62507
+ if (typeof timeoutMs === 'number' && timeoutMs > 0) {
62508
+ timeoutId = setTimeout(ontimeout, timeoutMs);
62509
+ }
62510
+ if ('port' in opts && typeof opts.port !== 'number') {
62511
+ opts.port = Number(opts.port);
62512
+ }
62513
+ try {
62514
+ debug$2('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
62515
+ Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
62516
+ }
62517
+ catch (err) {
62518
+ Promise.reject(err).catch(callbackError);
62519
+ }
62520
+ }
62521
+ freeSocket(socket, opts) {
62522
+ debug$2('Freeing socket %o %o', socket.constructor.name, opts);
62523
+ socket.destroy();
62524
+ }
62525
+ destroy() {
62526
+ debug$2('Destroying agent %o', this.constructor.name);
62527
+ }
62528
+ }
62529
+ createAgent.Agent = Agent;
62530
+ // So that `instanceof` works correctly
62531
+ createAgent.prototype = createAgent.Agent.prototype;
62532
+ })(createAgent || (createAgent = {}));
62533
+ var src = createAgent;
62534
+
62535
+ var parseProxyResponse$1 = {};
62536
+
62537
+ var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
62538
+ return (mod && mod.__esModule) ? mod : { "default": mod };
62539
+ };
62540
+ Object.defineProperty(parseProxyResponse$1, "__esModule", { value: true });
62541
+ const debug_1$1 = __importDefault$2(src$2.exports);
62542
+ const debug$1 = debug_1$1.default('https-proxy-agent:parse-proxy-response');
62543
+ function parseProxyResponse(socket) {
62544
+ return new Promise((resolve, reject) => {
62545
+ // we need to buffer any HTTP traffic that happens with the proxy before we get
62546
+ // the CONNECT response, so that if the response is anything other than an "200"
62547
+ // response code, then we can re-play the "data" events on the socket once the
62548
+ // HTTP parser is hooked up...
62549
+ let buffersLength = 0;
62550
+ const buffers = [];
62551
+ function read() {
62552
+ const b = socket.read();
62553
+ if (b)
62554
+ ondata(b);
62555
+ else
62556
+ socket.once('readable', read);
62557
+ }
62558
+ function cleanup() {
62559
+ socket.removeListener('end', onend);
62560
+ socket.removeListener('error', onerror);
62561
+ socket.removeListener('close', onclose);
62562
+ socket.removeListener('readable', read);
62563
+ }
62564
+ function onclose(err) {
62565
+ debug$1('onclose had error %o', err);
62566
+ }
62567
+ function onend() {
62568
+ debug$1('onend');
62569
+ }
62570
+ function onerror(err) {
62571
+ cleanup();
62572
+ debug$1('onerror %o', err);
62573
+ reject(err);
62574
+ }
62575
+ function ondata(b) {
62576
+ buffers.push(b);
62577
+ buffersLength += b.length;
62578
+ const buffered = Buffer.concat(buffers, buffersLength);
62579
+ const endOfHeaders = buffered.indexOf('\r\n\r\n');
62580
+ if (endOfHeaders === -1) {
62581
+ // keep buffering
62582
+ debug$1('have not received end of HTTP headers yet...');
62583
+ read();
62584
+ return;
62585
+ }
62586
+ const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
62587
+ const statusCode = +firstLine.split(' ')[1];
62588
+ debug$1('got proxy server response: %o', firstLine);
62589
+ resolve({
62590
+ statusCode,
62591
+ buffered
62592
+ });
62593
+ }
62594
+ socket.on('error', onerror);
62595
+ socket.on('close', onclose);
62596
+ socket.on('end', onend);
62597
+ read();
62598
+ });
62599
+ }
62600
+ parseProxyResponse$1.default = parseProxyResponse;
62601
+
62602
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
62603
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
62604
+ return new (P || (P = Promise))(function (resolve, reject) {
62605
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
62606
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
62607
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
62608
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
62609
+ });
62610
+ };
62611
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
62612
+ return (mod && mod.__esModule) ? mod : { "default": mod };
62613
+ };
62614
+ Object.defineProperty(agent, "__esModule", { value: true });
62615
+ const net_1 = __importDefault$1(require$$3__default["default"]);
62616
+ const tls_1 = __importDefault$1(require$$4__default["default"]);
62617
+ const url_1 = __importDefault$1(require$$0__default$5["default"]);
62618
+ const assert_1 = __importDefault$1(require$$5__default["default"]);
62619
+ const debug_1 = __importDefault$1(src$2.exports);
62620
+ const agent_base_1 = src;
62621
+ const parse_proxy_response_1 = __importDefault$1(parseProxyResponse$1);
62622
+ const debug = debug_1.default('https-proxy-agent:agent');
62623
+ /**
62624
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
62625
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
62626
+ *
62627
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
62628
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
62629
+ * and then the proxy server connects to the destination target and issues the
62630
+ * HTTP request from the proxy server.
62631
+ *
62632
+ * `https:` requests have their socket connection upgraded to TLS once
62633
+ * the connection to the proxy server has been established.
62634
+ *
62635
+ * @api public
62636
+ */
62637
+ class HttpsProxyAgent extends agent_base_1.Agent {
62638
+ constructor(_opts) {
62639
+ let opts;
62640
+ if (typeof _opts === 'string') {
62641
+ opts = url_1.default.parse(_opts);
62642
+ }
62643
+ else {
62644
+ opts = _opts;
62645
+ }
62646
+ if (!opts) {
62647
+ throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
62648
+ }
62649
+ debug('creating new HttpsProxyAgent instance: %o', opts);
62650
+ super(opts);
62651
+ const proxy = Object.assign({}, opts);
62652
+ // If `true`, then connect to the proxy server over TLS.
62653
+ // Defaults to `false`.
62654
+ this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
62655
+ // Prefer `hostname` over `host`, and set the `port` if needed.
62656
+ proxy.host = proxy.hostname || proxy.host;
62657
+ if (typeof proxy.port === 'string') {
62658
+ proxy.port = parseInt(proxy.port, 10);
62659
+ }
62660
+ if (!proxy.port && proxy.host) {
62661
+ proxy.port = this.secureProxy ? 443 : 80;
62662
+ }
62663
+ // ALPN is supported by Node.js >= v5.
62664
+ // attempt to negotiate http/1.1 for proxy servers that support http/2
62665
+ if (this.secureProxy && !('ALPNProtocols' in proxy)) {
62666
+ proxy.ALPNProtocols = ['http 1.1'];
62667
+ }
62668
+ if (proxy.host && proxy.path) {
62669
+ // If both a `host` and `path` are specified then it's most likely
62670
+ // the result of a `url.parse()` call... we need to remove the
62671
+ // `path` portion so that `net.connect()` doesn't attempt to open
62672
+ // that as a Unix socket file.
62673
+ delete proxy.path;
62674
+ delete proxy.pathname;
62675
+ }
62676
+ this.proxy = proxy;
62677
+ }
62678
+ /**
62679
+ * Called when the node-core HTTP client library is creating a
62680
+ * new HTTP request.
62681
+ *
62682
+ * @api protected
62683
+ */
62684
+ callback(req, opts) {
62685
+ return __awaiter(this, void 0, void 0, function* () {
62686
+ const { proxy, secureProxy } = this;
62687
+ // Create a socket connection to the proxy server.
62688
+ let socket;
62689
+ if (secureProxy) {
62690
+ debug('Creating `tls.Socket`: %o', proxy);
62691
+ socket = tls_1.default.connect(proxy);
62692
+ }
62693
+ else {
62694
+ debug('Creating `net.Socket`: %o', proxy);
62695
+ socket = net_1.default.connect(proxy);
62696
+ }
62697
+ const headers = Object.assign({}, proxy.headers);
62698
+ const hostname = `${opts.host}:${opts.port}`;
62699
+ let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
62700
+ // Inject the `Proxy-Authorization` header if necessary.
62701
+ if (proxy.auth) {
62702
+ headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
62703
+ }
62704
+ // The `Host` header should only include the port
62705
+ // number when it is not the default port.
62706
+ let { host, port, secureEndpoint } = opts;
62707
+ if (!isDefaultPort(port, secureEndpoint)) {
62708
+ host += `:${port}`;
62709
+ }
62710
+ headers.Host = host;
62711
+ headers.Connection = 'close';
62712
+ for (const name of Object.keys(headers)) {
62713
+ payload += `${name}: ${headers[name]}\r\n`;
62714
+ }
62715
+ const proxyResponsePromise = parse_proxy_response_1.default(socket);
62716
+ socket.write(`${payload}\r\n`);
62717
+ const { statusCode, buffered } = yield proxyResponsePromise;
62718
+ if (statusCode === 200) {
62719
+ req.once('socket', resume);
62720
+ if (opts.secureEndpoint) {
62721
+ const servername = opts.servername || opts.host;
62722
+ if (!servername) {
62723
+ throw new Error('Could not determine "servername"');
62724
+ }
62725
+ // The proxy is connecting to a TLS server, so upgrade
62726
+ // this socket connection to a TLS connection.
62727
+ debug('Upgrading socket connection to TLS');
62728
+ return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
62729
+ servername }));
62730
+ }
62731
+ return socket;
62732
+ }
62733
+ // Some other status code that's not 200... need to re-play the HTTP
62734
+ // header "data" events onto the socket once the HTTP machinery is
62735
+ // attached so that the node core `http` can parse and handle the
62736
+ // error status code.
62737
+ // Close the original socket, and a new "fake" socket is returned
62738
+ // instead, so that the proxy doesn't get the HTTP request
62739
+ // written to it (which may contain `Authorization` headers or other
62740
+ // sensitive data).
62741
+ //
62742
+ // See: https://hackerone.com/reports/541502
62743
+ socket.destroy();
62744
+ const fakeSocket = new net_1.default.Socket();
62745
+ fakeSocket.readable = true;
62746
+ // Need to wait for the "socket" event to re-play the "data" events.
62747
+ req.once('socket', (s) => {
62748
+ debug('replaying proxy buffer for failed request');
62749
+ assert_1.default(s.listenerCount('data') > 0);
62750
+ // Replay the "buffered" Buffer onto the fake `socket`, since at
62751
+ // this point the HTTP module machinery has been hooked up for
62752
+ // the user.
62753
+ s.push(buffered);
62754
+ s.push(null);
62755
+ });
62756
+ return fakeSocket;
62968
62757
  });
62969
- str += `\u8282\u70B9\u540D: *${item.name}*
62970
- \u5F53\u524D\u72B6\u6001: `;
62971
- if (item.status.online4 || item.status.online6) {
62972
- str += "\u2705*\u5728\u7EBF*\n";
62973
- online++;
62974
- } else {
62975
- str += "\u274C*\u79BB\u7EBF*";
62976
- str += "\n\n";
62977
- return;
62758
+ }
62759
+ }
62760
+ agent.default = HttpsProxyAgent;
62761
+ function resume(socket) {
62762
+ socket.resume();
62763
+ }
62764
+ function isDefaultPort(port, secure) {
62765
+ return Boolean((!secure && port === 80) || (secure && port === 443));
62766
+ }
62767
+ function isHTTPS(protocol) {
62768
+ return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
62769
+ }
62770
+ function omit(obj, ...keys) {
62771
+ const ret = {};
62772
+ let key;
62773
+ for (key in obj) {
62774
+ if (!keys.includes(key)) {
62775
+ ret[key] = obj[key];
62978
62776
  }
62979
- str += `\u5F53\u524D\u8D1F\u8F7D: ${parseEntities(item.status.load.toFixed(2))}
62777
+ }
62778
+ return ret;
62779
+ }
62780
+
62781
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
62782
+ return (mod && mod.__esModule) ? mod : { "default": mod };
62783
+ };
62784
+ const agent_1 = __importDefault(agent);
62785
+ function createHttpsProxyAgent(opts) {
62786
+ return new agent_1.default(opts);
62787
+ }
62788
+ (function (createHttpsProxyAgent) {
62789
+ createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
62790
+ createHttpsProxyAgent.prototype = agent_1.default.prototype;
62791
+ })(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
62792
+ var dist = createHttpsProxyAgent;
62793
+
62794
+ function createPush(options) {
62795
+ const pushList = [];
62796
+ const timerMap = new Map();
62797
+ const entities = new Set(["_", "*", "[", "]", "(", ")", "~", "`", ">", "#", "+", "-", "=", "|", "{", "}", ".", "!", "\\"]);
62798
+ const parseEntities = (msg) => {
62799
+ let str;
62800
+ if (typeof msg !== "string")
62801
+ str = msg.toString();
62802
+ else
62803
+ str = msg;
62804
+ let newStr = "";
62805
+ for (const char of str) {
62806
+ if (entities.has(char)) {
62807
+ newStr += "\\";
62808
+ }
62809
+ newStr += char;
62810
+ }
62811
+ return newStr;
62812
+ };
62813
+ const getBotStatus = () => {
62814
+ let str = "";
62815
+ let online = 0;
62816
+ this.serversPub.forEach((obj) => {
62817
+ const item = new Proxy(obj, {
62818
+ get(target, key) {
62819
+ const value = Reflect.get(target, key);
62820
+ return typeof value === "string" ? parseEntities(value) : value;
62821
+ }
62822
+ });
62823
+ str += `\u8282\u70B9\u540D: *${item.name}*
62824
+ \u5F53\u524D\u72B6\u6001: `;
62825
+ if (item.status.online4 || item.status.online6) {
62826
+ str += "\u2705*\u5728\u7EBF*\n";
62827
+ online++;
62828
+ } else {
62829
+ str += "\u274C*\u79BB\u7EBF*";
62830
+ str += "\n\n";
62831
+ return;
62832
+ }
62833
+ str += `\u5F53\u524D\u8D1F\u8F7D: ${parseEntities(item.status.load.toFixed(2))}
62980
62834
  `;
62981
- str += `\u5F53\u524DCPU\u5360\u7528: ${Math.round(item.status.cpu)}%
62835
+ str += `\u5F53\u524DCPU\u5360\u7528: ${Math.round(item.status.cpu)}%
62982
62836
  `;
62983
- str += `\u5F53\u524D\u5185\u5B58\u5360\u7528: ${Math.round(item.status.memory_used / item.status.memory_total * 100)}%
62837
+ str += `\u5F53\u524D\u5185\u5B58\u5360\u7528: ${Math.round(item.status.memory_used / item.status.memory_total * 100)}%
62984
62838
  `;
62985
- str += `\u5F53\u524D\u786C\u76D8\u5360\u7528: ${Math.round(item.status.hdd_used / item.status.hdd_total * 100)}%
62839
+ str += `\u5F53\u524D\u786C\u76D8\u5360\u7528: ${Math.round(item.status.hdd_used / item.status.hdd_total * 100)}%
62986
62840
  `;
62987
- str += "\n\n";
62988
- });
62989
- return `\u{1F34A}*NodeStatus*
62841
+ str += "\n\n";
62842
+ });
62843
+ return `\u{1F34A}*NodeStatus*
62990
62844
  \u{1F916} \u5F53\u524D\u6709 ${this.serversPub.length} \u53F0\u670D\u52A1\u5668, \u5176\u4E2D\u5728\u7EBF ${online} \u53F0
62991
62845
 
62992
62846
  ${str}`;
62993
- };
62994
- const tgConfig = this.options.telegram;
62995
- if (tgConfig?.bot_token) {
62996
- const bot = new telegraf.Telegraf(tgConfig.bot_token, {
62997
- ...tgConfig.proxy && {
62998
- telegram: {
62999
- agent: dist(tgConfig.proxy)
63000
- }
62847
+ };
62848
+ const tgConfig = options.telegram;
62849
+ if (tgConfig?.bot_token) {
62850
+ const bot = new telegraf.Telegraf(tgConfig.bot_token, {
62851
+ ...tgConfig.proxy && {
62852
+ telegram: {
62853
+ agent: dist(tgConfig.proxy)
63001
62854
  }
63002
- });
63003
- const chatId = new Set(tgConfig.chat_id);
63004
- bot.command("start", (ctx) => {
63005
- const currentChat = ctx.message.chat.id.toString();
63006
- if (chatId.has(currentChat)) {
63007
- ctx.reply(`\u{1F34A}NodeStatus
62855
+ }
62856
+ });
62857
+ const chatId = new Set(tgConfig.chat_id);
62858
+ bot.command("start", (ctx) => {
62859
+ const currentChat = ctx.message.chat.id.toString();
62860
+ if (chatId.has(currentChat)) {
62861
+ ctx.reply(`\u{1F34A}NodeStatus
63008
62862
  \u{1F916} Hi, this chat id is *${currentChat}*\\.
63009
62863
  You have access to this service\\. I will alert you when your servers changed\\.
63010
62864
  You are currently using NodeStatus: *${parseEntities(process.env.npm_package_version)}*`, { parse_mode: "MarkdownV2" });
63011
- } else {
63012
- ctx.reply(`\u{1F34A}NodeStatus
62865
+ } else {
62866
+ ctx.reply(`\u{1F34A}NodeStatus
63013
62867
  \u{1F916} Hi, this chat id is *${currentChat}*\\.
63014
62868
  You *do not* have permission to use this service\\.
63015
62869
  Please check your settings\\.`, { parse_mode: "MarkdownV2" });
63016
- }
63017
- });
63018
- bot.command("status", (ctx) => {
63019
- if (chatId.has(ctx.message.chat.id.toString())) {
63020
- ctx.reply(getBotStatus(), { parse_mode: "MarkdownV2" });
63021
- } else {
63022
- ctx.reply("\u{1F34A}NodeStatus\n*No permission*", { parse_mode: "MarkdownV2" });
63023
- }
63024
- });
63025
- if (tgConfig.web_hook) {
63026
- const secretPath = `/telegraf/${bot.secretPathComponent()}`;
63027
- bot.telegram.setWebhook(`${tgConfig.web_hook}${secretPath}`).then(() => logger.info("\u{1F916} Telegram Bot is running using webhook"));
63028
- this.server.on("request", (req, res) => {
63029
- if (req.url && req.url.length === secretPath.length && require$$0$8.timingSafeEqual(Buffer.from(secretPath), Buffer.from(req.url))) {
63030
- bot.webhookCallback(secretPath)(req, res);
63031
- res.statusCode = 200;
63032
- }
63033
- });
62870
+ }
62871
+ });
62872
+ bot.command("status", (ctx) => {
62873
+ if (chatId.has(ctx.message.chat.id.toString())) {
62874
+ ctx.reply(getBotStatus(), { parse_mode: "MarkdownV2" });
63034
62875
  } else {
63035
- bot.launch().then(() => logger.info("\u{1F916} Telegram Bot is running using polling"));
62876
+ ctx.reply("\u{1F34A}NodeStatus\n*No permission*", { parse_mode: "MarkdownV2" });
63036
62877
  }
63037
- pushList.push((message) => [...chatId].map((id) => bot.telegram.sendMessage(id, `${message}`, { parse_mode: "MarkdownV2" })));
62878
+ });
62879
+ if (tgConfig.web_hook) {
62880
+ const secretPath = `/telegraf/${bot.secretPathComponent()}`;
62881
+ bot.telegram.setWebhook(`${tgConfig.web_hook}${secretPath}`).then(() => logger.info("\u{1F916} Telegram Bot is running using webhook"));
62882
+ this.server.on("request", (req, res) => {
62883
+ if (req.url && req.url.length === secretPath.length && require$$0$8.timingSafeEqual(Buffer.from(secretPath), Buffer.from(req.url))) {
62884
+ bot.webhookCallback(secretPath)(req, res);
62885
+ res.statusCode = 200;
62886
+ }
62887
+ });
62888
+ } else {
62889
+ bot.launch().then(() => logger.info("\u{1F916} Telegram Bot is running using polling"));
63038
62890
  }
63039
- this.onServerConnected = (socket, username) => {
63040
- const ip = this.map.get(socket);
63041
- if (ip) {
63042
- const timer = timerMap.get(ip);
63043
- if (timer) {
63044
- clearTimeout(timer);
63045
- timerMap.delete(ip);
63046
- } else {
63047
- return Promise.all(pushList.map((fn) => fn(`\u{1F34A}*NodeStatus*
62891
+ pushList.push((message) => [...chatId].map((id) => bot.telegram.sendMessage(id, `${message}`, { parse_mode: "MarkdownV2" })));
62892
+ }
62893
+ this.onServerConnected = (socket, username) => {
62894
+ const ip = this.ipMap.get(socket);
62895
+ if (ip) {
62896
+ const timer = timerMap.get(ip);
62897
+ if (timer) {
62898
+ clearTimeout(timer);
62899
+ timerMap.delete(ip);
62900
+ } else {
62901
+ return Promise.all(pushList.map((fn) => fn(`\u{1F34A}*NodeStatus*
63048
62902
  \u{1F600} One new server has connected\\!
63049
62903
 
63050
62904
  *\u7528\u6237\u540D*: ${parseEntities(username)}
63051
62905
  *\u8282\u70B9\u540D*: ${parseEntities(this.servers[username].name)}
63052
62906
  *\u65F6\u95F4*: ${parseEntities(new Date())}`)));
63053
- }
63054
62907
  }
63055
- };
63056
- this.onServerDisconnected = (socket, username) => {
63057
- const ip = this.map.get(socket);
63058
- const timer = setTimeout(() => {
63059
- Promise.all(pushList.map((fn) => fn(`\u{1F34A}*NodeStatus*
62908
+ }
62909
+ };
62910
+ this.onServerDisconnected = (socket, username) => {
62911
+ const ip = this.ipMap.get(socket);
62912
+ const timer = setTimeout(() => {
62913
+ Promise.all(pushList.map((fn) => fn(`\u{1F34A}*NodeStatus*
63060
62914
  \u{1F630} One server has disconnected\\!
63061
62915
 
63062
62916
  *\u7528\u6237\u540D*: ${parseEntities(username)}
63063
62917
  *\u8282\u70B9\u540D*: ${parseEntities(this.servers[username]?.name)}
63064
62918
  *\u65F6\u95F4*: ${parseEntities(new Date())}`))).then();
63065
- ip && timerMap.delete(ip);
63066
- }, this.options.pushTimeOut * 1e3);
63067
- ip && timerMap.set(ip, timer);
63068
- };
63069
- }
62919
+ ip && timerMap.delete(ip);
62920
+ }, options.pushTimeOut * 1e3);
62921
+ ip && timerMap.set(ip, timer);
62922
+ };
63070
62923
  }
63071
62924
 
63072
62925
  async function createStatus(app) {
63073
62926
  const server = new require$$2$1.Server(app.callback());
63074
62927
  let ipc = null;
63075
62928
  const instance = new NodeStatus(server, {
63076
- interval: Number(config.interval),
63077
- usePush: config.usePush,
63078
- pushTimeOut: config.pushTimeOut,
63079
- telegram: {
63080
- ...config.telegram,
63081
- chat_id: config.telegram.chat_id.split(",")
63082
- }
62929
+ interval: config.interval
63083
62930
  });
63084
62931
  await instance.launch();
62932
+ if (config.usePush) {
62933
+ setTimeout(createPush.bind(instance, {
62934
+ pushTimeOut: config.pushTimeOut,
62935
+ telegram: {
62936
+ ...config.telegram,
62937
+ chat_id: config.telegram.chat_id.split(",")
62938
+ }
62939
+ }), config.pushDelay * 1e3);
62940
+ }
63085
62941
  if (config.useIpc) {
63086
- require$$1__default$2["default"].existsSync(config.ipcAddress) && require$$1__default$2["default"].unlinkSync(config.ipcAddress);
62942
+ require$$0__default$2["default"].existsSync(config.ipcAddress) && require$$0__default$2["default"].unlinkSync(config.ipcAddress);
63087
62943
  ipc = createIpc();
63088
62944
  }
63089
62945
  if (config.useWeb) {