tunli 0.0.27 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +158 -67
  3. package/bin/tunli +4 -5
  4. package/dist/api-client/ApiClient.d.ts +18 -0
  5. package/dist/api-client/ApiClient.d.ts.map +1 -0
  6. package/dist/api-client/ApiClient.js +100 -0
  7. package/dist/api-client/ApiClient.js.map +1 -0
  8. package/dist/api-client/types.d.ts +26 -0
  9. package/dist/api-client/types.d.ts.map +1 -0
  10. package/dist/api-client/types.js +2 -0
  11. package/dist/api-client/types.js.map +1 -0
  12. package/dist/api-client/utils.d.ts +4 -0
  13. package/dist/api-client/utils.d.ts.map +1 -0
  14. package/dist/api-client/utils.js +13 -0
  15. package/dist/api-client/utils.js.map +1 -0
  16. package/dist/cli-app/AppEventEmitter.d.ts +57 -0
  17. package/dist/cli-app/AppEventEmitter.d.ts.map +1 -0
  18. package/dist/cli-app/AppEventEmitter.js +11 -0
  19. package/dist/cli-app/AppEventEmitter.js.map +1 -0
  20. package/dist/cli-app/Dashboard.d.ts +4 -0
  21. package/dist/cli-app/Dashboard.d.ts.map +1 -0
  22. package/dist/cli-app/Dashboard.js +241 -0
  23. package/dist/cli-app/Dashboard.js.map +1 -0
  24. package/dist/cli-app/LiveLog.d.ts +4 -0
  25. package/dist/cli-app/LiveLog.d.ts.map +1 -0
  26. package/dist/cli-app/LiveLog.js +28 -0
  27. package/dist/cli-app/LiveLog.js.map +1 -0
  28. package/dist/cli-app/types.d.ts +10 -0
  29. package/dist/cli-app/types.d.ts.map +1 -0
  30. package/dist/cli-app/types.js +2 -0
  31. package/dist/cli-app/types.js.map +1 -0
  32. package/dist/cli-app/versionCheck.d.ts +4 -0
  33. package/dist/cli-app/versionCheck.d.ts.map +1 -0
  34. package/dist/cli-app/versionCheck.js +46 -0
  35. package/dist/cli-app/versionCheck.js.map +1 -0
  36. package/dist/client.d.ts +2 -0
  37. package/dist/client.d.ts.map +1 -0
  38. package/dist/client.js +75 -0
  39. package/dist/client.js.map +1 -0
  40. package/dist/commander/Argument.d.ts +19 -0
  41. package/dist/commander/Argument.d.ts.map +1 -0
  42. package/dist/commander/Argument.js +25 -0
  43. package/dist/commander/Argument.js.map +1 -0
  44. package/dist/commander/Command.d.ts +23 -0
  45. package/dist/commander/Command.d.ts.map +1 -0
  46. package/dist/commander/Command.js +159 -0
  47. package/dist/commander/Command.js.map +1 -0
  48. package/dist/commander/InvalidArgumentError.d.ts +5 -0
  49. package/dist/commander/InvalidArgumentError.d.ts.map +1 -0
  50. package/dist/commander/InvalidArgumentError.js +8 -0
  51. package/dist/commander/InvalidArgumentError.js.map +1 -0
  52. package/dist/commander/Option.d.ts +15 -0
  53. package/dist/commander/Option.d.ts.map +1 -0
  54. package/dist/commander/Option.js +43 -0
  55. package/dist/commander/Option.js.map +1 -0
  56. package/dist/commander/index.d.ts +7 -0
  57. package/dist/commander/index.d.ts.map +1 -0
  58. package/dist/commander/index.js +5 -0
  59. package/dist/commander/index.js.map +1 -0
  60. package/dist/commander/types.d.ts +2 -0
  61. package/dist/commander/types.d.ts.map +1 -0
  62. package/dist/commander/types.js +2 -0
  63. package/dist/commander/types.js.map +1 -0
  64. package/dist/commands/CommandAuth/CommandAuth.d.ts +4 -0
  65. package/dist/commands/CommandAuth/CommandAuth.d.ts.map +1 -0
  66. package/dist/commands/CommandAuth/CommandAuth.js +24 -0
  67. package/dist/commands/CommandAuth/CommandAuth.js.map +1 -0
  68. package/dist/commands/CommandConfig/CommandConfig.d.ts +4 -0
  69. package/dist/commands/CommandConfig/CommandConfig.d.ts.map +1 -0
  70. package/dist/commands/CommandConfig/CommandConfig.js +37 -0
  71. package/dist/commands/CommandConfig/CommandConfig.js.map +1 -0
  72. package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts +4 -0
  73. package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts.map +1 -0
  74. package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js +20 -0
  75. package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js.map +1 -0
  76. package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts +5 -0
  77. package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts.map +1 -0
  78. package/dist/commands/CommandConfig/sub-commands/configGetCommand.js +23 -0
  79. package/dist/commands/CommandConfig/sub-commands/configGetCommand.js.map +1 -0
  80. package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts +4 -0
  81. package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts.map +1 -0
  82. package/dist/commands/CommandConfig/sub-commands/configSetCommand.js +69 -0
  83. package/dist/commands/CommandConfig/sub-commands/configSetCommand.js.map +1 -0
  84. package/dist/commands/CommandConfig/types.d.ts +6 -0
  85. package/dist/commands/CommandConfig/types.d.ts.map +1 -0
  86. package/dist/commands/CommandConfig/types.js +2 -0
  87. package/dist/commands/CommandConfig/types.js.map +1 -0
  88. package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts +3 -0
  89. package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts.map +1 -0
  90. package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js +8 -0
  91. package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js.map +1 -0
  92. package/dist/commands/CommandConfig/utils/resolveConfig.d.ts +8 -0
  93. package/dist/commands/CommandConfig/utils/resolveConfig.d.ts.map +1 -0
  94. package/dist/commands/CommandConfig/utils/resolveConfig.js +33 -0
  95. package/dist/commands/CommandConfig/utils/resolveConfig.js.map +1 -0
  96. package/dist/commands/CommandConfig/utils/sharedOptions.d.ts +3 -0
  97. package/dist/commands/CommandConfig/utils/sharedOptions.d.ts.map +1 -0
  98. package/dist/commands/CommandConfig/utils/sharedOptions.js +14 -0
  99. package/dist/commands/CommandConfig/utils/sharedOptions.js.map +1 -0
  100. package/dist/commands/CommandDaemon/CommandDaemon.d.ts +4 -0
  101. package/dist/commands/CommandDaemon/CommandDaemon.d.ts.map +1 -0
  102. package/dist/commands/CommandDaemon/CommandDaemon.js +57 -0
  103. package/dist/commands/CommandDaemon/CommandDaemon.js.map +1 -0
  104. package/dist/commands/CommandDashboard/CommandDashboard.d.ts +4 -0
  105. package/dist/commands/CommandDashboard/CommandDashboard.d.ts.map +1 -0
  106. package/dist/commands/CommandDashboard/CommandDashboard.js +54 -0
  107. package/dist/commands/CommandDashboard/CommandDashboard.js.map +1 -0
  108. package/dist/commands/CommandHTTP/CommandHttp.d.ts +4 -0
  109. package/dist/commands/CommandHTTP/CommandHttp.d.ts.map +1 -0
  110. package/dist/commands/CommandHTTP/CommandHttp.js +50 -0
  111. package/dist/commands/CommandHTTP/CommandHttp.js.map +1 -0
  112. package/dist/commands/CommandInit/CommandInit.d.ts +4 -0
  113. package/dist/commands/CommandInit/CommandInit.d.ts.map +1 -0
  114. package/dist/commands/CommandInit/CommandInit.js +36 -0
  115. package/dist/commands/CommandInit/CommandInit.js.map +1 -0
  116. package/dist/commands/CommandList/CommandList.d.ts +4 -0
  117. package/dist/commands/CommandList/CommandList.d.ts.map +1 -0
  118. package/dist/commands/CommandList/CommandList.js +54 -0
  119. package/dist/commands/CommandList/CommandList.js.map +1 -0
  120. package/dist/commands/CommandLogs/CommandLogs.d.ts +4 -0
  121. package/dist/commands/CommandLogs/CommandLogs.d.ts.map +1 -0
  122. package/dist/commands/CommandLogs/CommandLogs.js +33 -0
  123. package/dist/commands/CommandLogs/CommandLogs.js.map +1 -0
  124. package/dist/commands/CommandProfile/CommandProfile.d.ts +5 -0
  125. package/dist/commands/CommandProfile/CommandProfile.d.ts.map +1 -0
  126. package/dist/commands/CommandProfile/CommandProfile.js +64 -0
  127. package/dist/commands/CommandProfile/CommandProfile.js.map +1 -0
  128. package/dist/commands/CommandRegister/CommandRegister.d.ts +4 -0
  129. package/dist/commands/CommandRegister/CommandRegister.d.ts.map +1 -0
  130. package/dist/commands/CommandRegister/CommandRegister.js +43 -0
  131. package/dist/commands/CommandRegister/CommandRegister.js.map +1 -0
  132. package/dist/commands/CommandRestart/CommandRestart.d.ts +4 -0
  133. package/dist/commands/CommandRestart/CommandRestart.d.ts.map +1 -0
  134. package/dist/commands/CommandRestart/CommandRestart.js +62 -0
  135. package/dist/commands/CommandRestart/CommandRestart.js.map +1 -0
  136. package/dist/commands/CommandServer/CommandServer.d.ts +4 -0
  137. package/dist/commands/CommandServer/CommandServer.d.ts.map +1 -0
  138. package/dist/commands/CommandServer/CommandServer.js +24 -0
  139. package/dist/commands/CommandServer/CommandServer.js.map +1 -0
  140. package/dist/commands/CommandStop/CommandStop.d.ts +4 -0
  141. package/dist/commands/CommandStop/CommandStop.d.ts.map +1 -0
  142. package/dist/commands/CommandStop/CommandStop.js +25 -0
  143. package/dist/commands/CommandStop/CommandStop.js.map +1 -0
  144. package/dist/commands/CommandUpdate/CommandUpdate.d.ts +4 -0
  145. package/dist/commands/CommandUpdate/CommandUpdate.d.ts.map +1 -0
  146. package/dist/commands/CommandUpdate/CommandUpdate.js +38 -0
  147. package/dist/commands/CommandUpdate/CommandUpdate.js.map +1 -0
  148. package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts +4 -0
  149. package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts.map +1 -0
  150. package/dist/commands/CommandUseProfile/CommandUseProfile.js +63 -0
  151. package/dist/commands/CommandUseProfile/CommandUseProfile.js.map +1 -0
  152. package/dist/commands/helper/Help.d.ts +4 -0
  153. package/dist/commands/helper/Help.d.ts.map +1 -0
  154. package/dist/commands/helper/Help.js +134 -0
  155. package/dist/commands/helper/Help.js.map +1 -0
  156. package/dist/commands/helper/Parser.d.ts +55 -0
  157. package/dist/commands/helper/Parser.d.ts.map +1 -0
  158. package/dist/commands/helper/Parser.js +280 -0
  159. package/dist/commands/helper/Parser.js.map +1 -0
  160. package/dist/commands/shared/allowDenyCidrCommand.d.ts +3 -0
  161. package/dist/commands/shared/allowDenyCidrCommand.d.ts.map +1 -0
  162. package/dist/commands/shared/allowDenyCidrCommand.js +10 -0
  163. package/dist/commands/shared/allowDenyCidrCommand.js.map +1 -0
  164. package/dist/commands/shared/configServersCommand.d.ts +4 -0
  165. package/dist/commands/shared/configServersCommand.d.ts.map +1 -0
  166. package/dist/commands/shared/configServersCommand.js +19 -0
  167. package/dist/commands/shared/configServersCommand.js.map +1 -0
  168. package/dist/commands/utils.d.ts +3 -0
  169. package/dist/commands/utils.d.ts.map +1 -0
  170. package/dist/commands/utils.js +17 -0
  171. package/dist/commands/utils.js.map +1 -0
  172. package/dist/config/ParsedConfig.d.ts +31 -0
  173. package/dist/config/ParsedConfig.d.ts.map +1 -0
  174. package/dist/config/ParsedConfig.js +116 -0
  175. package/dist/config/ParsedConfig.js.map +1 -0
  176. package/dist/config/ParsedGlobalConfig.d.ts +5 -0
  177. package/dist/config/ParsedGlobalConfig.d.ts.map +1 -0
  178. package/dist/config/ParsedGlobalConfig.js +7 -0
  179. package/dist/config/ParsedGlobalConfig.js.map +1 -0
  180. package/dist/config/ParsedLocalConfig.d.ts +5 -0
  181. package/dist/config/ParsedLocalConfig.d.ts.map +1 -0
  182. package/dist/config/ParsedLocalConfig.js +7 -0
  183. package/dist/config/ParsedLocalConfig.js.map +1 -0
  184. package/dist/config/ParsedProfileConfig.d.ts +46 -0
  185. package/dist/config/ParsedProfileConfig.d.ts.map +1 -0
  186. package/dist/config/ParsedProfileConfig.js +120 -0
  187. package/dist/config/ParsedProfileConfig.js.map +1 -0
  188. package/dist/config/ParsedServerConfig.d.ts +20 -0
  189. package/dist/config/ParsedServerConfig.d.ts.map +1 -0
  190. package/dist/config/ParsedServerConfig.js +55 -0
  191. package/dist/config/ParsedServerConfig.js.map +1 -0
  192. package/dist/config/TempProfileConfig.d.ts +8 -0
  193. package/dist/config/TempProfileConfig.d.ts.map +1 -0
  194. package/dist/config/TempProfileConfig.js +13 -0
  195. package/dist/config/TempProfileConfig.js.map +1 -0
  196. package/dist/config/utils.d.ts +2 -0
  197. package/dist/config/utils.d.ts.map +1 -0
  198. package/dist/config/utils.js +8 -0
  199. package/dist/config/utils.js.map +1 -0
  200. package/dist/config/validations/validateProfileConfig.d.ts +4 -0
  201. package/dist/config/validations/validateProfileConfig.d.ts.map +1 -0
  202. package/dist/config/validations/validateProfileConfig.js +76 -0
  203. package/dist/config/validations/validateProfileConfig.js.map +1 -0
  204. package/dist/core/FS/utils.d.ts +12 -0
  205. package/dist/core/FS/utils.d.ts.map +1 -0
  206. package/dist/core/FS/utils.js +55 -0
  207. package/dist/core/FS/utils.js.map +1 -0
  208. package/dist/daemon/DaemonClient.d.ts +16 -0
  209. package/dist/daemon/DaemonClient.d.ts.map +1 -0
  210. package/dist/daemon/DaemonClient.js +158 -0
  211. package/dist/daemon/DaemonClient.js.map +1 -0
  212. package/dist/daemon/DaemonServer.d.ts +8 -0
  213. package/dist/daemon/DaemonServer.d.ts.map +1 -0
  214. package/dist/daemon/DaemonServer.js +201 -0
  215. package/dist/daemon/DaemonServer.js.map +1 -0
  216. package/dist/daemon/protocol.d.ts +101 -0
  217. package/dist/daemon/protocol.d.ts.map +1 -0
  218. package/dist/daemon/protocol.js +2 -0
  219. package/dist/daemon/protocol.js.map +1 -0
  220. package/dist/daemon-main.d.ts +2 -0
  221. package/dist/daemon-main.d.ts.map +1 -0
  222. package/dist/daemon-main.js +13 -0
  223. package/dist/daemon-main.js.map +1 -0
  224. package/dist/launcher-main.d.ts +2 -0
  225. package/dist/launcher-main.d.ts.map +1 -0
  226. package/dist/launcher-main.js +57 -0
  227. package/dist/launcher-main.js.map +1 -0
  228. package/dist/lib/Flow/applyUpdate.d.ts +3 -0
  229. package/dist/lib/Flow/applyUpdate.d.ts.map +1 -0
  230. package/dist/lib/Flow/applyUpdate.js +34 -0
  231. package/dist/lib/Flow/applyUpdate.js.map +1 -0
  232. package/dist/lib/Flow/downloadBinaryUpdate.d.ts +3 -0
  233. package/dist/lib/Flow/downloadBinaryUpdate.d.ts.map +1 -0
  234. package/dist/lib/Flow/downloadBinaryUpdate.js +54 -0
  235. package/dist/lib/Flow/downloadBinaryUpdate.js.map +1 -0
  236. package/dist/lib/Flow/getLatestVersion.d.ts +2 -0
  237. package/dist/lib/Flow/getLatestVersion.d.ts.map +1 -0
  238. package/dist/lib/Flow/getLatestVersion.js +13 -0
  239. package/dist/lib/Flow/getLatestVersion.js.map +1 -0
  240. package/dist/lib/defs.d.ts +18 -0
  241. package/dist/lib/defs.d.ts.map +1 -0
  242. package/dist/lib/defs.js +33 -0
  243. package/dist/lib/defs.js.map +1 -0
  244. package/dist/logger/logger.d.ts +6 -0
  245. package/dist/logger/logger.d.ts.map +1 -0
  246. package/dist/logger/logger.js +34 -0
  247. package/dist/logger/logger.js.map +1 -0
  248. package/dist/output-formats/colors.d.ts +7 -0
  249. package/dist/output-formats/colors.d.ts.map +1 -0
  250. package/dist/output-formats/colors.js +8 -0
  251. package/dist/output-formats/colors.js.map +1 -0
  252. package/dist/output-formats/formatConfig.d.ts +3 -0
  253. package/dist/output-formats/formatConfig.d.ts.map +1 -0
  254. package/dist/output-formats/formatConfig.js +59 -0
  255. package/dist/output-formats/formatConfig.js.map +1 -0
  256. package/dist/output-formats/formatConfigPath.d.ts +4 -0
  257. package/dist/output-formats/formatConfigPath.d.ts.map +1 -0
  258. package/dist/output-formats/formatConfigPath.js +7 -0
  259. package/dist/output-formats/formatConfigPath.js.map +1 -0
  260. package/dist/output-formats/formatPath.d.ts +2 -0
  261. package/dist/output-formats/formatPath.d.ts.map +1 -0
  262. package/dist/output-formats/formatPath.js +6 -0
  263. package/dist/output-formats/formatPath.js.map +1 -0
  264. package/dist/output-formats/formatProfile.d.ts +3 -0
  265. package/dist/output-formats/formatProfile.d.ts.map +1 -0
  266. package/dist/output-formats/formatProfile.js +35 -0
  267. package/dist/output-formats/formatProfile.js.map +1 -0
  268. package/dist/output-formats/formatProfilesShort.d.ts +3 -0
  269. package/dist/output-formats/formatProfilesShort.d.ts.map +1 -0
  270. package/dist/output-formats/formatProfilesShort.js +19 -0
  271. package/dist/output-formats/formatProfilesShort.js.map +1 -0
  272. package/dist/output-formats/formatSaveResult.d.ts +4 -0
  273. package/dist/output-formats/formatSaveResult.d.ts.map +1 -0
  274. package/dist/output-formats/formatSaveResult.js +7 -0
  275. package/dist/output-formats/formatSaveResult.js.map +1 -0
  276. package/dist/output-formats/table.d.ts +8 -0
  277. package/dist/output-formats/table.d.ts.map +1 -0
  278. package/dist/output-formats/table.js +15 -0
  279. package/dist/output-formats/table.js.map +1 -0
  280. package/dist/package-json/packageJson.d.ts +6 -0
  281. package/dist/package-json/packageJson.d.ts.map +1 -0
  282. package/dist/package-json/packageJson.js +12 -0
  283. package/dist/package-json/packageJson.js.map +1 -0
  284. package/dist/proxy/Proxy.d.ts +6 -0
  285. package/dist/proxy/Proxy.d.ts.map +1 -0
  286. package/dist/proxy/Proxy.js +203 -0
  287. package/dist/proxy/Proxy.js.map +1 -0
  288. package/dist/sea-main.d.ts +2 -0
  289. package/dist/sea-main.d.ts.map +1 -0
  290. package/dist/sea-main.js +20 -0
  291. package/dist/sea-main.js.map +1 -0
  292. package/dist/types/types.d.ts +55 -0
  293. package/dist/types/types.d.ts.map +1 -0
  294. package/dist/types/types.js +2 -0
  295. package/dist/types/types.js.map +1 -0
  296. package/dist/utils/arrayFunctions.d.ts +24 -0
  297. package/dist/utils/arrayFunctions.d.ts.map +1 -0
  298. package/dist/utils/arrayFunctions.js +43 -0
  299. package/dist/utils/arrayFunctions.js.map +1 -0
  300. package/dist/utils/assertFunctions.d.ts +7 -0
  301. package/dist/utils/assertFunctions.d.ts.map +1 -0
  302. package/dist/utils/assertFunctions.js +20 -0
  303. package/dist/utils/assertFunctions.js.map +1 -0
  304. package/dist/utils/checkFunctions.d.ts +34 -0
  305. package/dist/utils/checkFunctions.d.ts.map +1 -0
  306. package/dist/utils/checkFunctions.js +87 -0
  307. package/dist/utils/checkFunctions.js.map +1 -0
  308. package/dist/utils/cliFunctions.d.ts +10 -0
  309. package/dist/utils/cliFunctions.d.ts.map +1 -0
  310. package/dist/utils/cliFunctions.js +68 -0
  311. package/dist/utils/cliFunctions.js.map +1 -0
  312. package/dist/utils/hashFunctions.d.ts +10 -0
  313. package/dist/utils/hashFunctions.d.ts.map +1 -0
  314. package/dist/utils/hashFunctions.js +11 -0
  315. package/dist/utils/hashFunctions.js.map +1 -0
  316. package/dist/utils/npmFunctions.d.ts +3 -0
  317. package/dist/utils/npmFunctions.d.ts.map +1 -0
  318. package/dist/utils/npmFunctions.js +28 -0
  319. package/dist/utils/npmFunctions.js.map +1 -0
  320. package/dist/utils/stringFunctions.d.ts +12 -0
  321. package/dist/utils/stringFunctions.d.ts.map +1 -0
  322. package/dist/utils/stringFunctions.js +37 -0
  323. package/dist/utils/stringFunctions.js.map +1 -0
  324. package/package.json +39 -16
  325. package/client.js +0 -33
  326. package/src/cli-app/Dashboard.js +0 -220
  327. package/src/cli-app/Screen/FullScreenModal.js +0 -63
  328. package/src/cli-app/Screen.js +0 -140
  329. package/src/cli-app/elements/ElementNode.js +0 -97
  330. package/src/cli-app/elements/Line.js +0 -21
  331. package/src/cli-app/elements/List/List.js +0 -227
  332. package/src/cli-app/elements/List/ListCell.js +0 -83
  333. package/src/cli-app/elements/List/ListColumn.js +0 -52
  334. package/src/cli-app/elements/List/ListRow.js +0 -118
  335. package/src/cli-app/elements/Row.js +0 -38
  336. package/src/cli-app/helper/utils.js +0 -42
  337. package/src/commands/Action/addDelValuesAction.js +0 -56
  338. package/src/commands/CommandAuth.js +0 -32
  339. package/src/commands/CommandClearAll.js +0 -27
  340. package/src/commands/CommandConfig.js +0 -59
  341. package/src/commands/CommandHTTP.js +0 -192
  342. package/src/commands/CommandInvite.js +0 -38
  343. package/src/commands/CommandRefresh.js +0 -35
  344. package/src/commands/CommandRegister.js +0 -48
  345. package/src/commands/Option/DeleteOption.js +0 -6
  346. package/src/commands/Option/ProfileListOption.js +0 -65
  347. package/src/commands/Option/SelectConfigOption.js +0 -52
  348. package/src/commands/SubCommand/AllowDenyCidrCommand.js +0 -28
  349. package/src/commands/SubCommand/HostCommand.js +0 -22
  350. package/src/commands/SubCommand/PortCommand.js +0 -20
  351. package/src/commands/SubCommand/ProtocolCommand.js +0 -21
  352. package/src/commands/helper/AliasResolver.js +0 -13
  353. package/src/commands/helper/BindArgs.js +0 -53
  354. package/src/commands/helper/SharedArg.js +0 -32
  355. package/src/commands/utils.js +0 -96
  356. package/src/config/ConfigAbstract.js +0 -353
  357. package/src/config/ConfigManager.js +0 -70
  358. package/src/config/GlobalConfig.js +0 -14
  359. package/src/config/GlobalLocalShardConfigAbstract.js +0 -98
  360. package/src/config/LocalConfig.js +0 -7
  361. package/src/config/PropertyConfig.js +0 -122
  362. package/src/config/SystemConfig.js +0 -31
  363. package/src/core/FS/utils.js +0 -60
  364. package/src/core/Ref.js +0 -70
  365. package/src/lib/Flow/getCurrentIp.js +0 -18
  366. package/src/lib/Flow/getLatestVersion.js +0 -13
  367. package/src/lib/Flow/proxyUrl.js +0 -35
  368. package/src/lib/Flow/validateAuthToken.js +0 -19
  369. package/src/lib/HttpClient.js +0 -61
  370. package/src/lib/Proxy.js +0 -42
  371. package/src/lib/defs.js +0 -13
  372. package/src/net/IPV4.js +0 -139
  373. package/src/net/http/IncomingMessage.js +0 -92
  374. package/src/net/http/ServerResponse.js +0 -126
  375. package/src/net/http/TunliRequest.js +0 -1
  376. package/src/net/http/TunliResponse.js +0 -1
  377. package/src/net/http/TunnelRequest.js +0 -229
  378. package/src/net/http/TunnelResponse.js +0 -119
  379. package/src/tunnel-client/TunnelClient.js +0 -144
  380. package/src/utils/arrayFunctions.js +0 -45
  381. package/src/utils/checkFunctions.js +0 -182
  382. package/src/utils/cliFunctions.js +0 -63
  383. package/src/utils/createRequest.js +0 -12
  384. package/src/utils/hashFunctions.js +0 -9
  385. package/src/utils/httpFunction.js +0 -23
  386. package/src/utils/npmFunctions.js +0 -27
  387. package/src/utils/stringFunctions.js +0 -59
  388. package/types/index.d.ts +0 -119
@@ -1,92 +0,0 @@
1
- import {ServerResponse} from "#src/net/http/ServerResponse"
2
- import {Socket} from "socket.io-client"
3
- import {getRemoteAddress} from "#src/utils/httpFunction"
4
-
5
- /**
6
- * IncomingMessage class represents an HTTP request received by the server.
7
- */
8
- export class IncomingMessage {
9
- /**
10
- * @type {ServerResponse}
11
- * @private
12
- */
13
- #res
14
-
15
- /**
16
- * @type {string}
17
- * @private
18
- */
19
- #id
20
-
21
- /**
22
- * @type {Socket}
23
- * @private
24
- */
25
- #socket
26
-
27
- /**
28
- * @type {string}
29
- * @private
30
- */
31
- #remoteAddress
32
-
33
- /**
34
- * @type {string}
35
- * @private
36
- */
37
- #url
38
-
39
- /**
40
- * Creates an instance of IncomingMessage.
41
- * @param {SocketIoRawRequestObject} request - The raw request object.
42
- * @param {string} requestId - The unique request identifier.
43
- * @param {Socket} socket - The socket to communicate over.
44
- */
45
- constructor(request, requestId, socket) {
46
- this.#url = request.path
47
- this.#id = requestId
48
- this.#socket = socket
49
- this.#remoteAddress = getRemoteAddress(request)
50
- }
51
-
52
- /**
53
- * Returns the URL path.
54
- * @return {string}
55
- */
56
- get url() {
57
- return this.#url
58
- }
59
-
60
- /**
61
- * Returns the remote address.
62
- * @return {string}
63
- */
64
- get remoteAddress() {
65
- return this.#remoteAddress
66
- }
67
-
68
- /**
69
- * Returns the unique request identifier.
70
- * @return {string}
71
- */
72
- get id() {
73
- return this.#id
74
- }
75
-
76
- /**
77
- * Returns the socket associated with the request.
78
- * @return {Socket}
79
- */
80
- get socket() {
81
- return this.#socket
82
- }
83
-
84
- /**
85
- * Returns the ServerResponse instance, creating it if necessary.
86
- * @return {ServerResponse}
87
- */
88
- get res() {
89
- this.#res ??= new ServerResponse(this)
90
- return this.#res
91
- }
92
- }
@@ -1,126 +0,0 @@
1
- import {IncomingMessage} from "#src/net/http/IncomingMessage"
2
- import {TunnelResponse} from "#src/net/http/TunnelResponse"
3
-
4
- /**
5
- * ServerResponse class represents an HTTP response to be sent back to the client.
6
- */
7
- export class ServerResponse {
8
-
9
- /**
10
- * @type {IncomingMessage}
11
- * @private
12
- */
13
- #req
14
-
15
- /**
16
- * @type {Object}
17
- * @private
18
- */
19
- #headers = {}
20
-
21
- /**
22
- * @type {string}
23
- * @private
24
- */
25
- #httpVersion = '1.1'
26
-
27
- /**
28
- * @type {TunnelResponse}
29
- * @private
30
- */
31
- #res
32
-
33
- /**
34
- * @type {string}
35
- * @private
36
- */
37
- #statusMessage = 'OK'
38
-
39
- /**
40
- * @type {number}
41
- * @private
42
- */
43
- #statusCode = 200
44
-
45
- /**
46
- * Creates an instance of ServerResponse.
47
- * @param {IncomingMessage} incomingMessage - The incoming message object.
48
- */
49
- constructor(incomingMessage) {
50
- this.#req = incomingMessage
51
- this.#res = new TunnelResponse({
52
- responseId: incomingMessage.id,
53
- socket: incomingMessage.socket,
54
- })
55
- }
56
-
57
- /**
58
- * Returns the associated IncomingMessage instance.
59
- * @return {IncomingMessage}
60
- */
61
- get req() {
62
- return this.#req
63
- }
64
-
65
- /**
66
- * Sets the status code and message.
67
- * @param {number} statusCode - The HTTP status code.
68
- * @param {string} [statusMessage] - The HTTP status message.
69
- * @return {ServerResponse}
70
- */
71
- status(statusCode, statusMessage) {
72
- this.#statusMessage = statusMessage ?? {
73
- 200: 'OK',
74
- 201: 'Created',
75
- 202: 'Accepted',
76
- 204: 'No Content',
77
- 301: 'Moved Permanently',
78
- 302: 'Found',
79
- 304: 'Not Modified',
80
- 400: 'Bad Request',
81
- 401: 'Unauthorized',
82
- 403: 'Forbidden',
83
- 404: 'Not Found',
84
- 405: 'Method Not Allowed',
85
- 500: 'Internal Server Error',
86
- 501: 'Not Implemented',
87
- 502: 'Bad Gateway',
88
- 503: 'Service Unavailable',
89
- 504: 'Gateway Timeout'
90
- }[statusCode] ?? 'Unknown Status'
91
- this.#statusCode = statusCode
92
- return this
93
- }
94
-
95
- /**
96
- * Sends the response with the provided body.
97
- * @param {string|Buffer} body - The body of the response.
98
- * @return {ServerResponse}
99
- */
100
- send(body) {
101
- this.#res.writeHead(this.#statusCode, this.#statusMessage, this.#headers, this.#httpVersion)
102
- this.#res.write(body)
103
- this.#res.end()
104
- return this
105
- }
106
-
107
- /**
108
- * Sets the headers for the response.
109
- * @param {Object} headers - The headers to set.
110
- * @return {ServerResponse}
111
- */
112
- headers(headers) {
113
- this.#headers = headers
114
- return this
115
- }
116
-
117
- /**
118
- * Sets the HTTP version for the response.
119
- * @param {string} httpVersion - The HTTP version to set.
120
- * @return {ServerResponse}
121
- */
122
- httpVersion(httpVersion) {
123
- this.#httpVersion = httpVersion
124
- return this
125
- }
126
- }
@@ -1 +0,0 @@
1
- export class TunliRequest {}
@@ -1 +0,0 @@
1
- export class TunliResponse {}
@@ -1,229 +0,0 @@
1
- import {Readable} from "stream";
2
- import {TunnelResponse} from "#src/net/http/TunnelResponse";
3
- import https from "node:https";
4
- import http from "node:http";
5
-
6
- class TunnelRequest extends Readable {
7
-
8
- #socket
9
-
10
- /**
11
- * uuid v4 request/response id
12
- * @type {string}
13
- */
14
- #requestId
15
-
16
- constructor({socket, requestId}) {
17
-
18
- super();
19
- this.#socket = socket;
20
- this.#requestId = requestId;
21
-
22
- this.#bindEvents()
23
- }
24
-
25
- #bindEvents() {
26
- const events = {
27
- 'request-pipe': this.#onRequestPipe.bind(this),
28
- 'request-pipes': this.#onRequestPipes.bind(this),
29
- 'request-pipe-error': this.#onRequestPipeError.bind(this),
30
- 'request-pipe-end': this.#onRequestPipeEnd.bind(this),
31
- }
32
-
33
- for (const [event, handler] of Object.entries(events)) {
34
- this.#socket.on(event, handler);
35
- }
36
-
37
- this.once('close', () => {
38
- for (const [event, handler] of Object.entries(events)) {
39
- this.#socket.off(event, handler);
40
- }
41
- })
42
- }
43
-
44
- #onRequestPipe(requestId, data) {
45
- if (this.#requestId === requestId) {
46
- this.push(data);
47
- }
48
- }
49
-
50
- #onRequestPipes(requestId, data) {
51
- if (this.#requestId === requestId) {
52
- data.forEach((chunk) => {
53
- this.push(chunk);
54
- });
55
- }
56
- }
57
-
58
- #onRequestPipeError(requestId, error) {
59
- if (this.#requestId === requestId) {
60
- this.destroy(new Error(error));
61
- }
62
- }
63
-
64
- #onRequestPipeEnd(requestId, data) {
65
- if (this.#requestId === requestId) {
66
- if (data) {
67
- this.push(data);
68
- }
69
- this.push(null);
70
- }
71
- }
72
-
73
- _read() {
74
- // No op
75
- }
76
- }
77
-
78
- const setupErrorHandlers = (source, target) => {
79
- const onTunnelRequestError = (e) => {
80
- source.off('end', onTunnelRequestEnd);
81
- target.destroy(e);
82
- };
83
- const onTunnelRequestEnd = () => {
84
- target.off('error', onTunnelRequestError);
85
- };
86
-
87
- source.once('error', onTunnelRequestError);
88
- source.once('end', onTunnelRequestEnd);
89
- };
90
-
91
-
92
- /**
93
- * @param {SocketIoRawRequestObject} req
94
- * @param {EventEmitter} eventEmitter
95
- * @param {tunnelClientOptions} options
96
- */
97
- export const forwardTunnelRequestToProxyTarget = (req, eventEmitter, options) => {
98
-
99
- const tunnelRequest = new TunnelRequest({
100
- requestId: req.requestId,
101
- socket: req.tunnelSocket,
102
- });
103
-
104
- const isWebSocket = req.headers.upgrade === 'websocket'
105
- const localReq = options.protocol === 'https' ? https.request(req) : http.request(req)
106
-
107
- tunnelRequest.pipe(localReq)
108
-
109
- setupErrorHandlers(tunnelRequest, localReq)
110
-
111
- const onLocalResponse = (localRes) => {
112
-
113
- localReq.off('error', onLocalError)
114
-
115
- if (isWebSocket && localRes.upgrade) {
116
- return
117
- }
118
-
119
- if (!isWebSocket) rewriteResponse(localRes, options)
120
-
121
- const tunnelResponse = new TunnelResponse({
122
- responseId: req.requestId,
123
- socket: req.tunnelSocket,
124
- })
125
-
126
- tunnelResponse.writeHead(
127
- localRes.statusCode,
128
- localRes.statusMessage,
129
- localRes.headers,
130
- localRes.httpVersion
131
- )
132
- localRes.pipe(tunnelResponse)
133
- if (!isWebSocket) {
134
- eventEmitter.emit('response', localRes, req)
135
- }
136
- }
137
- const onLocalError = (error) => {
138
-
139
- let statusCode = 500
140
- let statusMessage = 'UNKNOWN ERROR'
141
- if (error.code === 'ECONNREFUSED') {
142
- statusCode = 502
143
- statusMessage = 'Bad gateway'
144
- } else if (error.code === 'ECONNRESET') {
145
- statusCode = 500
146
- statusMessage = 'Connection reset'
147
- } else {
148
- console.error('IMPLEMENT ME')
149
- console.error(error)
150
- console.error(error.code)
151
- }
152
-
153
- eventEmitter.emit('response', {statusCode, statusMessage}, req)
154
- localReq.off('response', onLocalResponse)
155
- req.tunnelSocket.emit('request-error', req.requestId, error && error.message)
156
- tunnelRequest.destroy(error)
157
- }
158
- const onUpgrade = (localRes, localSocket, localHead) => {
159
- if (localHead && localHead.length) {
160
- localSocket.unshift(localHead)
161
- }
162
-
163
- const tunnelResponse = new TunnelResponse({
164
- responseId: req.requestId,
165
- socket: req.tunnelSocket,
166
- duplex: true,
167
- })
168
-
169
- tunnelResponse.writeHead(null, null, localRes.headers)
170
- localSocket
171
- .pipe(tunnelResponse)
172
- .pipe(localSocket)
173
- }
174
-
175
- localReq.once('error', onLocalError)
176
- localReq.once('response', onLocalResponse)
177
-
178
- if (isWebSocket) {
179
- localReq.on('upgrade', onUpgrade)
180
- }
181
- }
182
-
183
-
184
- /**
185
- * @param {Response<IncomingMessage>} localRes
186
- * @param {tunnelClientOptions} options
187
- */
188
- const rewriteResponse = (localRes, options) => {
189
-
190
- options.proxyURL ??= options.server
191
-
192
- const hostSearch = options.origin ?? options.host
193
- const {protocol: protocolReplace, hostname: hostReplace} = new URL(options.proxyURL)
194
- const baseURL = new URL(`${options.protocol}://${hostSearch}:${options.port}`).toString()
195
-
196
- if (localRes.statusCode === 301) {
197
- delete localRes.headers.location
198
- }
199
-
200
- let location = localRes.headers.location
201
- let setCookie = localRes.headers['set-cookie']
202
-
203
- if (!setCookie || !Array.isArray(setCookie)) {
204
- setCookie = null
205
- }
206
-
207
- if (location) {
208
- location = new URL(location, baseURL).toString()
209
- }
210
-
211
- if (location && location.charAt(0) !== '/' && location.startsWith(baseURL)) {
212
- localRes.headers.location = location.replace(baseURL, options.proxyURL)
213
- }
214
-
215
- if (setCookie) {
216
- localRes.headers['set-cookie'] = setCookie.map(cookie => {
217
- return updateCookieDomain(cookie, hostReplace) // TODO MOVE THIS PART TO SERVER
218
- })
219
- }
220
- }
221
-
222
- function extractDomainFromCookieString(cookie) {
223
- const domainMatch = cookie.match(/Domain=([^;]+)/);
224
- return domainMatch ? domainMatch[1] : null;
225
- }
226
-
227
- function updateCookieDomain(cookie, newDomain) {
228
- return cookie.replace(/Domain=[^;]+/, `Domain=${newDomain}`);
229
- }
@@ -1,119 +0,0 @@
1
- import {Duplex} from "stream";
2
-
3
- export class TunnelResponse extends Duplex {
4
-
5
- /**
6
- *
7
- */
8
- #socket
9
-
10
- /**
11
- * uuid v4 request/response id
12
- * @type {string}
13
- */
14
- #responseId
15
-
16
- constructor({socket, responseId, duplex}) {
17
-
18
- super();
19
- this.#socket = socket;
20
- this.#responseId = responseId;
21
-
22
- if (duplex) {
23
- this.#bindEvents()
24
- }
25
- }
26
-
27
- #onResponsePipe(responseId, data) {
28
- if (this.#responseId === responseId) {
29
- this.push(data);
30
- }
31
- }
32
-
33
- #onResponsePipes(responseId, data) {
34
- if (this.#responseId === responseId) {
35
- data.forEach((chunk) => {
36
- this.push(chunk);
37
- });
38
- }
39
- }
40
-
41
- #onResponsePipeError(responseId, error) {
42
- if (this.#responseId === responseId) {
43
- this.destroy(new Error(error));
44
- }
45
- }
46
-
47
- #onResponsePipeEnd(responseId, data) {
48
- if (this.#responseId === responseId) {
49
- if (data) {
50
- this.push(data);
51
- }
52
- this.push(null);
53
- }
54
- }
55
-
56
- #bindEvents() {
57
-
58
- const events = {
59
- 'response-pipe': this.#onResponsePipe.bind(this),
60
- 'response-pipes': this.#onResponsePipes.bind(this),
61
- 'response-pipe-error': this.#onResponsePipeError.bind(this),
62
- 'response-pipe-end': this.#onResponsePipeEnd.bind(this)
63
- };
64
-
65
- for (const [event, handler] of Object.entries(events)) {
66
- this.#socket.on(event, handler);
67
- }
68
-
69
- this.once('close', () => {
70
- console.log('CLOSING CALL')
71
- for (const [event, handler] of Object.entries(events)) {
72
- this.#socket.off(event, handler);
73
- }
74
- })
75
- }
76
-
77
- _write(chunk, encoding, callback) {
78
- this.#socket.emit('response-pipe', this.#responseId, chunk);
79
- this.#socket.io.engine.once('drain', callback)
80
- }
81
-
82
- _writev(chunks, callback) {
83
- this.#socket.emit('response-pipes', this.#responseId, chunks);
84
- this.#socket.io.engine.once('drain', callback)
85
- }
86
-
87
- _final(callback) {
88
- this.#socket.emit('response-pipe-end', this.#responseId);
89
- this.#socket.io.engine.once('drain', callback)
90
- }
91
-
92
- _destroy(e, callback) {
93
- if (e) {
94
- this.#socket.emit('response-pipe-error', this.#responseId, e && e.message);
95
- this.#socket.io.engine.once('drain', callback)
96
- return;
97
- }
98
- callback();
99
- }
100
-
101
- /**
102
- * @param {number} statusCode
103
- * @param {string} statusMessage
104
- * @param {Object} headers
105
- * @param {string} httpVersion
106
- */
107
- writeHead(statusCode, statusMessage, headers, httpVersion) {
108
-
109
- this.#socket.emit('response', this.#responseId, {
110
- statusCode,
111
- statusMessage,
112
- headers,
113
- httpVersion,
114
- });
115
- }
116
-
117
- _read(size) {
118
- }
119
- }
@@ -1,144 +0,0 @@
1
- import {securedHttpClient} from "#lib/HttpClient";
2
- import {forwardTunnelRequestToProxyTarget} from "#src/net/http/TunnelRequest";
3
- import {io} from "socket.io-client";
4
- import EventEmitter from "node:events";
5
- import {ref} from "#src/core/Ref";
6
- import {isValidRemoteAddress} from "#commands/helper/BindArgs";
7
- import {createRequestFromRaw} from "#src/utils/httpFunction";
8
-
9
- export class TunnelClient extends EventEmitter {
10
-
11
- /**
12
- * @type {tunnelClientOptions}
13
- */
14
- #options
15
- #socket
16
- #latency = ref(0)
17
-
18
- /**
19
- * @param {...tunnelClientOptions} options
20
- */
21
- constructor(options) {
22
- super()
23
- this.#options = options
24
- }
25
-
26
- get latency() {
27
- return this.#latency
28
- }
29
-
30
- #bindEvents() {
31
-
32
- const socket = this.#socket
33
- const options = this.#options
34
-
35
- socket.on('connect', () => {
36
- if (socket.connected) {
37
- this.emit('tunnel-connection-established')
38
- }
39
- })
40
-
41
- socket.on('connect_error', (e) => {
42
- this.emit('tunnel-connection-error', e)
43
- })
44
-
45
- socket.on('disconnect', () => {
46
- this.emit('tunnel-connection-closed')
47
- })
48
-
49
- socket.on('request', ( /** string */ requestId, /** SocketIoRawRequestObject */ request) => {
50
-
51
- const req = createRequestFromRaw(request, requestId, socket)
52
- request.requestId = requestId
53
- request.tunnelSocket = socket
54
-
55
- if (!isValidRemoteAddress(req.remoteAddress, options)) {
56
- this.emit('blocked', req.remoteAddress)
57
- req.res.status(401).send(`Access denied for ip ${req.remoteAddress}`)
58
- return;
59
- }
60
-
61
- const isWebSocket = request.headers.upgrade === 'websocket';
62
-
63
- request.port = options.port;
64
- request.hostname = options.host; // TODO hostanme : www.foo.bar.de vs host: www.foo.bar:80
65
- request.rejectUnauthorized = false
66
-
67
- if (options.origin) {
68
- request.headers.host = options.origin;
69
- } else {
70
- request.headers.host = request.hostname
71
- }
72
-
73
- if (!isWebSocket) {
74
- this.emit('request', request)
75
- }
76
-
77
- forwardTunnelRequestToProxyTarget(request, this, this.#options)
78
- })
79
- }
80
-
81
- async #keepAlive() {
82
- const ping = () => {
83
- const start = Date.now();
84
- this.#socket.volatile.emit('ping', () => {
85
- this.#latency.value = Date.now() - start;
86
- });
87
- }
88
-
89
- while (this.#latency.value === 0) {
90
- ping()
91
- await new Promise((resolve) => setTimeout((resolve), 100))
92
- }
93
-
94
- setInterval(ping, 5000)
95
- }
96
-
97
- /**
98
- * @param {Dashboard} [dashboard]
99
- * @return {Promise<TunnelClient>}
100
- */
101
- async init(dashboard) {
102
-
103
- const params = await this.#createParameters(dashboard)
104
- this.#socket = io(this.#options.server, params)
105
- this.#bindEvents()
106
- this.#keepAlive();
107
- return this
108
- }
109
-
110
- /**
111
- * @param {Dashboard} dashboard
112
- * @return {Promise<{path: any, transports: string[], auth: {token: string}, extraHeaders: {}}>}
113
- */
114
- async #createParameters(dashboard) {
115
- const options = this.#options
116
- const webSocketCapturePath = await securedHttpClient(options.authToken).get('/capture_path')
117
-
118
- if (webSocketCapturePath.error) {
119
- dashboard?.destroy()
120
- if (webSocketCapturePath.error?.message === 'Request failed with status code 401') {
121
- console.error('missing authorization, check your registration and try again')
122
- } else {
123
- console.error('could not connect to remote server. pls try again later')
124
- }
125
-
126
- process.exit(1)
127
- }
128
-
129
- const initParams = {
130
- path: webSocketCapturePath.data,
131
- transports: ['websocket'],
132
- auth: {
133
- token: options.authToken,
134
- },
135
- extraHeaders: {},
136
- };
137
-
138
- if (options.path) {
139
- initParams.extraHeaders['path-prefix'] = options.path;
140
- }
141
-
142
- return initParams
143
- }
144
- }