Skip to content

Commit

Permalink
export port finder
Browse files Browse the repository at this point in the history
  • Loading branch information
leone authored and Leonewu committed Jul 15, 2023
1 parent f221d1e commit 51d1d35
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": false,
"name": "ssh-tunneling",
"version": "1.1.18",
"version": "1.1.19",
"description": "a ssh-tunneling client for nodejs",
"keywords": [
"ssh tunnel",
Expand Down
28 changes: 15 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,4 @@ class SshTunnel {

}

export { logger, SshTunnel }
export { logger, SshTunnel, getAvailablePort }
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const checkPortAvailable = (port: number) => {
});
}

/**
* @description check whether port is idle and then return another idle port if the port pass in is unavailable
*/
export const getAvailablePort = async (port: number) => {
if (port > 65535) {
throw new Error('There is no available port');
Expand Down

0 comments on commit 51d1d35

Please sign in to comment.