diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 75a52eb4..c26b7cd2 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -31,7 +31,7 @@ command again. Check whether the SD card is locked (a physical switch on the side of the card). -## I get `connect ETIMEDOUT` with `balena tunnel` +## I get `connect ETIMEDOUT` with `balena device tunnel` Please update the CLI to the latest version. This issue was fixed in v12.38.5. For more details, see: https://github.com/balena-io/balena-cli/issues/2172 diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index 9ce749dd..92f95fb4 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -61,7 +61,6 @@ const commandHeadings: { [key: string]: string } = { organization: 'Organizations', os: 'OS', util: 'Utilities', - tunnel: 'Network', build: 'Deploy', join: 'Platform', leave: 'Platform', diff --git a/completion/_balena b/completion/_balena index 1f7a14dd..2a9af301 100644 --- a/completion/_balena +++ b/completion/_balena @@ -8,13 +8,13 @@ _balena() { local context state line curcontext="$curcontext" # Valid top-level completions - main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh-key support tag tunnel util version whoami ) + main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh-key support tag util version whoami ) # Sub-completions api_key_cmds=( generate list revoke ) app_cmds=( create ) block_cmds=( create ) config_cmds=( generate inject read reconfigure write ) - device_cmds=( deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet ) + device_cmds=( deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel ) devices_cmds=( supported ) env_cmds=( list rename rm set ) fleet_cmds=( create list pin purge rename restart rm track-latest ) diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index 3830c5a7..5efbf741 100644 --- a/completion/balena-completion.bash +++ b/completion/balena-completion.bash @@ -7,13 +7,13 @@ _balena_complete() local cur prev # Valid top-level completions - main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh-key support tag tunnel util version whoami" + main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout notes organization os preload push release settings ssh-key support tag util version whoami" # Sub-completions api_key_cmds="generate list revoke" app_cmds="create" block_cmds="create" config_cmds="generate inject read reconfigure write" - device_cmds="deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet" + device_cmds="deactivate detect identify init list local-mode logs move os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel" devices_cmds="supported" env_cmds="list rename rm set" fleet_cmds="create list pin purge rename restart rm track-latest" diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 9ad242ce..d7b3236b 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -218,6 +218,7 @@ are encouraged to regularly update the balena CLI to the latest version. - [device start-service](#device-start-service) - [device stop-service](#device-stop-service) - [device track-fleet](#device-track-fleet) + - [device tunnel](#device-tunnel) - [devices supported](#devices-supported) - Environment Variables @@ -244,10 +245,6 @@ are encouraged to regularly update the balena CLI to the latest version. - [local configure](#local-configure) - [local flash](#local-flash) -- Network - - - [tunnel](#tunnel) - - Notes - [notes](#notes) @@ -2047,6 +2044,66 @@ the uuid of the device to make track the fleet's release ### Options +## device tunnel + +### Aliases + +- `tunnel` + + +To use one of the aliases, replace `device tunnel` with the alias. + +### Description + +Use this command to open local TCP ports that tunnel to listening sockets in a +balenaOS device. + +For example, this command could be used to expose the ssh server of a balenaOS +device (port number 22222) on the local machine, or to expose a web server +running on the device. The port numbers do not have be the same between the +device and the local machine, and multiple ports may be tunneled in a single +command line. + +Port mappings are specified in the format: [:[localIP:]localPort] +localIP defaults to 'localhost', and localPort defaults to the specified +remotePort value. + +Note: the -p (--port) flag must be provided at the end of the command line, +as per examples. + +In the case of openBalena, the tunnel command in CLI v12.38.5 or later requires +openBalena v3.1.2 or later. Older CLI versions work with older openBalena +versions. + +Examples: + + # map remote port 22222 to localhost:22222 + $ balena device tunnel myFleet -p 22222 + + # map remote port 22222 to localhost:222 + $ balena device tunnel 2ead211 -p 22222:222 + + # map remote port 22222 to any address on your host machine, port 22222 + $ balena device tunnel 1546690 -p 22222:0.0.0.0 + + # map remote port 22222 to any address on your host machine, port 222 + $ balena device tunnel myFleet -p 22222:0.0.0.0:222 + + # multiple port tunnels can be specified at any one time + $ balena device tunnel myFleet -p 8080:3000 -p 8081:9000 + +### Arguments + +#### DEVICEORFLEET + +device UUID or fleet name/slug + +### Options + +#### -p, --port PORT + +port mapping in the format [:[localIP:]localPort] + ## devices supported ### Description @@ -2714,61 +2771,6 @@ Check `balena util available-drives` for available options. answer "yes" to all questions (non interactive use) -# Network - -## tunnel - -### Description - -Use this command to open local TCP ports that tunnel to listening sockets in a -balenaOS device. - -For example, this command could be used to expose the ssh server of a balenaOS -device (port number 22222) on the local machine, or to expose a web server -running on the device. The port numbers do not have be the same between the -device and the local machine, and multiple ports may be tunneled in a single -command line. - -Port mappings are specified in the format: [:[localIP:]localPort] -localIP defaults to 'localhost', and localPort defaults to the specified -remotePort value. - -Note: the -p (--port) flag must be provided at the end of the command line, -as per examples. - -In the case of openBalena, the tunnel command in CLI v12.38.5 or later requires -openBalena v3.1.2 or later. Older CLI versions work with older openBalena -versions. - -Examples: - - # map remote port 22222 to localhost:22222 - $ balena tunnel myFleet -p 22222 - - # map remote port 22222 to localhost:222 - $ balena tunnel 2ead211 -p 22222:222 - - # map remote port 22222 to any address on your host machine, port 22222 - $ balena tunnel 1546690 -p 22222:0.0.0.0 - - # map remote port 22222 to any address on your host machine, port 222 - $ balena tunnel myFleet -p 22222:0.0.0.0:222 - - # multiple port tunnels can be specified at any one time - $ balena tunnel myFleet -p 8080:3000 -p 8081:9000 - -### Arguments - -#### DEVICEORFLEET - -device UUID or fleet name/slug - -### Options - -#### -p, --port PORT - -port mapping in the format [:[localIP:]localPort] - # Notes ## notes diff --git a/src/commands/device/tunnel.ts b/src/commands/device/tunnel.ts index fe8556e8..fc086853 100644 --- a/src/commands/device/tunnel.ts +++ b/src/commands/device/tunnel.ts @@ -27,7 +27,9 @@ import { lowercaseIfSlug } from '../../utils/normalization'; import type { Server, Socket } from 'net'; -export default class TunnelCmd extends Command { +export default class DeviceTunnelCmd extends Command { + public static aliases = ['tunnel']; + public static description = stripIndent` Tunnel local ports to your balenaOS device. @@ -54,19 +56,19 @@ export default class TunnelCmd extends Command { public static examples = [ '# map remote port 22222 to localhost:22222', - '$ balena tunnel myFleet -p 22222', + '$ balena device tunnel myFleet -p 22222', '', '# map remote port 22222 to localhost:222', - '$ balena tunnel 2ead211 -p 22222:222', + '$ balena device tunnel 2ead211 -p 22222:222', '', '# map remote port 22222 to any address on your host machine, port 22222', - '$ balena tunnel 1546690 -p 22222:0.0.0.0', + '$ balena device tunnel 1546690 -p 22222:0.0.0.0', '', '# map remote port 22222 to any address on your host machine, port 222', - '$ balena tunnel myFleet -p 22222:0.0.0.0:222', + '$ balena device tunnel myFleet -p 22222:0.0.0.0:222', '', '# multiple port tunnels can be specified at any one time', - '$ balena tunnel myFleet -p 8080:3000 -p 8081:9000', + '$ balena device tunnel myFleet -p 8080:3000 -p 8081:9000', ]; public static args = { @@ -91,7 +93,7 @@ export default class TunnelCmd extends Command { public static authenticated = true; public async run() { - const { args: params, flags: options } = await this.parse(TunnelCmd); + const { args: params, flags: options } = await this.parse(DeviceTunnelCmd); const Logger = await import('../../utils/logger'); diff --git a/src/help.ts b/src/help.ts index 2e740c08..85e7fd51 100644 --- a/src/help.ts +++ b/src/help.ts @@ -229,7 +229,6 @@ See: https://git.io/JRHUW#deprecation-policy`, 'push', 'fleet', 'device', - 'tunnel', 'preload', 'build', 'deploy', diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index 5fc3b930..916f3a32 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -30,7 +30,6 @@ PRIMARY COMMANDS push start a remote build on the balenaCloud build servers or a local mode device app display information about a single application device show info about a single device - tunnel tunnel local ports to your balenaOS device preload preload an app on a disk image (or Edison zip archive) build build a project locally deploy deploy a single image or a multicontainer project to a balena application @@ -64,6 +63,7 @@ ADDITIONAL COMMANDS device rm remove one or more devices device shutdown shutdown a device device ssh SSH into the host or application container of a device + device tunnel tunnel local ports to your balenaOS device devices supported list the supported device types (like 'raspberrypi3' or 'intel-nuc') env set add or update env or config variable to application(s), device(s) or service(s) env list list the environment or config variables of an application, device or service diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index 7738c6e2..841aaa04 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -133,6 +133,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/track-fleet.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/devices/supported.js @@ -265,9 +268,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tag/set.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/tunnel/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/util/available-drives.js diff --git a/tests/test-data/pkg/expected-warnings-darwin-x64.txt b/tests/test-data/pkg/expected-warnings-darwin-x64.txt index 66a475ad..33a73f3d 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -133,6 +133,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/track-fleet.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/devices/supported.js @@ -265,9 +268,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tag/set.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/tunnel/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/util/available-drives.js diff --git a/tests/test-data/pkg/expected-warnings-linux-arm64.txt b/tests/test-data/pkg/expected-warnings-linux-arm64.txt index 7738c6e2..841aaa04 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -133,6 +133,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/track-fleet.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/devices/supported.js @@ -265,9 +268,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tag/set.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/tunnel/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/util/available-drives.js diff --git a/tests/test-data/pkg/expected-warnings-linux-x64.txt b/tests/test-data/pkg/expected-warnings-linux-x64.txt index 66a475ad..33a73f3d 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -133,6 +133,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/track-fleet.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/devices/supported.js @@ -265,9 +268,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tag/set.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/tunnel/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/util/available-drives.js diff --git a/tests/test-data/pkg/expected-warnings-win32-x64.txt b/tests/test-data/pkg/expected-warnings-win32-x64.txt index e278eabd..3a106749 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -133,6 +133,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\device\track-fleet.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\device\tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\devices\supported.js @@ -265,9 +268,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\tag\set.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\tunnel\index.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\util\available-drives.js