From a12806e9d8aa7e6149cb587681c20d254afb8379 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Tue, 3 Jun 2025 20:11:48 +0200 Subject: [PATCH 01/13] Update test NodeJS to later version --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 32fdd0f..505825f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [16.x, 18.x, 20.x] + node-version: [20.x, 22.x, 24.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} From b28f357dca533bff37f856a3321a2e61b2ea4718 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Tue, 3 Jun 2025 22:57:14 +0200 Subject: [PATCH 02/13] fix --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 505825f..dbc909f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,7 +25,7 @@ jobs: - name: Verify lint run: npm run lint - name: Show interfaces - run: sudo ip r + run: sudo ip route show - name: Test cable run: bin/index.js cable && bin/index.js stop - name: Test configuration From cf503a496ecbfc2c219acec827a89b01d5c5c4b8 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Wed, 4 Jun 2025 07:44:40 +0200 Subject: [PATCH 03/13] Show default --- .github/workflows/linux.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index dbc909f..a567cc9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -26,6 +26,8 @@ jobs: run: npm run lint - name: Show interfaces run: sudo ip route show + - name: Get default interface + run: sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n' - name: Test cable run: bin/index.js cable && bin/index.js stop - name: Test configuration From 3a8d00966c2ed349b35926c34cfa55e9cda1d807 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 05:30:23 +0200 Subject: [PATCH 04/13] test --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a567cc9..7546339 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -21,7 +21,7 @@ jobs: - name: Install throttle run: npm ci - name: Install dependencies - run: sudo apt-get install -y net-tools + run: sudo apt-get install -y iproute2 - name: Verify lint run: npm run lint - name: Show interfaces From 20c6f40036798fe5337efcfc9c29ea07dd3b4b1b Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 05:33:16 +0200 Subject: [PATCH 05/13] moar --- .github/workflows/linux.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7546339..1667a03 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -21,7 +21,7 @@ jobs: - name: Install throttle run: npm ci - name: Install dependencies - run: sudo apt-get install -y iproute2 + run: sudo apt-get install -y net-tools - name: Verify lint run: npm run lint - name: Show interfaces @@ -31,11 +31,11 @@ jobs: - name: Test cable run: bin/index.js cable && bin/index.js stop - name: Test configuration - run: bin/index.js throttle --up 330 --down 780 --rtt 200 && bin/index.js stop + run: LOG_THROTTLE=true bin/index.js throttle --up 330 --down 780 --rtt 200 && bin/index.js stop - name: Test localhost - run: bin/index.js --rtt 200 --localhost && bin/index.js stop --localhost + run: LOG_THROTTLE=true bin/index.js --rtt 200 --localhost && bin/index.js stop --localhost - name: Test config file - run: bin/index.js --config test/config.json && bin/index.js stop + run: LOG_THROTTLE=true bin/index.js --config test/config.json && bin/index.js stop - name: Test packet loss run: bin/index.js throttle --up 330 --down 780 --rtt 200 --packetLoss 10 && bin/index.js stop - name: Test packet loss and profile From ea933bf343b82ee307cad8542ff6deb026bd7405 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 05:37:02 +0200 Subject: [PATCH 06/13] moar --- .github/workflows/linux.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1667a03..1c0b73a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -29,7 +29,7 @@ jobs: - name: Get default interface run: sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n' - name: Test cable - run: bin/index.js cable && bin/index.js stop + run: LOG_THROTTLE=true bin/index.js cable && bin/index.js stop - name: Test configuration run: LOG_THROTTLE=true bin/index.js throttle --up 330 --down 780 --rtt 200 && bin/index.js stop - name: Test localhost @@ -37,6 +37,6 @@ jobs: - name: Test config file run: LOG_THROTTLE=true bin/index.js --config test/config.json && bin/index.js stop - name: Test packet loss - run: bin/index.js throttle --up 330 --down 780 --rtt 200 --packetLoss 10 && bin/index.js stop + run: LOG_THROTTLE=true bin/index.js throttle --up 330 --down 780 --rtt 200 --packetLoss 10 && bin/index.js stop - name: Test packet loss and profile - run: bin/index.js 3g --packetLoss 10 && bin/index.js stop + run: LOG_THROTTLE=true bin/index.js 3g --packetLoss 10 && bin/index.js stop From a572c92a4a57bec8f9fdcb083f91976f42bfca01 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 05:58:09 +0200 Subject: [PATCH 07/13] test --- lib/tc.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/tc.js b/lib/tc.js index a79ca49..36a03af 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -2,17 +2,17 @@ import shell from './shell.js'; import sudo from './sudo.js'; async function getDefaultInterface() { - const result = await shell( - "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'", - { - shell: true - } - ); + const command = "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'" + const result = await shell(command , { shell: true } ); if (result.stdout.length === 0 && result.stderr.length > 0) { throw new Error( 'There was an error getting the default interface:\n\n' + result.stderr ); + } else if (result.stdout.length === 0) { + // lets do one retry + const result = await shell(command , { shell: true } ); + return result.stdout; } return result.stdout; From 129b59f363b15db6b2a3e2a383b5e20b4b608b63 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 06:04:15 +0200 Subject: [PATCH 08/13] lint --- lib/tc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tc.js b/lib/tc.js index 36a03af..f7efd3f 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -2,16 +2,17 @@ import shell from './shell.js'; import sudo from './sudo.js'; async function getDefaultInterface() { - const command = "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'" - const result = await shell(command , { shell: true } ); + const command = + "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'"; + const result = await shell(command, { shell: true }); if (result.stdout.length === 0 && result.stderr.length > 0) { throw new Error( 'There was an error getting the default interface:\n\n' + result.stderr ); } else if (result.stdout.length === 0) { - // lets do one retry - const result = await shell(command , { shell: true } ); + // lets do one retry + const result = await shell(command, { shell: true }); return result.stdout; } From 0fdc9fc6717852ba8af1a1c6cdc1408f2bc2fe72 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 06:14:52 +0200 Subject: [PATCH 09/13] lint --- lib/tc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tc.js b/lib/tc.js index f7efd3f..11bd538 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -13,6 +13,9 @@ async function getDefaultInterface() { } else if (result.stdout.length === 0) { // lets do one retry const result = await shell(command, { shell: true }); + if (result.stdout.length === 0) { + throw new Error('There was an error getting the default interface'); + } return result.stdout; } From 3f2dc1abaaf3680a1ac5a47b61e61ab06bc936d7 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 06:26:27 +0200 Subject: [PATCH 10/13] waiT --- lib/tc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tc.js b/lib/tc.js index 11bd538..4989255 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -1,6 +1,8 @@ import shell from './shell.js'; import sudo from './sudo.js'; +const delay = (ms) => new Promise((result) => setTimeout(result, ms)); + async function getDefaultInterface() { const command = "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'"; @@ -12,6 +14,7 @@ async function getDefaultInterface() { ); } else if (result.stdout.length === 0) { // lets do one retry + await delay(1000); const result = await shell(command, { shell: true }); if (result.stdout.length === 0) { throw new Error('There was an error getting the default interface'); From f599e076e8c3567474140bab73cf2235a36d0d8f Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 07:14:47 +0200 Subject: [PATCH 11/13] More info --- lib/tc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tc.js b/lib/tc.js index 4989255..8d96233 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -6,7 +6,7 @@ const delay = (ms) => new Promise((result) => setTimeout(result, ms)); async function getDefaultInterface() { const command = "sudo ip route | awk '/default/ {print $5; exit}' | tr -d '\n'"; - const result = await shell(command, { shell: true }); + const result = await shell(command); if (result.stdout.length === 0 && result.stderr.length > 0) { throw new Error( @@ -14,10 +14,12 @@ async function getDefaultInterface() { ); } else if (result.stdout.length === 0) { // lets do one retry + // The GitHub Actions sometimes cannot find the interface await delay(1000); - const result = await shell(command, { shell: true }); + const result = await shell(command); if (result.stdout.length === 0) { - throw new Error('There was an error getting the default interface'); + const result = await shell('sudo ip route show'); + throw new Error('There was an error getting the default interface %s', result.stdout); } return result.stdout; } From be0e125fedabf56805fa2908f9ea9f9cdaa52762 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 07:18:52 +0200 Subject: [PATCH 12/13] lint --- lib/tc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tc.js b/lib/tc.js index 8d96233..5988fff 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -19,7 +19,10 @@ async function getDefaultInterface() { const result = await shell(command); if (result.stdout.length === 0) { const result = await shell('sudo ip route show'); - throw new Error('There was an error getting the default interface %s', result.stdout); + throw new Error( + 'There was an error getting the default interface %s', + result.stdout + ); } return result.stdout; } From 3c30aeb5c0fd8ba11d1533d7e1b33fdc93169530 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Thu, 5 Jun 2025 07:27:33 +0200 Subject: [PATCH 13/13] fix --- lib/tc.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tc.js b/lib/tc.js index 5988fff..4debd46 100644 --- a/lib/tc.js +++ b/lib/tc.js @@ -20,8 +20,7 @@ async function getDefaultInterface() { if (result.stdout.length === 0) { const result = await shell('sudo ip route show'); throw new Error( - 'There was an error getting the default interface %s', - result.stdout + `There was an error getting the default interface ${result.stdout}` ); } return result.stdout;