mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 06:57:48 +00:00
Remove unnecessary fetch of device info in balena tunnel
Change-type: patch
This commit is contained in:
parent
f2528dcd18
commit
bd1bf8153d
@ -136,8 +136,7 @@ export default class TunnelCmd extends Command {
|
|||||||
// Ascertain device uuid
|
// Ascertain device uuid
|
||||||
const { getOnlineTargetDeviceUuid } = await import('../utils/patterns');
|
const { getOnlineTargetDeviceUuid } = await import('../utils/patterns');
|
||||||
const uuid = await getOnlineTargetDeviceUuid(sdk, params.deviceOrFleet);
|
const uuid = await getOnlineTargetDeviceUuid(sdk, params.deviceOrFleet);
|
||||||
const device = await sdk.models.device.get(uuid);
|
logger.logInfo(`Opening a tunnel to ${uuid}...`);
|
||||||
logger.logInfo(`Opening a tunnel to ${device.uuid}...`);
|
|
||||||
|
|
||||||
const _ = await import('lodash');
|
const _ = await import('lodash');
|
||||||
const localListeners = _.chain(options.port)
|
const localListeners = _.chain(options.port)
|
||||||
@ -147,11 +146,7 @@ export default class TunnelCmd extends Command {
|
|||||||
.map(async ({ localPort, localAddress, remotePort }) => {
|
.map(async ({ localPort, localAddress, remotePort }) => {
|
||||||
try {
|
try {
|
||||||
const { tunnelConnectionToDevice } = await import('../utils/tunnel');
|
const { tunnelConnectionToDevice } = await import('../utils/tunnel');
|
||||||
const handler = await tunnelConnectionToDevice(
|
const handler = await tunnelConnectionToDevice(uuid, remotePort, sdk);
|
||||||
device.uuid,
|
|
||||||
remotePort,
|
|
||||||
sdk,
|
|
||||||
);
|
|
||||||
|
|
||||||
const { createServer } = await import('net');
|
const { createServer } = await import('net');
|
||||||
const server = createServer(async (client: Socket) => {
|
const server = createServer(async (client: Socket) => {
|
||||||
@ -162,7 +157,7 @@ export default class TunnelCmd extends Command {
|
|||||||
client.remotePort || 0,
|
client.remotePort || 0,
|
||||||
client.localAddress,
|
client.localAddress,
|
||||||
client.localPort,
|
client.localPort,
|
||||||
device.uuid,
|
uuid,
|
||||||
remotePort,
|
remotePort,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -171,7 +166,7 @@ export default class TunnelCmd extends Command {
|
|||||||
client.remotePort || 0,
|
client.remotePort || 0,
|
||||||
client.localAddress,
|
client.localAddress,
|
||||||
client.localPort,
|
client.localPort,
|
||||||
device.uuid,
|
uuid,
|
||||||
remotePort,
|
remotePort,
|
||||||
err,
|
err,
|
||||||
);
|
);
|
||||||
@ -186,15 +181,15 @@ export default class TunnelCmd extends Command {
|
|||||||
});
|
});
|
||||||
|
|
||||||
logger.logInfo(
|
logger.logInfo(
|
||||||
` - tunnelling ${localAddress}:${localPort} to ${device.uuid}:${remotePort}`,
|
` - tunnelling ${localAddress}:${localPort} to ${uuid}:${remotePort}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.logWarn(
|
logger.logWarn(
|
||||||
` - not tunnelling ${localAddress}:${localPort} to ${
|
` - not tunnelling ${localAddress}:${localPort} to ${uuid}:${remotePort}, failed ${JSON.stringify(
|
||||||
device.uuid
|
err.message,
|
||||||
}:${remotePort}, failed ${JSON.stringify(err.message)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user