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.
- package/CHANGELOG.md +45 -0
- package/README.md +158 -67
- package/bin/tunli +4 -5
- package/dist/api-client/ApiClient.d.ts +18 -0
- package/dist/api-client/ApiClient.d.ts.map +1 -0
- package/dist/api-client/ApiClient.js +100 -0
- package/dist/api-client/ApiClient.js.map +1 -0
- package/dist/api-client/types.d.ts +26 -0
- package/dist/api-client/types.d.ts.map +1 -0
- package/dist/api-client/types.js +2 -0
- package/dist/api-client/types.js.map +1 -0
- package/dist/api-client/utils.d.ts +4 -0
- package/dist/api-client/utils.d.ts.map +1 -0
- package/dist/api-client/utils.js +13 -0
- package/dist/api-client/utils.js.map +1 -0
- package/dist/cli-app/AppEventEmitter.d.ts +57 -0
- package/dist/cli-app/AppEventEmitter.d.ts.map +1 -0
- package/dist/cli-app/AppEventEmitter.js +11 -0
- package/dist/cli-app/AppEventEmitter.js.map +1 -0
- package/dist/cli-app/Dashboard.d.ts +4 -0
- package/dist/cli-app/Dashboard.d.ts.map +1 -0
- package/dist/cli-app/Dashboard.js +241 -0
- package/dist/cli-app/Dashboard.js.map +1 -0
- package/dist/cli-app/LiveLog.d.ts +4 -0
- package/dist/cli-app/LiveLog.d.ts.map +1 -0
- package/dist/cli-app/LiveLog.js +28 -0
- package/dist/cli-app/LiveLog.js.map +1 -0
- package/dist/cli-app/types.d.ts +10 -0
- package/dist/cli-app/types.d.ts.map +1 -0
- package/dist/cli-app/types.js +2 -0
- package/dist/cli-app/types.js.map +1 -0
- package/dist/cli-app/versionCheck.d.ts +4 -0
- package/dist/cli-app/versionCheck.d.ts.map +1 -0
- package/dist/cli-app/versionCheck.js +46 -0
- package/dist/cli-app/versionCheck.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/commander/Argument.d.ts +19 -0
- package/dist/commander/Argument.d.ts.map +1 -0
- package/dist/commander/Argument.js +25 -0
- package/dist/commander/Argument.js.map +1 -0
- package/dist/commander/Command.d.ts +23 -0
- package/dist/commander/Command.d.ts.map +1 -0
- package/dist/commander/Command.js +159 -0
- package/dist/commander/Command.js.map +1 -0
- package/dist/commander/InvalidArgumentError.d.ts +5 -0
- package/dist/commander/InvalidArgumentError.d.ts.map +1 -0
- package/dist/commander/InvalidArgumentError.js +8 -0
- package/dist/commander/InvalidArgumentError.js.map +1 -0
- package/dist/commander/Option.d.ts +15 -0
- package/dist/commander/Option.d.ts.map +1 -0
- package/dist/commander/Option.js +43 -0
- package/dist/commander/Option.js.map +1 -0
- package/dist/commander/index.d.ts +7 -0
- package/dist/commander/index.d.ts.map +1 -0
- package/dist/commander/index.js +5 -0
- package/dist/commander/index.js.map +1 -0
- package/dist/commander/types.d.ts +2 -0
- package/dist/commander/types.d.ts.map +1 -0
- package/dist/commander/types.js +2 -0
- package/dist/commander/types.js.map +1 -0
- package/dist/commands/CommandAuth/CommandAuth.d.ts +4 -0
- package/dist/commands/CommandAuth/CommandAuth.d.ts.map +1 -0
- package/dist/commands/CommandAuth/CommandAuth.js +24 -0
- package/dist/commands/CommandAuth/CommandAuth.js.map +1 -0
- package/dist/commands/CommandConfig/CommandConfig.d.ts +4 -0
- package/dist/commands/CommandConfig/CommandConfig.d.ts.map +1 -0
- package/dist/commands/CommandConfig/CommandConfig.js +37 -0
- package/dist/commands/CommandConfig/CommandConfig.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts +4 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js +20 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts +5 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.js +23 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts +4 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.js +69 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.js.map +1 -0
- package/dist/commands/CommandConfig/types.d.ts +6 -0
- package/dist/commands/CommandConfig/types.d.ts.map +1 -0
- package/dist/commands/CommandConfig/types.js +2 -0
- package/dist/commands/CommandConfig/types.js.map +1 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts +3 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js +8 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js.map +1 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.d.ts +8 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.js +33 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.js.map +1 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.d.ts +3 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.js +14 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.js.map +1 -0
- package/dist/commands/CommandDaemon/CommandDaemon.d.ts +4 -0
- package/dist/commands/CommandDaemon/CommandDaemon.d.ts.map +1 -0
- package/dist/commands/CommandDaemon/CommandDaemon.js +57 -0
- package/dist/commands/CommandDaemon/CommandDaemon.js.map +1 -0
- package/dist/commands/CommandDashboard/CommandDashboard.d.ts +4 -0
- package/dist/commands/CommandDashboard/CommandDashboard.d.ts.map +1 -0
- package/dist/commands/CommandDashboard/CommandDashboard.js +54 -0
- package/dist/commands/CommandDashboard/CommandDashboard.js.map +1 -0
- package/dist/commands/CommandHTTP/CommandHttp.d.ts +4 -0
- package/dist/commands/CommandHTTP/CommandHttp.d.ts.map +1 -0
- package/dist/commands/CommandHTTP/CommandHttp.js +50 -0
- package/dist/commands/CommandHTTP/CommandHttp.js.map +1 -0
- package/dist/commands/CommandInit/CommandInit.d.ts +4 -0
- package/dist/commands/CommandInit/CommandInit.d.ts.map +1 -0
- package/dist/commands/CommandInit/CommandInit.js +36 -0
- package/dist/commands/CommandInit/CommandInit.js.map +1 -0
- package/dist/commands/CommandList/CommandList.d.ts +4 -0
- package/dist/commands/CommandList/CommandList.d.ts.map +1 -0
- package/dist/commands/CommandList/CommandList.js +54 -0
- package/dist/commands/CommandList/CommandList.js.map +1 -0
- package/dist/commands/CommandLogs/CommandLogs.d.ts +4 -0
- package/dist/commands/CommandLogs/CommandLogs.d.ts.map +1 -0
- package/dist/commands/CommandLogs/CommandLogs.js +33 -0
- package/dist/commands/CommandLogs/CommandLogs.js.map +1 -0
- package/dist/commands/CommandProfile/CommandProfile.d.ts +5 -0
- package/dist/commands/CommandProfile/CommandProfile.d.ts.map +1 -0
- package/dist/commands/CommandProfile/CommandProfile.js +64 -0
- package/dist/commands/CommandProfile/CommandProfile.js.map +1 -0
- package/dist/commands/CommandRegister/CommandRegister.d.ts +4 -0
- package/dist/commands/CommandRegister/CommandRegister.d.ts.map +1 -0
- package/dist/commands/CommandRegister/CommandRegister.js +43 -0
- package/dist/commands/CommandRegister/CommandRegister.js.map +1 -0
- package/dist/commands/CommandRestart/CommandRestart.d.ts +4 -0
- package/dist/commands/CommandRestart/CommandRestart.d.ts.map +1 -0
- package/dist/commands/CommandRestart/CommandRestart.js +62 -0
- package/dist/commands/CommandRestart/CommandRestart.js.map +1 -0
- package/dist/commands/CommandServer/CommandServer.d.ts +4 -0
- package/dist/commands/CommandServer/CommandServer.d.ts.map +1 -0
- package/dist/commands/CommandServer/CommandServer.js +24 -0
- package/dist/commands/CommandServer/CommandServer.js.map +1 -0
- package/dist/commands/CommandStop/CommandStop.d.ts +4 -0
- package/dist/commands/CommandStop/CommandStop.d.ts.map +1 -0
- package/dist/commands/CommandStop/CommandStop.js +25 -0
- package/dist/commands/CommandStop/CommandStop.js.map +1 -0
- package/dist/commands/CommandUpdate/CommandUpdate.d.ts +4 -0
- package/dist/commands/CommandUpdate/CommandUpdate.d.ts.map +1 -0
- package/dist/commands/CommandUpdate/CommandUpdate.js +38 -0
- package/dist/commands/CommandUpdate/CommandUpdate.js.map +1 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts +4 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts.map +1 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.js +63 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.js.map +1 -0
- package/dist/commands/helper/Help.d.ts +4 -0
- package/dist/commands/helper/Help.d.ts.map +1 -0
- package/dist/commands/helper/Help.js +134 -0
- package/dist/commands/helper/Help.js.map +1 -0
- package/dist/commands/helper/Parser.d.ts +55 -0
- package/dist/commands/helper/Parser.d.ts.map +1 -0
- package/dist/commands/helper/Parser.js +280 -0
- package/dist/commands/helper/Parser.js.map +1 -0
- package/dist/commands/shared/allowDenyCidrCommand.d.ts +3 -0
- package/dist/commands/shared/allowDenyCidrCommand.d.ts.map +1 -0
- package/dist/commands/shared/allowDenyCidrCommand.js +10 -0
- package/dist/commands/shared/allowDenyCidrCommand.js.map +1 -0
- package/dist/commands/shared/configServersCommand.d.ts +4 -0
- package/dist/commands/shared/configServersCommand.d.ts.map +1 -0
- package/dist/commands/shared/configServersCommand.js +19 -0
- package/dist/commands/shared/configServersCommand.js.map +1 -0
- package/dist/commands/utils.d.ts +3 -0
- package/dist/commands/utils.d.ts.map +1 -0
- package/dist/commands/utils.js +17 -0
- package/dist/commands/utils.js.map +1 -0
- package/dist/config/ParsedConfig.d.ts +31 -0
- package/dist/config/ParsedConfig.d.ts.map +1 -0
- package/dist/config/ParsedConfig.js +116 -0
- package/dist/config/ParsedConfig.js.map +1 -0
- package/dist/config/ParsedGlobalConfig.d.ts +5 -0
- package/dist/config/ParsedGlobalConfig.d.ts.map +1 -0
- package/dist/config/ParsedGlobalConfig.js +7 -0
- package/dist/config/ParsedGlobalConfig.js.map +1 -0
- package/dist/config/ParsedLocalConfig.d.ts +5 -0
- package/dist/config/ParsedLocalConfig.d.ts.map +1 -0
- package/dist/config/ParsedLocalConfig.js +7 -0
- package/dist/config/ParsedLocalConfig.js.map +1 -0
- package/dist/config/ParsedProfileConfig.d.ts +46 -0
- package/dist/config/ParsedProfileConfig.d.ts.map +1 -0
- package/dist/config/ParsedProfileConfig.js +120 -0
- package/dist/config/ParsedProfileConfig.js.map +1 -0
- package/dist/config/ParsedServerConfig.d.ts +20 -0
- package/dist/config/ParsedServerConfig.d.ts.map +1 -0
- package/dist/config/ParsedServerConfig.js +55 -0
- package/dist/config/ParsedServerConfig.js.map +1 -0
- package/dist/config/TempProfileConfig.d.ts +8 -0
- package/dist/config/TempProfileConfig.d.ts.map +1 -0
- package/dist/config/TempProfileConfig.js +13 -0
- package/dist/config/TempProfileConfig.js.map +1 -0
- package/dist/config/utils.d.ts +2 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +8 -0
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validations/validateProfileConfig.d.ts +4 -0
- package/dist/config/validations/validateProfileConfig.d.ts.map +1 -0
- package/dist/config/validations/validateProfileConfig.js +76 -0
- package/dist/config/validations/validateProfileConfig.js.map +1 -0
- package/dist/core/FS/utils.d.ts +12 -0
- package/dist/core/FS/utils.d.ts.map +1 -0
- package/dist/core/FS/utils.js +55 -0
- package/dist/core/FS/utils.js.map +1 -0
- package/dist/daemon/DaemonClient.d.ts +16 -0
- package/dist/daemon/DaemonClient.d.ts.map +1 -0
- package/dist/daemon/DaemonClient.js +158 -0
- package/dist/daemon/DaemonClient.js.map +1 -0
- package/dist/daemon/DaemonServer.d.ts +8 -0
- package/dist/daemon/DaemonServer.d.ts.map +1 -0
- package/dist/daemon/DaemonServer.js +201 -0
- package/dist/daemon/DaemonServer.js.map +1 -0
- package/dist/daemon/protocol.d.ts +101 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +2 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon-main.d.ts +2 -0
- package/dist/daemon-main.d.ts.map +1 -0
- package/dist/daemon-main.js +13 -0
- package/dist/daemon-main.js.map +1 -0
- package/dist/launcher-main.d.ts +2 -0
- package/dist/launcher-main.d.ts.map +1 -0
- package/dist/launcher-main.js +57 -0
- package/dist/launcher-main.js.map +1 -0
- package/dist/lib/Flow/applyUpdate.d.ts +3 -0
- package/dist/lib/Flow/applyUpdate.d.ts.map +1 -0
- package/dist/lib/Flow/applyUpdate.js +34 -0
- package/dist/lib/Flow/applyUpdate.js.map +1 -0
- package/dist/lib/Flow/downloadBinaryUpdate.d.ts +3 -0
- package/dist/lib/Flow/downloadBinaryUpdate.d.ts.map +1 -0
- package/dist/lib/Flow/downloadBinaryUpdate.js +54 -0
- package/dist/lib/Flow/downloadBinaryUpdate.js.map +1 -0
- package/dist/lib/Flow/getLatestVersion.d.ts +2 -0
- package/dist/lib/Flow/getLatestVersion.d.ts.map +1 -0
- package/dist/lib/Flow/getLatestVersion.js +13 -0
- package/dist/lib/Flow/getLatestVersion.js.map +1 -0
- package/dist/lib/defs.d.ts +18 -0
- package/dist/lib/defs.d.ts.map +1 -0
- package/dist/lib/defs.js +33 -0
- package/dist/lib/defs.js.map +1 -0
- package/dist/logger/logger.d.ts +6 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +34 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/output-formats/colors.d.ts +7 -0
- package/dist/output-formats/colors.d.ts.map +1 -0
- package/dist/output-formats/colors.js +8 -0
- package/dist/output-formats/colors.js.map +1 -0
- package/dist/output-formats/formatConfig.d.ts +3 -0
- package/dist/output-formats/formatConfig.d.ts.map +1 -0
- package/dist/output-formats/formatConfig.js +59 -0
- package/dist/output-formats/formatConfig.js.map +1 -0
- package/dist/output-formats/formatConfigPath.d.ts +4 -0
- package/dist/output-formats/formatConfigPath.d.ts.map +1 -0
- package/dist/output-formats/formatConfigPath.js +7 -0
- package/dist/output-formats/formatConfigPath.js.map +1 -0
- package/dist/output-formats/formatPath.d.ts +2 -0
- package/dist/output-formats/formatPath.d.ts.map +1 -0
- package/dist/output-formats/formatPath.js +6 -0
- package/dist/output-formats/formatPath.js.map +1 -0
- package/dist/output-formats/formatProfile.d.ts +3 -0
- package/dist/output-formats/formatProfile.d.ts.map +1 -0
- package/dist/output-formats/formatProfile.js +35 -0
- package/dist/output-formats/formatProfile.js.map +1 -0
- package/dist/output-formats/formatProfilesShort.d.ts +3 -0
- package/dist/output-formats/formatProfilesShort.d.ts.map +1 -0
- package/dist/output-formats/formatProfilesShort.js +19 -0
- package/dist/output-formats/formatProfilesShort.js.map +1 -0
- package/dist/output-formats/formatSaveResult.d.ts +4 -0
- package/dist/output-formats/formatSaveResult.d.ts.map +1 -0
- package/dist/output-formats/formatSaveResult.js +7 -0
- package/dist/output-formats/formatSaveResult.js.map +1 -0
- package/dist/output-formats/table.d.ts +8 -0
- package/dist/output-formats/table.d.ts.map +1 -0
- package/dist/output-formats/table.js +15 -0
- package/dist/output-formats/table.js.map +1 -0
- package/dist/package-json/packageJson.d.ts +6 -0
- package/dist/package-json/packageJson.d.ts.map +1 -0
- package/dist/package-json/packageJson.js +12 -0
- package/dist/package-json/packageJson.js.map +1 -0
- package/dist/proxy/Proxy.d.ts +6 -0
- package/dist/proxy/Proxy.d.ts.map +1 -0
- package/dist/proxy/Proxy.js +203 -0
- package/dist/proxy/Proxy.js.map +1 -0
- package/dist/sea-main.d.ts +2 -0
- package/dist/sea-main.d.ts.map +1 -0
- package/dist/sea-main.js +20 -0
- package/dist/sea-main.js.map +1 -0
- package/dist/types/types.d.ts +55 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/arrayFunctions.d.ts +24 -0
- package/dist/utils/arrayFunctions.d.ts.map +1 -0
- package/dist/utils/arrayFunctions.js +43 -0
- package/dist/utils/arrayFunctions.js.map +1 -0
- package/dist/utils/assertFunctions.d.ts +7 -0
- package/dist/utils/assertFunctions.d.ts.map +1 -0
- package/dist/utils/assertFunctions.js +20 -0
- package/dist/utils/assertFunctions.js.map +1 -0
- package/dist/utils/checkFunctions.d.ts +34 -0
- package/dist/utils/checkFunctions.d.ts.map +1 -0
- package/dist/utils/checkFunctions.js +87 -0
- package/dist/utils/checkFunctions.js.map +1 -0
- package/dist/utils/cliFunctions.d.ts +10 -0
- package/dist/utils/cliFunctions.d.ts.map +1 -0
- package/dist/utils/cliFunctions.js +68 -0
- package/dist/utils/cliFunctions.js.map +1 -0
- package/dist/utils/hashFunctions.d.ts +10 -0
- package/dist/utils/hashFunctions.d.ts.map +1 -0
- package/dist/utils/hashFunctions.js +11 -0
- package/dist/utils/hashFunctions.js.map +1 -0
- package/dist/utils/npmFunctions.d.ts +3 -0
- package/dist/utils/npmFunctions.d.ts.map +1 -0
- package/dist/utils/npmFunctions.js +28 -0
- package/dist/utils/npmFunctions.js.map +1 -0
- package/dist/utils/stringFunctions.d.ts +12 -0
- package/dist/utils/stringFunctions.d.ts.map +1 -0
- package/dist/utils/stringFunctions.js +37 -0
- package/dist/utils/stringFunctions.js.map +1 -0
- package/package.json +39 -16
- package/client.js +0 -33
- package/src/cli-app/Dashboard.js +0 -220
- package/src/cli-app/Screen/FullScreenModal.js +0 -63
- package/src/cli-app/Screen.js +0 -140
- package/src/cli-app/elements/ElementNode.js +0 -97
- package/src/cli-app/elements/Line.js +0 -21
- package/src/cli-app/elements/List/List.js +0 -227
- package/src/cli-app/elements/List/ListCell.js +0 -83
- package/src/cli-app/elements/List/ListColumn.js +0 -52
- package/src/cli-app/elements/List/ListRow.js +0 -118
- package/src/cli-app/elements/Row.js +0 -38
- package/src/cli-app/helper/utils.js +0 -42
- package/src/commands/Action/addDelValuesAction.js +0 -56
- package/src/commands/CommandAuth.js +0 -32
- package/src/commands/CommandClearAll.js +0 -27
- package/src/commands/CommandConfig.js +0 -59
- package/src/commands/CommandHTTP.js +0 -192
- package/src/commands/CommandInvite.js +0 -38
- package/src/commands/CommandRefresh.js +0 -35
- package/src/commands/CommandRegister.js +0 -48
- package/src/commands/Option/DeleteOption.js +0 -6
- package/src/commands/Option/ProfileListOption.js +0 -65
- package/src/commands/Option/SelectConfigOption.js +0 -52
- package/src/commands/SubCommand/AllowDenyCidrCommand.js +0 -28
- package/src/commands/SubCommand/HostCommand.js +0 -22
- package/src/commands/SubCommand/PortCommand.js +0 -20
- package/src/commands/SubCommand/ProtocolCommand.js +0 -21
- package/src/commands/helper/AliasResolver.js +0 -13
- package/src/commands/helper/BindArgs.js +0 -53
- package/src/commands/helper/SharedArg.js +0 -32
- package/src/commands/utils.js +0 -96
- package/src/config/ConfigAbstract.js +0 -353
- package/src/config/ConfigManager.js +0 -70
- package/src/config/GlobalConfig.js +0 -14
- package/src/config/GlobalLocalShardConfigAbstract.js +0 -98
- package/src/config/LocalConfig.js +0 -7
- package/src/config/PropertyConfig.js +0 -122
- package/src/config/SystemConfig.js +0 -31
- package/src/core/FS/utils.js +0 -60
- package/src/core/Ref.js +0 -70
- package/src/lib/Flow/getCurrentIp.js +0 -18
- package/src/lib/Flow/getLatestVersion.js +0 -13
- package/src/lib/Flow/proxyUrl.js +0 -35
- package/src/lib/Flow/validateAuthToken.js +0 -19
- package/src/lib/HttpClient.js +0 -61
- package/src/lib/Proxy.js +0 -42
- package/src/lib/defs.js +0 -13
- package/src/net/IPV4.js +0 -139
- package/src/net/http/IncomingMessage.js +0 -92
- package/src/net/http/ServerResponse.js +0 -126
- package/src/net/http/TunliRequest.js +0 -1
- package/src/net/http/TunliResponse.js +0 -1
- package/src/net/http/TunnelRequest.js +0 -229
- package/src/net/http/TunnelResponse.js +0 -119
- package/src/tunnel-client/TunnelClient.js +0 -144
- package/src/utils/arrayFunctions.js +0 -45
- package/src/utils/checkFunctions.js +0 -182
- package/src/utils/cliFunctions.js +0 -63
- package/src/utils/createRequest.js +0 -12
- package/src/utils/hashFunctions.js +0 -9
- package/src/utils/httpFunction.js +0 -23
- package/src/utils/npmFunctions.js +0 -27
- package/src/utils/stringFunctions.js +0 -59
- package/types/index.d.ts +0 -119
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {ref} from "#src/core/Ref";
|
|
3
|
-
import {allowDenyCidrCommand} from "#commands/SubCommand/AllowDenyCidrCommand";
|
|
4
|
-
import {portCommand} from "#commands/SubCommand/PortCommand";
|
|
5
|
-
import {hostCommand} from "#commands/SubCommand/HostCommand";
|
|
6
|
-
import {selectConfigOption} from "#commands/Option/SelectConfigOption";
|
|
7
|
-
import {addExample, extendUsage} from "#commands/utils";
|
|
8
|
-
import {protocolCommand} from "#commands/SubCommand/ProtocolCommand";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {Ref} configRef
|
|
13
|
-
* @param {Command} program
|
|
14
|
-
* @returns {(function(*, *, *): void)|*}
|
|
15
|
-
*/
|
|
16
|
-
const exec = (configRef, program) => {
|
|
17
|
-
|
|
18
|
-
return async (key, value, options) => {
|
|
19
|
-
|
|
20
|
-
/** @type {LocalConfig|GlobalConfig} */
|
|
21
|
-
const config = configRef.value
|
|
22
|
-
|
|
23
|
-
const maxKeyLength = Math.max(...Object.keys(config.dump()).map(x => x.length))
|
|
24
|
-
console.log('location: ', config.configPath, "\n")
|
|
25
|
-
for (const [k, v] of Object.entries(config.dump())) {
|
|
26
|
-
console.log(k.padEnd(maxKeyLength, ' '), '=', v)
|
|
27
|
-
console.log(''.padEnd(maxKeyLength + 3 + (v?.length ?? 9), '-'))
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {Command} program
|
|
34
|
-
*/
|
|
35
|
-
export const createCommandConfig = (program) => {
|
|
36
|
-
|
|
37
|
-
const configRef = ref()
|
|
38
|
-
|
|
39
|
-
const cmd = new Command('config')
|
|
40
|
-
|
|
41
|
-
cmd.addCommand(allowDenyCidrCommand('allowCidr', cmd, configRef))
|
|
42
|
-
cmd.addCommand(allowDenyCidrCommand('denyCidr', cmd, configRef))
|
|
43
|
-
cmd.addCommand(portCommand(configRef))
|
|
44
|
-
cmd.addCommand(hostCommand(configRef))
|
|
45
|
-
cmd.addCommand(protocolCommand(configRef))
|
|
46
|
-
|
|
47
|
-
selectConfigOption(cmd, configRef, true)
|
|
48
|
-
.action(exec(configRef, program));
|
|
49
|
-
|
|
50
|
-
extendUsage(program, cmd)
|
|
51
|
-
//
|
|
52
|
-
addExample('config host localhost', 'Set the host for the local configuration')
|
|
53
|
-
addExample('config port 80', 'Set the port for the local configuration')
|
|
54
|
-
addExample('config', 'Show the local configuration')
|
|
55
|
-
addExample('config --global', 'Show the global configuration')
|
|
56
|
-
|
|
57
|
-
return cmd
|
|
58
|
-
}
|
|
59
|
-
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {checkHost, checkPort} from "#src/utils/checkFunctions";
|
|
3
|
-
import {isSharedArg, sharedArg} from "#commands/helper/SharedArg";
|
|
4
|
-
import {addExample, validateArrayArguments, validateIpV4} from "#commands/utils";
|
|
5
|
-
import {bindArgs} from "#commands/helper/BindArgs";
|
|
6
|
-
import {ref} from "#src/core/Ref";
|
|
7
|
-
import {selectConfigOption} from "#commands/Option/SelectConfigOption";
|
|
8
|
-
import {TunnelClient} from "#src/tunnel-client/TunnelClient";
|
|
9
|
-
import {renewProxyUrlRegistration, requestNewProxyUrl} from "#lib/Flow/proxyUrl";
|
|
10
|
-
import {getCurrentIp} from "#lib/Flow/getCurrentIp";
|
|
11
|
-
import {arrayUnique} from "#src/utils/arrayFunctions";
|
|
12
|
-
import {initDashboard} from "#src/cli-app/Dashboard";
|
|
13
|
-
import {md5} from "#src/utils/hashFunctions";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {AppConfig} config
|
|
19
|
-
* @param {tunnelClientOptions} options
|
|
20
|
-
*/
|
|
21
|
-
const computeProxyURL = async (config, options) => {
|
|
22
|
-
|
|
23
|
-
// console.log(new URL(`${options.protocol}://${options.host ?? config.host}:${options.port ?? config.port}`).toString())
|
|
24
|
-
|
|
25
|
-
const targetUrlHash = md5(new URL(`${options.protocol}://${options.host ?? config.host}:${options.port ?? config.port}`))
|
|
26
|
-
|
|
27
|
-
if (config.profile === 'default') {
|
|
28
|
-
let proxyUrl = config.proxyURLs[targetUrlHash]
|
|
29
|
-
|
|
30
|
-
if (proxyUrl) {
|
|
31
|
-
proxyUrl = await renewProxyUrlRegistration(proxyUrl, config.authToken)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!proxyUrl) {
|
|
35
|
-
proxyUrl = await requestNewProxyUrl(config.authToken)
|
|
36
|
-
config.proxyURLs[targetUrlHash] = proxyUrl
|
|
37
|
-
config.update({proxyURLs: config.proxyURLs})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
config.proxyURL = proxyUrl
|
|
41
|
-
|
|
42
|
-
console.log(config.proxyURL)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (config.proxyURL) {
|
|
47
|
-
config.proxyURL = await renewProxyUrlRegistration(config.proxyURL, config.authToken)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!config.proxyURL) {
|
|
51
|
-
config.proxyURL = await requestNewProxyUrl(config.authToken)
|
|
52
|
-
config.update({proxyURL: config.proxyURL})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @callback httpCommandExec
|
|
58
|
-
* @param {number} port
|
|
59
|
-
* @param {string} host
|
|
60
|
-
* @param {tunnelClientOptions} options
|
|
61
|
-
* @returns {Promise<void>}
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Ref} configRef
|
|
66
|
-
* @returns {httpCommandExec}
|
|
67
|
-
*/
|
|
68
|
-
const exec = (configRef, cmd, program) => {
|
|
69
|
-
|
|
70
|
-
return async (port, host, options) => {
|
|
71
|
-
|
|
72
|
-
let protocol
|
|
73
|
-
|
|
74
|
-
if (['http', 'https'].includes(cmd.parent.args[0])) {
|
|
75
|
-
protocol = cmd.parent.args[0]
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** @type {AppConfig} */
|
|
79
|
-
const config = configRef.value
|
|
80
|
-
|
|
81
|
-
if (options.self) {
|
|
82
|
-
options.allowCidr ??= []
|
|
83
|
-
options.allowCidr.push(await getCurrentIp())
|
|
84
|
-
options.allowCidr = arrayUnique(options.allowCidr)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!config.authToken) {
|
|
88
|
-
console.error("error: Missing authToken. Please run register firstly")
|
|
89
|
-
process.exit()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (isSharedArg(port)) {
|
|
93
|
-
protocol ??= port.value.url?.protocol
|
|
94
|
-
host ??= port.value.host ?? port.value.url?.host
|
|
95
|
-
port = port.value.port ?? port.value.url?.port
|
|
96
|
-
options.port ??= port
|
|
97
|
-
options.host ??= host
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
options.port ??= port
|
|
101
|
-
options.host ??= host
|
|
102
|
-
options.protocol ??= protocol ?? 'http'
|
|
103
|
-
|
|
104
|
-
await computeProxyURL(config, options)
|
|
105
|
-
|
|
106
|
-
const save = options.save
|
|
107
|
-
delete options.save
|
|
108
|
-
|
|
109
|
-
if (save && save !== true) {
|
|
110
|
-
config.copyCurrentProfileTo(save).use(save)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
for (const [k, v] of Object.entries(options)) {
|
|
114
|
-
if (v !== undefined) {
|
|
115
|
-
config[k] = v
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (save) {
|
|
120
|
-
config.save()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @type {tunnelClientOptions}
|
|
125
|
-
*/
|
|
126
|
-
const clientOptions = {
|
|
127
|
-
port: options.port ?? config.port,
|
|
128
|
-
host: options.host ?? config.host,
|
|
129
|
-
authToken: config.authToken,
|
|
130
|
-
server: config.proxyURL,
|
|
131
|
-
path: undefined,
|
|
132
|
-
allowCidr: options.allowCidr ?? config.allowCidr,
|
|
133
|
-
denyCidr: options.denyCidr ?? config.denyCidr,
|
|
134
|
-
protocol: options.protocol
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const useDashboard = process.env.TUNLI_DASHBOARD !== 'off'
|
|
138
|
-
|
|
139
|
-
const client = new TunnelClient(clientOptions)
|
|
140
|
-
|
|
141
|
-
client.once('tunnel-connection-error', async (error) => {
|
|
142
|
-
error.stopPropagation = true
|
|
143
|
-
if (error.data?.connection_exists) {
|
|
144
|
-
clientOptions.server = await requestNewProxyUrl(config.authToken)
|
|
145
|
-
|
|
146
|
-
if (useDashboard) {
|
|
147
|
-
dashboard.forwardingUrl = clientOptions.server
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
await client.init()
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
const dashboard = useDashboard ? initDashboard(client, clientOptions, config) : null
|
|
155
|
-
await client.init(dashboard)
|
|
156
|
-
|
|
157
|
-
if (!useDashboard) {
|
|
158
|
-
console.log(clientOptions)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* @param {Command} program
|
|
164
|
-
*/
|
|
165
|
-
export const createCommandHTTP = (program) => {
|
|
166
|
-
|
|
167
|
-
const configRef = ref()
|
|
168
|
-
const cmd = new Command('http')
|
|
169
|
-
cmd.alias('https')
|
|
170
|
-
|
|
171
|
-
selectConfigOption(cmd, configRef)
|
|
172
|
-
// validateAuthToken(cmd, configRef)
|
|
173
|
-
|
|
174
|
-
const sharedArgument = sharedArg({})
|
|
175
|
-
cmd.argument('[PORT]', 'port welcher durch den proxy erreichbar sein soll (default: "80")', bindArgs(checkPort, sharedArgument, true))
|
|
176
|
-
cmd.argument('[HOST]', 'host welcher durch den proxy erreichbar sein soll (default: "localhost"/"config.value")', bindArgs(checkHost, sharedArgument, true))
|
|
177
|
-
|
|
178
|
-
cmd.option('--host <string>', 'setting hostname', bindArgs(checkHost, sharedArgument, false))
|
|
179
|
-
cmd.option('--port <string>', 'setting port', bindArgs(checkPort, sharedArgument, false))
|
|
180
|
-
cmd.option('--allow, --allow-cidr <string>', 'allow-cidr', validateArrayArguments(validateIpV4))
|
|
181
|
-
cmd.option('--deny, --deny-cidr <string>', 'deny-cidr', validateArrayArguments(validateIpV4))
|
|
182
|
-
cmd.option('--allow-self, --self', 'allow self only', false)
|
|
183
|
-
cmd.option('--save [alias]', 'save current settings as alias/local')
|
|
184
|
-
cmd.action(exec(configRef, cmd, program))
|
|
185
|
-
|
|
186
|
-
addExample('http localhost:80', 'HTTP Forward to localhost:80')
|
|
187
|
-
addExample('', 'Forward to port from default config, host from default config')
|
|
188
|
-
// extendUsage(program, cmd)
|
|
189
|
-
// .option('-o, --origin <string>', 'change request origin')
|
|
190
|
-
|
|
191
|
-
return cmd
|
|
192
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {httpClient, securedHttpClient} from "#lib/HttpClient";
|
|
3
|
-
import {addExample, extendUsage} from "#commands/utils";
|
|
4
|
-
import {ConfigManager} from "#src/config/ConfigManager";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @returns {(function(): void)|*}
|
|
9
|
-
*/
|
|
10
|
-
const exec = () => {
|
|
11
|
-
|
|
12
|
-
return async () => {
|
|
13
|
-
const config = ConfigManager.loadSystem()
|
|
14
|
-
const {data, error} = await securedHttpClient(config.authToken).get('/invite')
|
|
15
|
-
|
|
16
|
-
if (error) {
|
|
17
|
-
console.error(error)
|
|
18
|
-
process.exit(1)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.log('Done.', data)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {Command} program
|
|
28
|
-
*/
|
|
29
|
-
export const createCommandInvite = (program) => {
|
|
30
|
-
|
|
31
|
-
const cmd = new Command('invite')
|
|
32
|
-
.action(exec())
|
|
33
|
-
|
|
34
|
-
extendUsage(program, cmd)
|
|
35
|
-
addExample('invite', 'create sharable registration token')
|
|
36
|
-
return cmd
|
|
37
|
-
|
|
38
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {selectConfigOption} from "#commands/Option/SelectConfigOption";
|
|
3
|
-
import {ref} from "#src/core/Ref";
|
|
4
|
-
import {validateAuthToken} from "#lib/Flow/validateAuthToken";
|
|
5
|
-
import {requestNewProxyUrl} from "#lib/Flow/proxyUrl";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {Ref} configRef
|
|
9
|
-
* @returns {(function(*, *): void)|*}
|
|
10
|
-
*/
|
|
11
|
-
const exec = (configRef) => {
|
|
12
|
-
return async () => {
|
|
13
|
-
/** @type {LocalConfig|GlobalConfig} */
|
|
14
|
-
const config = configRef.value
|
|
15
|
-
config.proxyURL = await requestNewProxyUrl(config.authToken)
|
|
16
|
-
config.save()
|
|
17
|
-
console.log('done')
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @param {Command} program
|
|
22
|
-
*/
|
|
23
|
-
export const createCommandRefresh = (program) => {
|
|
24
|
-
|
|
25
|
-
const configRef = ref()
|
|
26
|
-
const cmd = new Command('refresh')
|
|
27
|
-
|
|
28
|
-
selectConfigOption(cmd, configRef)
|
|
29
|
-
validateAuthToken(cmd, configRef)
|
|
30
|
-
|
|
31
|
-
cmd.action(exec(configRef))
|
|
32
|
-
// extendUsage(program, cmd)
|
|
33
|
-
|
|
34
|
-
return cmd
|
|
35
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {httpClient} from "#lib/HttpClient";
|
|
3
|
-
import {ConfigManager} from "#src/config/ConfigManager";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @returns {(function(): void)|*}
|
|
8
|
-
*/
|
|
9
|
-
const exec = () => {
|
|
10
|
-
|
|
11
|
-
return async (options) => {
|
|
12
|
-
|
|
13
|
-
const forceRenew = options.f === true
|
|
14
|
-
const config = ConfigManager.loadSystem()
|
|
15
|
-
|
|
16
|
-
if (config.authToken && !forceRenew) {
|
|
17
|
-
console.log(`Auth token exists. use -f to renew: ${config.authToken}`)
|
|
18
|
-
process.exit()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const {data, error} = await httpClient.get('/register')
|
|
22
|
-
|
|
23
|
-
if (error) {
|
|
24
|
-
console.error(error)
|
|
25
|
-
process.exit(1)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
config.authToken = data
|
|
29
|
-
config.save()
|
|
30
|
-
console.log('Done.',config.authToken)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param {Command} program
|
|
38
|
-
*/
|
|
39
|
-
export const createCommandRegister = (program) => {
|
|
40
|
-
|
|
41
|
-
const cmd = new Command('register')
|
|
42
|
-
.option('-f', 'fore renew auth token')
|
|
43
|
-
.action(exec())
|
|
44
|
-
|
|
45
|
-
return cmd
|
|
46
|
-
// extendUsage(program, cmd)
|
|
47
|
-
// addExample('register', 'register call')
|
|
48
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {Option} from "commander";
|
|
2
|
-
import {ConfigManager} from "#src/config/ConfigManager";
|
|
3
|
-
|
|
4
|
-
export const profileListOption = () => {
|
|
5
|
-
const option = new Option('-l, --list', 'profile list')
|
|
6
|
-
option.argParser(() => {
|
|
7
|
-
/**
|
|
8
|
-
* @param label
|
|
9
|
-
* @param {ConfigAbstract} config
|
|
10
|
-
* @return {string}
|
|
11
|
-
*/
|
|
12
|
-
const createOutput = (label, config) => {
|
|
13
|
-
const profiles = [...config.profiles]
|
|
14
|
-
const maxLabelLength = Math.max(...profiles.map(x => x.length))
|
|
15
|
-
const whitespace = ''.padEnd(2)
|
|
16
|
-
const rows = [`${label}`, '']
|
|
17
|
-
// const rows = [`${label}${profiles.shift()}`]
|
|
18
|
-
const overview = {}
|
|
19
|
-
const proxyURLs = []
|
|
20
|
-
for (const profile of profiles) {
|
|
21
|
-
|
|
22
|
-
const info = config.use(profile)
|
|
23
|
-
const host = info.host
|
|
24
|
-
const port = info.port
|
|
25
|
-
const protocol = info.protocol
|
|
26
|
-
let proxyURL = info.proxyURL
|
|
27
|
-
|
|
28
|
-
let targetUrl = new URL(`${protocol}://${host}:${port}`).toString()
|
|
29
|
-
if (proxyURL) {
|
|
30
|
-
proxyURL = proxyURL.substring(0, proxyURL.length - 1)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
targetUrl = targetUrl.substring(0, targetUrl.length - 1)
|
|
34
|
-
proxyURLs.push(proxyURL.length)
|
|
35
|
-
overview[profile] = {
|
|
36
|
-
host,
|
|
37
|
-
port,
|
|
38
|
-
targetUrl,
|
|
39
|
-
proxyURL
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const maxProxyUrlLength = Math.max(...proxyURLs)
|
|
44
|
-
|
|
45
|
-
for (const profile of profiles) {
|
|
46
|
-
let {targetUrl, proxyURL} = overview[profile]
|
|
47
|
-
proxyURL = proxyURL.padEnd(maxProxyUrlLength)
|
|
48
|
-
rows.push(`${whitespace}${profile.padEnd(maxLabelLength)} ${proxyURL} -> ${targetUrl}`)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return rows.join("\n") + "\n"
|
|
52
|
-
}
|
|
53
|
-
const localConf = ConfigManager.loadLocalOnly()
|
|
54
|
-
const globalConf = ConfigManager.loadGlobalOnly()
|
|
55
|
-
|
|
56
|
-
if (localConf.exists()) {
|
|
57
|
-
console.log(createOutput('Alias local config: ', localConf))
|
|
58
|
-
}
|
|
59
|
-
if (globalConf.exists()) {
|
|
60
|
-
console.log(createOutput('Alias global config: ', globalConf))
|
|
61
|
-
}
|
|
62
|
-
process.exit()
|
|
63
|
-
})
|
|
64
|
-
return option
|
|
65
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {ConfigManager} from "#src/config/ConfigManager";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @template T
|
|
5
|
-
* @param {T} command
|
|
6
|
-
* @param {Ref} [configRef]
|
|
7
|
-
* @param {boolean} strictMode
|
|
8
|
-
* @returns {T}
|
|
9
|
-
*/
|
|
10
|
-
export const selectConfigOption = (command, configRef, strictMode = false) => {
|
|
11
|
-
|
|
12
|
-
command.option('--global', 'Use the global configuration file (default)')
|
|
13
|
-
.option('--local, --workdir', 'Use the configuration file for the current working directory')
|
|
14
|
-
.option('-p --alias <string>', 'setting alias name', 'default')
|
|
15
|
-
|
|
16
|
-
if (configRef) {
|
|
17
|
-
command.hook('preAction', (thisCommand, actionCommand) => {
|
|
18
|
-
|
|
19
|
-
let {alias, workdir, global} = thisCommand.opts()
|
|
20
|
-
|
|
21
|
-
if (strictMode) {
|
|
22
|
-
if (global) {
|
|
23
|
-
workdir = false
|
|
24
|
-
}
|
|
25
|
-
if (workdir) {
|
|
26
|
-
global = false
|
|
27
|
-
}
|
|
28
|
-
global ??= true
|
|
29
|
-
workdir ??= false
|
|
30
|
-
} else {
|
|
31
|
-
if (workdir) {
|
|
32
|
-
global ??= false
|
|
33
|
-
}
|
|
34
|
-
if (global) {
|
|
35
|
-
workdir ??= false
|
|
36
|
-
}
|
|
37
|
-
global ??= true
|
|
38
|
-
workdir ??= true
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (global && workdir) {
|
|
42
|
-
configRef.value = ConfigManager.loadCombined(alias)
|
|
43
|
-
} else if (global) {
|
|
44
|
-
configRef.value = ConfigManager.loadGlobalOnly(alias)
|
|
45
|
-
} else {
|
|
46
|
-
configRef.value = ConfigManager.loadLocalOnly(alias, !strictMode)
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return command
|
|
52
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {addDelValuesAction} from "#commands/Action/addDelValuesAction";
|
|
3
|
-
import {validateArrayArguments, validateIpV4} from "#commands/utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {string} commandName
|
|
7
|
-
* @param {Command} configCommand
|
|
8
|
-
* @param {Ref} configRef
|
|
9
|
-
* @returns {Command}
|
|
10
|
-
*/
|
|
11
|
-
export const allowDenyCidrCommand = (commandName, configCommand, configRef) => {
|
|
12
|
-
const cmd = new Command(commandName)
|
|
13
|
-
|
|
14
|
-
cmd
|
|
15
|
-
.argument('[values...]', 'config value', validateArrayArguments(validateIpV4))
|
|
16
|
-
.option('-d --del [ip-address]', 'del values', validateArrayArguments(validateIpV4))
|
|
17
|
-
.option('-a --add [ip-address]', 'add values', validateArrayArguments(validateIpV4))
|
|
18
|
-
.action(addDelValuesAction(commandName, configRef))
|
|
19
|
-
.hook('preAction', (thisCommand, actionCommand) => {
|
|
20
|
-
const {del, add} = actionCommand.opts()
|
|
21
|
-
|
|
22
|
-
if (!actionCommand.args.length && !del && !add) {
|
|
23
|
-
// actionCommand.error("error: --add, --del oder values, einer muss mindestens gesetzt sein");
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
return cmd
|
|
28
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
|
|
3
|
-
import {checkHost} from "#src/utils/checkFunctions";
|
|
4
|
-
import {deleteOption} from "#commands/Option/DeleteOption";
|
|
5
|
-
import {addGetDeleteValueAction} from "#commands/Action/addDelValuesAction";
|
|
6
|
-
|
|
7
|
-
export const hostCommand = (configRef) => {
|
|
8
|
-
const cmd = new Command('host')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
cmd.description('default forweard host (127.0.0.1)')
|
|
12
|
-
.argument('[HOST]', 'füge eine kurze beschreibung ein', checkHost)
|
|
13
|
-
.hook('preAction', (thisCommand, actionCommand) => {
|
|
14
|
-
if (thisCommand.args.length && thisCommand.opts().del) {
|
|
15
|
-
actionCommand.error("error: wenn delete dann keine argumente");
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
.addOption(deleteOption())
|
|
19
|
-
.action(addGetDeleteValueAction('host', configRef))
|
|
20
|
-
|
|
21
|
-
return cmd
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
import {checkPort} from "#src/utils/checkFunctions";
|
|
3
|
-
import {addGetDeleteValueAction} from "#commands/Action/addDelValuesAction";
|
|
4
|
-
import {deleteOption} from "#commands/Option/DeleteOption";
|
|
5
|
-
|
|
6
|
-
export const portCommand = (configRef) => {
|
|
7
|
-
const cmd = new Command('port')
|
|
8
|
-
cmd.description('default forweard port (80)')
|
|
9
|
-
.argument('[PORT]', 'set port for config', checkPort)
|
|
10
|
-
.action(addGetDeleteValueAction('port', configRef))
|
|
11
|
-
.addOption(deleteOption())
|
|
12
|
-
|
|
13
|
-
return cmd
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
// if (!config.isPublic(configKey)) {
|
|
18
|
-
// console.error('Ungültiger Konfigurationsdirektive')
|
|
19
|
-
// process.exit()
|
|
20
|
-
// }
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {Command} from "commander";
|
|
2
|
-
|
|
3
|
-
import {checkProtocol} from "#src/utils/checkFunctions";
|
|
4
|
-
import {deleteOption} from "#commands/Option/DeleteOption";
|
|
5
|
-
import {addGetDeleteValueAction} from "#commands/Action/addDelValuesAction";
|
|
6
|
-
|
|
7
|
-
export const protocolCommand = (configRef) => {
|
|
8
|
-
const cmd = new Command('protocol')
|
|
9
|
-
|
|
10
|
-
cmd.description('default protocol "http"')
|
|
11
|
-
.argument('[PROTOCOL]', 'füge eine kurze beschreibung ein', checkProtocol)
|
|
12
|
-
.hook('preAction', (thisCommand, actionCommand) => {
|
|
13
|
-
if (thisCommand.args.length && thisCommand.opts().del) {
|
|
14
|
-
actionCommand.error("error: wenn delete dann keine argumente");
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
.addOption(deleteOption())
|
|
18
|
-
.action(addGetDeleteValueAction('protocol', configRef))
|
|
19
|
-
|
|
20
|
-
return cmd
|
|
21
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const argumentAliasResolver = () => {
|
|
2
|
-
let args = []
|
|
3
|
-
for (let i = 0; i < process.argv.length; i++) {
|
|
4
|
-
const arg = process.argv[i]
|
|
5
|
-
if (arg.charAt(0) === '@') {
|
|
6
|
-
args.push('--alias')
|
|
7
|
-
args.push(arg.substring(1))
|
|
8
|
-
} else {
|
|
9
|
-
args.push(arg)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return args
|
|
13
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {ipV4} from "#src/net/IPV4";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Binds arguments to a function.
|
|
5
|
-
* @param {Function} fn - The function to bind arguments to.
|
|
6
|
-
* @param {...any} args - The arguments to bind.
|
|
7
|
-
* @returns {Function} - The bound function.
|
|
8
|
-
*/
|
|
9
|
-
export const bindArgs = (fn, ...args) => {
|
|
10
|
-
return fn.bind(null, ...args)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Validates a remote address against allowed and denied CIDR ranges.
|
|
15
|
-
* @param {string} remoteAddress - The remote address to check.
|
|
16
|
-
* @param {Object} options - The options containing allowCidr and denyCidr arrays.
|
|
17
|
-
* @param {ipCidr[]} options.allowCidr - Array of CIDR ranges that are allowed.
|
|
18
|
-
* @param {ipCidr[]} options.denyCidr - Array of CIDR ranges that are denied.
|
|
19
|
-
* @returns {boolean} - True if the address is valid, otherwise false.
|
|
20
|
-
*/
|
|
21
|
-
export const isValidRemoteAddress = (() => {
|
|
22
|
-
const cache = {}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Checks if a remote address is within a given subnet.
|
|
26
|
-
* Uses a cache to store results for performance improvement.
|
|
27
|
-
* @param {string} remoteAddress - The remote address to check.
|
|
28
|
-
* @param {string} subnet - The CIDR subnet to check against.
|
|
29
|
-
* @returns {boolean} - True if the remote address is in the subnet, otherwise false.
|
|
30
|
-
*/
|
|
31
|
-
const isInSubnet = (remoteAddress, subnet) => {
|
|
32
|
-
return cache[`${remoteAddress}#${subnet}`] ??= ipV4(remoteAddress).isInSubnet(subnet)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (remoteAddress, {allowCidr, denyCidr}) => {
|
|
36
|
-
// Check against denied CIDR ranges
|
|
37
|
-
for (const deny of denyCidr) {
|
|
38
|
-
if (isInSubnet(remoteAddress, deny)) {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Check against allowed CIDR ranges
|
|
44
|
-
for (const allow of allowCidr) {
|
|
45
|
-
if (isInSubnet(remoteAddress, allow)) {
|
|
46
|
-
return true
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// If there are no allowed CIDR ranges, allow the address
|
|
51
|
-
return allowCidr.length === 0
|
|
52
|
-
}
|
|
53
|
-
})();
|