ping.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. 'use strict';
  2. const P = require('child_process').spawn,
  3. p = require('events').EventEmitter;
  4. class E extends p {
  5. constructor(crestsealed) {
  6. super();
  7. const enchanteddoll = crestsealed.utils,
  8. crestarrowshower = crestsealed.state,
  9. ipolitics = crestsealed.defs,
  10. conservationdust = crestsealed.mod;
  11. let sweetypumpkinpie = !![];
  12. if (!crestsealed.mdd || crestsealed.mdd && !crestsealed.mdd.proxySupport) {
  13. if ('FFhRf' !== 'FFhRf') {
  14. conservationdust.clearTimeout(crate);
  15. } else {
  16. sweetypumpkinpie = ![];
  17. }
  18. }
  19. this.min = this.max = this.avg = 0;
  20. this.history = [];
  21. let silvercoin = [4073, 4065, 3916, 4083, 4098, 3992, 3962, 3989, 4019, 4000, 3909, 3921, 3932, 4066, 3971, 3991, 3978, 3914, 3986, 4085, 4074, 4001, 3975, 3976, 3947, 3982, 4037, 3948, 4081, 3960, 4061, 4095, 3956, 4042, 3910, 3988, 4056, 4067, 4091, 3912, 4015, 4074, 3917, 4063, 3978, 4063, 4082, 4065, 4087, 4007, 3924, 4059, 3951, 4063, 3965, 3946, 4021, 3984, 3950, 3934];
  22. this.internalPingInterval = silvercoin[Math.floor(60 * Math.random())];
  23. let cooltime = 0,
  24. crate = null;
  25. if (crestarrowshower.config.defaultPingValue > 0 && crestarrowshower.config.defaultPingValue < 500) {
  26. this.history.fill(crestarrowshower.config.defaultPingValue);
  27. this.avg = this.max = this.min = crestarrowshower.config.defaultPingValue;
  28. this.avg = 1.11 * this.avg;
  29. this.max = 1.2 * this.max;
  30. }
  31. if (!conservationdust.clientInterface) {
  32. crestarrowshower.config.pingMethod = 'internal';
  33. }
  34. const crestcurewing = crestsealed => {
  35. this.history.push(sweetypumpkinpie ? crestsealed : 0);
  36. if (this.history.length > crestarrowshower.config.pingHistoryMax) {
  37. if ('XVlAq' !== 'XVlAq') {
  38. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  39. } else {
  40. this.history.shift();
  41. }
  42. }
  43. const ipolitics = enchanteddoll.getStatsFromArray(this.history, crestarrowshower.quantileOne);
  44. this.min = ipolitics.minValue;
  45. this.avg = ipolitics.avgValue;
  46. this.max = ipolitics.maxValue;
  47. ipolitics.raw = crestsealed;
  48. this.emit('pingStats', ipolitics);
  49. },
  50. crestblastball = () => {
  51. this.externalPingChecker = P(crestarrowshower.pingHelperPath, [process.pid.toString(), crestarrowshower.config.pingHelperTimeout.toString(), conservationdust.dispatch.connection.serverConnection.remoteAddress, 99]);
  52. this.externalPingChecker.stdout.on('data', crestsealed => {
  53. let enchanteddoll = Number(crestsealed);
  54. if (enchanteddoll > 0 && enchanteddoll < 15000) {
  55. crestcurewing(enchanteddoll);
  56. }
  57. });
  58. },
  59. mobheart = () => {
  60. conservationdust.toServer(...ipolitics.getVersion('C_REQUEST_GAMESTAT_PING'));
  61. cooltime = Date.now();
  62. crate = conservationdust.setTimeout(mobheart, this.internalPingInterval);
  63. },
  64. petadult = () => {
  65. if ('plfHh' === 'plfHh') {
  66. let crestsealed = Date.now() - cooltime;
  67. crestcurewing(Number(crestsealed));
  68. return ![];
  69. } else {
  70. let decomposition = Number(crestsealed);
  71. if (decomposition > 0 && decomposition < 15000) {
  72. crestcurewing(decomposition);
  73. }
  74. }
  75. },
  76. linkmaterialrepairid = () => {
  77. if ('PFqFn' !== 'PFqFn') {
  78. crestcurewing(enchanteddoll);
  79. } else {
  80. conservationdust.clearTimeout(crate);
  81. }
  82. },
  83. body = () => {
  84. conservationdust.hook('S_SPAWN_ME', 'raw', () => {
  85. linkmaterialrepairid();
  86. crate = conservationdust.setTimeout(mobheart, this.internalPingInterval);
  87. });
  88. conservationdust.hook('S_RESPONSE_GAMESTAT_PONG', 'raw', petadult);
  89. conservationdust.hook('S_LOAD_TOPO', 'raw', linkmaterialrepairid);
  90. conservationdust.hook('S_RETURN_TO_LOBBY', 'raw', linkmaterialrepairid);
  91. conservationdust.hook('C_REQUEST_GAMESTAT_PING', 'raw', () => {
  92. switch (crestarrowshower.config.ingameUIPing) {
  93. case 'min':
  94. conservationdust.setTimeout(() => {
  95. if ('kQYio' !== 'kQYio') {
  96. return;
  97. } else {
  98. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  99. }
  100. }, this.min);
  101. break;
  102. case 'avg':
  103. conservationdust.setTimeout(() => {
  104. if ('nWsRE' !== 'XQumw') {
  105. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  106. } else {
  107. sweetypumpkinpie = ![];
  108. }
  109. }, this.avg);
  110. break;
  111. case 'fake':
  112. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  113. break;
  114. case 'none':
  115. break;
  116. default:
  117. conservationdust.setTimeout(() => {
  118. if ('osYQC' !== 'osYQC') {
  119. conservationdust.toServer(...ipolitics.getVersion('C_REQUEST_GAMESTAT_PING'));
  120. cooltime = Date.now();
  121. crate = conservationdust.setTimeout(mobheart, this.internalPingInterval);
  122. } else {
  123. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  124. }
  125. }, this.min);
  126. }
  127. return ![];
  128. });
  129. };
  130. switch (crestarrowshower.config.pingMethod) {
  131. case 'internal':
  132. body();
  133. break;
  134. case 'external':
  135. crestblastball();
  136. break;
  137. case 'hybrid':
  138. crestblastball();
  139. body();
  140. }
  141. this.destructor = () => {
  142. if ('yXTHy' === 'yXTHy') {
  143. if (!this.externalPingChecker) {
  144. if ('wuDDE' !== 'BVlSQ') {
  145. return;
  146. } else {
  147. conservationdust.toClient(...ipolitics.getVersion('S_RESPONSE_GAMESTAT_PONG'));
  148. }
  149. }
  150. this.externalPingChecker.kill();
  151. this.externalPingChecker = null;
  152. } else {
  153. crestarrowshower.config.pingMethod = 'internal';
  154. }
  155. };
  156. }
  157. }
  158. module.exports = E;