Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

keep-open

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keep-open - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

39

index.js

@@ -0,1 +1,3 @@

#!/usr/bin/env node
const { Socket } = require('net');

@@ -7,2 +9,3 @@ const { Command } = require('commander');

commander.requiredOption('-p, --ports <ports...>', 'an array of `host:port` combinations to keep connected to, e.g. localhost:1234');
commander.option('-w, --wait <interval>', 'interval to wait before sending the first package, seconds', 60);
commander.option('-i, --interval <interval>', 'interval to send the empty package, seconds', 60);

@@ -13,3 +16,3 @@ commander.option('-v, --verbose', 'enables verbose output', false);

const { ports, interval, verbose } = commander.opts();
const { ports, interval, verbose, wait } = commander.opts();

@@ -19,23 +22,27 @@ ports.forEach(hostPort => {

function send() {
const client = new Socket();
verbose && console.log(`Waiting ${wait}s to connect to ${hostPort}`);
client.connect(port, host, () => {
verbose && console.log(`Connected to ${hostPort}`);
setTimeout(() => {
function send() {
const client = new Socket();
client.write(new Uint8Array());
client.connect(port, host, () => {
verbose && console.log(`Connected to ${hostPort}`);
verbose && console.log(`Sent message to to ${hostPort}, closing connection...`);
client.write(new Uint8Array());
client.destroy();
});
verbose && console.log(`Sent message to to ${hostPort}, closing connection...`);
client.on('error', (error) => {
console.error(`Error: cannot connect to ${hostPort}, next attempt in ${interval}s`);
verbose && console.error(error);
})
}
client.destroy();
});
send();
setInterval(() => send(host, port), interval * 1e3);
client.on('error', (error) => {
console.error(`Error: cannot connect to ${hostPort}, next attempt in ${interval}s`);
verbose && console.error(error);
})
}
send();
setInterval(() => send(host, port), interval * 1e3);
}, wait * 1e3);
});
{
"name": "keep-open",
"version": "1.0.0",
"version": "1.0.2",
"description": "A CLI tool to keep the forwarded ports (e.g. with SSH or Kubernetes) connected",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,6 +19,6 @@ # keep-open

Specify custom interval (default is 60s):
Specify custom interval (default is 60s) and initial waiting time (default is 60s):
```sh
npx keep-open -p localhost:1234 localhost:4321 -i 60
npx keep-open -p localhost:1234 localhost:4321 -w 10 -i 10
```

@@ -25,0 +25,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc