tcpie 11.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +1 -1
- package/dist/tcpie.js +4 -4
- package/package.json +10 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) silverwind
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
17
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
22
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# tcpie
|
|
2
|
-
[](https://www.npmjs.org/package/tcpie) [](https://www.npmjs.org/package/tcpie) [](https://packagephobia.com/result?p=tcpie)
|
|
2
|
+
[](https://www.npmjs.org/package/tcpie) [](https://www.npmjs.org/package/tcpie) [](https://bundlephobia.com/package/tcpie) [](https://packagephobia.com/result?p=tcpie)
|
|
3
3
|
|
|
4
4
|
> Ping any TCP port
|
|
5
5
|
|
package/dist/tcpie.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {createRequire} from 'module';const require = createRequire(import.meta.url);
|
|
3
|
-
var vt=Object.create;var j=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var
|
|
4
|
-
`);l.v&&(console.info(Yt),
|
|
3
|
+
var vt=Object.create;var j=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Ot=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var k=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var Ct=(t,o,e,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Rt(o))!It.call(t,n)&&n!==e&&j(t,n,{get:()=>o[n],enumerable:!(s=$t(o,n))||s.enumerable});return t};var tt=(t,o,e)=>(e=t!=null?vt(Ot(t)):{},Ct(o||!t||!t.__esModule?j(e,"default",{value:t,enumerable:!0}):e,t));var it=k((Zt,st)=>{(function(){"use strict";function t(o){if(!Array.isArray(o))throw new TypeError("stdev()::invalid input argument. Must provide an array.");var e=o.length,s=0,n=0,c=0,r=0;if(e<2)return 0;for(var A=0;A<e;A++)s+=1,r=o[A]-n,n+=r/s,c+=r*(o[A]-n);return Math.sqrt(c/(s-1))}st.exports=t})()});var lt=k((kt,ut)=>{"use strict";function At(t,o){var e=t;o.slice(0,-1).forEach(function(n){e=e[n]||{}});var s=o[o.length-1];return s in e}function ct(t){return typeof t=="number"||/^0x[0-9a-f]+$/i.test(t)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)}function ft(t,o){return o==="constructor"&&typeof t[o]=="function"||o==="__proto__"}ut.exports=function(t,o){o||(o={});var e={bools:{},strings:{},unknownFn:null};typeof o.unknown=="function"&&(e.unknownFn=o.unknown),typeof o.boolean=="boolean"&&o.boolean?e.allBools=!0:[].concat(o.boolean).filter(Boolean).forEach(function(i){e.bools[i]=!0});var s={};function n(i){return s[i].some(function(m){return e.bools[m]})}Object.keys(o.alias||{}).forEach(function(i){s[i]=[].concat(o.alias[i]),s[i].forEach(function(m){s[m]=[i].concat(s[i].filter(function(I){return m!==I}))})}),[].concat(o.string).filter(Boolean).forEach(function(i){e.strings[i]=!0,s[i]&&[].concat(s[i]).forEach(function(m){e.strings[m]=!0})});var c=o.default||{},r={_:[]};function A(i,m){return e.allBools&&/^--[^=]+$/.test(m)||e.strings[i]||e.bools[i]||s[i]}function P(i,m,I){for(var u=i,S=0;S<m.length-1;S++){var R=m[S];if(ft(u,R))return;u[R]===void 0&&(u[R]={}),(u[R]===Object.prototype||u[R]===Number.prototype||u[R]===String.prototype)&&(u[R]={}),u[R]===Array.prototype&&(u[R]=[]),u=u[R]}var C=m[m.length-1];ft(u,C)||((u===Object.prototype||u===Number.prototype||u===String.prototype)&&(u={}),u===Array.prototype&&(u=[]),u[C]===void 0||e.bools[C]||typeof u[C]=="boolean"?u[C]=I:Array.isArray(u[C])?u[C].push(I):u[C]=[u[C],I])}function h(i,m,I){if(!(I&&e.unknownFn&&!A(i,I)&&e.unknownFn(I)===!1)){var u=!e.strings[i]&&ct(m)?Number(m):m;P(r,i.split("."),u),(s[i]||[]).forEach(function(S){P(r,S.split("."),u)})}}Object.keys(e.bools).forEach(function(i){h(i,c[i]===void 0?!1:c[i])});var V=[];t.indexOf("--")!==-1&&(V=t.slice(t.indexOf("--")+1),t=t.slice(0,t.indexOf("--")));for(var d=0;d<t.length;d++){var f=t[d],a,b;if(/^--.+=/.test(f)){var X=f.match(/^--([^=]+)=([\s\S]*)$/);a=X[1];var y=X[2];e.bools[a]&&(y=y!=="false"),h(a,y,f)}else if(/^--no-.+/.test(f))a=f.match(/^--no-(.+)/)[1],h(a,!1,f);else if(/^--.+/.test(f))a=f.match(/^--(.+)/)[1],b=t[d+1],b!==void 0&&!/^(-|--)[^-]/.test(b)&&!e.bools[a]&&!e.allBools&&(!s[a]||!n(a))?(h(a,b,f),d+=1):/^(true|false)$/.test(b)?(h(a,b==="true",f),d+=1):h(a,e.strings[a]?"":!0,f);else if(/^-[^-]+/.test(f)){for(var v=f.slice(1,-1).split(""),B=!1,_=0;_<v.length;_++){if(b=f.slice(_+2),b==="-"){h(v[_],b,f);continue}if(/[A-Za-z]/.test(v[_])&&b[0]==="="){h(v[_],b.slice(1),f),B=!0;break}if(/[A-Za-z]/.test(v[_])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(b)){h(v[_],b,f),B=!0;break}if(v[_+1]&&v[_+1].match(/\W/)){h(v[_],f.slice(_+2),f),B=!0;break}else h(v[_],e.strings[v[_]]?"":!0,f)}a=f.slice(-1)[0],!B&&a!=="-"&&(t[d+1]&&!/^(-|--)[^-]/.test(t[d+1])&&!e.bools[a]&&(!s[a]||!n(a))?(h(a,t[d+1],f),d+=1):t[d+1]&&/^(true|false)$/.test(t[d+1])?(h(a,t[d+1]==="true",f),d+=1):h(a,e.strings[a]?"":!0,f))}else if((!e.unknownFn||e.unknownFn(f)!==!1)&&r._.push(e.strings._||!ct(f)?f:Number(f)),o.stopEarly){r._.push.apply(r._,t.slice(d+1));break}}return Object.keys(c).forEach(function(i){At(r,i.split("."))||(P(r,i.split("."),c[i]),(s[i]||[]).forEach(function(m){P(r,m.split("."),c[i])}))}),o["--"]?r["--"]=V.slice():V.forEach(function(i){r._.push(i)}),r}});var ot=!0;function et(){ot=!1}function q(t,o,e){let s=t.join(" ");return ot?`\x1B[${o}m${s}\x1B[${e}m`:s}var N=(...t)=>q(t,31,39),K=(...t)=>q(t,32,39),nt=(...t)=>q(t,33,39);var _t=tt(it(),1);import{isIP as Bt}from"node:net";import{lookup as Gt}from"node:dns";import x,{exit as O,argv as Lt,stdin as z,stdout as Q,stderr as Dt}from"node:process";import{EventEmitter as wt}from"node:events";import{Socket as Nt}from"node:net";import{inherits as gt}from"node:util";var F=function(t,o,e){if(!(this instanceof F))return new F;if(typeof t!="string")throw new Error("host is required");o===void 0&&(o=80),this.host=t,this.port=o,this.opts={interval:1e3,timeout:3e3,count:1/0,...e},this.stats={sent:0,success:0,failed:0}};gt(F,wt);F.prototype.start=function t(o){return o||(this.stats.sent=0,this.stats.success=0,this.stats.failed=0),this._next=setTimeout(t.bind(this,!0),this.opts.interval),this._done=!1,this._abort=!1,this._socket=new Nt,this._startTime=performance.now(),this._socket.setTimeout(this.opts.timeout),this._socket.on("timeout",()=>{this._done||(this._done=!0,this.stats.sent++,this.stats.failed++,this.emit("timeout",H(this,this)),this._socket.destroy(),G(this))}),this._socket.on("error",e=>{this._done||(this._done=!0,this.stats.sent++,this.stats.failed++,this.emit("error",e,H(this,this)),this._socket.destroy(),G(this))}),this._socket.connect(this.port,this.host,()=>{this._done||(this._done=!0,this.stats.sent++,this.stats.success++,this.stats.rtt=performance.now()-this._startTime,this.emit("connect",H(this,this)),this._socket.end(),G(this))}),this};F.prototype.stop=function(){return this._abort=!0,this._socket.end(),G(this),this};function rt(...t){return new F(...t)}function H(t,o){let e=t.stats;return e.target={host:t.host,port:t.port},e.socket={localAddress:o.localAddress,localPort:o.localPort,remoteAddress:o.remoteAddress,remotePort:o.remotePort},e}function G(t){(t._abort||t.stats.failed+t.stats.success>=t.opts.count)&&(t._next&&clearTimeout(t._next),t.emit("end",{sent:t.stats.sent,success:t.stats.success,failed:t.stats.failed,target:{host:t.host,port:t.port}}))}var bt=tt(lt(),1);import W from"node:process";import Ft from"node:os";import at from"node:tty";function T(t,o=globalThis.Deno?globalThis.Deno.args:W.argv){let e=t.startsWith("-")?"":t.length===1?"-":"--",s=o.indexOf(e+t),n=o.indexOf("--");return s!==-1&&(n===-1||s<n)}var{env:p}=W,L;T("no-color")||T("no-colors")||T("color=false")||T("color=never")?L=0:(T("color")||T("colors")||T("color=true")||T("color=always"))&&(L=1);function Mt(){if(!("FORCE_COLOR"in p))return;if(p.FORCE_COLOR==="true")return 1;if(p.FORCE_COLOR==="false")return 0;if(p.FORCE_COLOR.length===0)return 1;let t=Math.min(Number.parseInt(p.FORCE_COLOR,10),3);if([0,1,2,3].includes(t))return t}function St(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function xt(t,{streamIsTTY:o,sniffFlags:e=!0}={}){let s=Mt();s!==void 0&&(L=s);let n=e?L:s;if(n===0)return 0;if(e){if(T("color=16m")||T("color=full")||T("color=truecolor"))return 3;if(T("color=256"))return 2}if("TF_BUILD"in p&&"AGENT_NAME"in p)return 1;if(t&&!o&&n===void 0)return 0;let c=n||0;if(p.TERM==="dumb")return c;if(W.platform==="win32"){let r=Ft.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in p)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(r=>r in p)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(r=>r in p)||p.CI_NAME==="codeship"?1:c;if("TEAMCITY_VERSION"in p)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(p.TEAMCITY_VERSION)?1:0;if(p.COLORTERM==="truecolor"||p.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in p){let r=Number.parseInt((p.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(p.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(p.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(p.TERM)||"COLORTERM"in p?1:c}function pt(t,o={}){let e=xt(t,{streamIsTTY:t&&t.isTTY,...o});return St(e)}var Pt={stdout:pt({isTTY:at.isatty(1)}),stderr:pt({isTTY:at.isatty(2)})},mt=Pt;var l=(0,bt.default)(Lt.slice(2),{boolean:["color","C","timestamp","T","flood","f","version","v"]}),Yt="11.0.1",Ut=1,D=3,Vt=0,yt=22,qt=[""," Usage: tcpie [options] host[:port] [port|22]",""," Options:",""," -v, --version output version"," -c, --count <n> number of connects (default: infinite)"," -i, --interval <n> wait n seconds between connects (default: 1)"," -t, --timeout <n> connection timeout in seconds (default: 3)"," -T, --timestamp add timestamps to output"," -f, --flood flood mode, connect as fast as possible"," -C, --no-color disable color output",""," Examples:",""," $ tcpie google.com"," $ tcpie -i .1 8.8.8.8:53"," $ tcpie -c5 -t.05 aspmx.l.google.com 25","",""].join(`
|
|
4
|
+
`);l.v&&(console.info(Yt),O(0));(!l._.length||l._.length>2||l._[1]&&Number.isNaN(parseInt(l._[1])))&&Tt();var E=l._[0],M={},w=parseInt(l._[1]),J=!1,U=[],$;typeof E!="string"&&Tt();var Y=/^(.+):(\d+)$/.exec(E);Y&&Y.length===3&&!w&&(E=Y[1],w=Y[2]);w||(w=yt);(l.count||l.c)&&(M.count=parseInt(l.count||l.c));(l.interval||l.i)&&(M.interval=Et(l.interval||l.i));(l.timeout||l.t)&&(M.timeout=Et(l.timeout||l.t));(l.flood||l.f)&&(M.interval=0);(l.C||!mt.stdout)&&et();Bt(E)?(ht(E,E,w),dt(E,w,M)):Gt(E,(t,o)=>{t?(t.code==="ENOTFOUND"?g(N("ERROR:"),`Host '${E}' not found`):g(N("ERROR:"),t.code,t.syscall||""),O(1)):(ht(E,o,w),dt(E,w,M))});function dt(t,o,e){let s=rt(t,o,e);s.on("error",(n,c)=>{$=c,g(N("error connecting to",`${c.target.host}:${c.target.port}`),`seq=${c.sent}`,`error=${N(n.code)}`)}).on("connect",n=>{$=n,U.push(n.rtt),g(K("connected to",`${n.target.host}:${n.target.port}`),`seq=${n.sent}`,n.socket.localPort!==void 0?`srcport=${n.socket.localPort}`:"",`time=${Kt(n.rtt.toFixed(Ut))}`)}).on("timeout",n=>{$=n,g(N("timeout connecting to",`${n.target.host}:${n.target.port}`),`seq=${n.sent}`,n.socket.localPort&&`srcport=${n.socket.localPort}`)}),z.isTTY?(z.setRawMode(!0),z.on("data",n=>{let c=[3,4,26,28];for(let r of n)c.includes(r)&&Z()})):(x.on("SIGINT",O),x.on("SIGQUIT",O),x.on("SIGTERM",O),x.on("SIGTSTP",O)),x.on("exit",Z),s.on("end",Z).start()}function ht(t,o,e){g("TCPIE",t,`(${o})`,"port",String(e))}function Z(){let t=0,o=1/0,e=0,s,n;if(J&&O($.success===0&&1||0),$&&$.sent>0){for(let c of U)c<=o&&(o=c.toFixed(D)),c>=e&&(e=c.toFixed(D)),t+=c;s=(t/U.length).toFixed(D),n=(0,_t.default)(U).toFixed(D),o===1/0&&(o="0"),Number.isNaN(s)&&(s="0"),J=!0,g(`
|
|
5
5
|
---`,E,"tcpie statistics","---",`
|
|
6
6
|
${$.sent}`,"handshakes attempted,",$.success||"0","succeeded,",`${($.failed/$.sent*100).toFixed(Vt)}% failed`,`
|
|
7
|
-
rtt min/avg/max/stdev =`,`${o}/${s}/${e}/${n}`,"ms"),
|
|
7
|
+
rtt min/avg/max/stdev =`,`${o}/${s}/${e}/${n}`,"ms"),O($.success===0&&1||0)}else O(1)}function Kt(t){return t>=150?`${N(t)} ms`:t>=75?`${nt(t)} ms`:`${K(t)} ms`}function g(...t){t=t.filter(Boolean),(l.timeout||l.T)&&t[0][0]!==`
|
|
8
8
|
`&&t.unshift(Ht()),t.push(`
|
|
9
|
-
`),(Q._type==="pipe"&&J?Dt:Q).write(t.join(" "))}function
|
|
9
|
+
`),(Q._type==="pipe"&&J?Dt:Q).write(t.join(" "))}function Tt(){Q.write(qt),O(1)}function Et(t){return parseFloat(t)*1e3}function Ht(){let t=new Date,o=t.getFullYear(),e=t.getMonth()+1,s=t.getDate(),n=t.getHours(),c=t.getMinutes(),r=t.getSeconds();return e<10&&(e=`0${e}`),s<10&&(s=`0${s}`),n<10&&(n=`0${n}`),c<10&&(c=`0${c}`),r<10&&(r=`0${r}`),`${o}-${e}-${s} ${n}:${c}:${r}`}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tcpie",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "Ping any TCP port",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/tcpie",
|
|
@@ -18,16 +18,18 @@
|
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"compute-stdev": "1.0.0",
|
|
21
|
-
"glowie": "1.2
|
|
21
|
+
"glowie": "1.3.2",
|
|
22
22
|
"minimist": "1.2.8",
|
|
23
|
-
"supports-color": "
|
|
23
|
+
"supports-color": "10.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"eslint": "8.57.0",
|
|
27
|
-
"eslint-config-silverwind": "
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
27
|
+
"eslint-config-silverwind": "99.0.0",
|
|
28
|
+
"typescript": "5.7.3",
|
|
29
|
+
"typescript-config-silverwind": "7.0.0",
|
|
30
|
+
"updates": "16.4.2",
|
|
31
|
+
"versions": "12.1.3",
|
|
32
|
+
"vitest": "3.0.5",
|
|
33
|
+
"vitest-config-silverwind": "10.0.0"
|
|
32
34
|
}
|
|
33
35
|
}
|