From 0e059d6443aabcc5ea54a27a70e7a68fdafbc58c Mon Sep 17 00:00:00 2001 From: greysoh Date: Tue, 7 May 2024 18:44:26 -0400 Subject: [PATCH] chore: Adds option to customize pulling rate. --- lom/src/commands/connections.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lom/src/commands/connections.ts b/lom/src/commands/connections.ts index db6c198..2113196 100644 --- a/lom/src/commands/connections.ts +++ b/lom/src/commands/connections.ts @@ -88,9 +88,11 @@ export async function run( getInbound.description("Shows all current connections"); getInbound.argument("", "Tunnel ID to view inbound connections of"); getInbound.option("-t, --tail", "Live-view of connection list"); + getInbound.option("-s, --tail-pull-rate ", "Controls the speed to pull at (in ms)"); getInbound.action(async(idStr: string, options: { - tail?: boolean + tail?: boolean, + tailPullRate?: string }): Promise => { type InboundConnectionSuccess = { success: true, @@ -107,11 +109,17 @@ export async function run( }[] }; + const pullRate: number = options.tailPullRate ? parseInt(options.tailPullRate) : 2000; const id = parseInt(idStr); if (Number.isNaN(id)) { println("ID (%s) is not a number\n", idStr); - return; + return resolve(null); + } + + if (Number.isNaN(pullRate)) { + println("Pull rate is not a number\n"); + return resolve(null); } if (options.tail) { @@ -146,7 +154,7 @@ export async function run( previousEntries = simplifiedArray; - await new Promise((i) => setTimeout(i, 2000)); + await new Promise((i) => setTimeout(i, pullRate)); } } else { const response = await axios.post("/api/v1/forward/connections", {