netprober 1.2.0
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 +21 -0
- package/README.md +127 -0
- package/dist/netprober.bundled.mjs +46 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Meisam Maani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<div align="ltr">
|
|
2
|
+
|
|
3
|
+
# ๐ netprober
|
|
4
|
+
|
|
5
|
+
**Async host & IP prober โ fast, concurrent, pretty.**
|
|
6
|
+
|
|
7
|
+
DNS resolution ยท Port 443 ยท ICMP ping ยท HTTPS curl ยท CIDR sweep
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## โจ Features
|
|
12
|
+
|
|
13
|
+
- **Live terminal summary** โ progress bar, stats, and per-IP results update in real time
|
|
14
|
+
- **CIDR expansion** โ sweep entire subnets like `10.0.0.0/24` natively
|
|
15
|
+
- **Concurrent probing** โ tunable worker pool, non-blocking by default
|
|
16
|
+
- **Multiple check modes** โ port 443 socket, ICMP ping, and HTTPS curl independently toggled
|
|
17
|
+
- **Structured output** โ results written to separate files as they land, no waiting
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ๐ฆ Installation
|
|
22
|
+
|
|
23
|
+
### Run directly with Bun (no install)
|
|
24
|
+
|
|
25
|
+
> Requires [Bun](https://bun.sh) โ install it first
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/maanimis/netprober
|
|
29
|
+
cd netprober
|
|
30
|
+
bun ./src/index.ts --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Download prebuilt binary
|
|
36
|
+
|
|
37
|
+
A standalone binary is available for **Linux x86-64 (amd64)** โ no Node, no Bun required.
|
|
38
|
+
|
|
39
|
+
1. Head to the [**Releases**](https://github.com/maanimis/netprober/releases) page
|
|
40
|
+
2. Download `netprober-linux-amd64`
|
|
41
|
+
3. Make it executable and run:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
chmod +x netprober-linux-amd64
|
|
45
|
+
./netprober-linux-amd64 --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> โ ๏ธ Only `linux/amd64` is currently available as a prebuilt binary. For other platforms, use the npm package or run with Bun directly.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## ๐ Usage
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
netprober [options]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Flags
|
|
59
|
+
|
|
60
|
+
| Flag | Description | Default |
|
|
61
|
+
| ----------------------- | -------------------------------- | ---------------- |
|
|
62
|
+
| `-i, --input <file>` | Input hosts file | `hosts.txt` |
|
|
63
|
+
| `--output-ping <file>` | Ping-up IPs output file | `ping_up.txt` |
|
|
64
|
+
| `--output-ports <file>` | Port-443-open IPs output file | `ports_open.txt` |
|
|
65
|
+
| `-r, --resolver <ip>` | DNS resolver to use | `127.0.0.1` |
|
|
66
|
+
| `-c, --concurrency <n>` | Concurrent workers | `10` |
|
|
67
|
+
| `-t, --timeout <s>` | Per-check timeout in seconds | `5` |
|
|
68
|
+
| `--ping-count <n>` | ICMP ping packet count | `3` |
|
|
69
|
+
| `--ping` | Enable ICMP ping checks | `false` |
|
|
70
|
+
| `--curl` | Enable HTTPS curl checks | `false` |
|
|
71
|
+
| `-v, --verbose` | Show all IPs, not just live ones | `false` |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## ๐ Input Format
|
|
76
|
+
|
|
77
|
+
Create a `hosts.txt` file โ one host, IP, or CIDR range per line:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
example.com
|
|
81
|
+
api.example.com
|
|
82
|
+
192.168.1.0/24
|
|
83
|
+
10.0.0.1
|
|
84
|
+
https://target.com/path โ URLs are sanitized automatically
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## โก Examples
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Basic โ port 443 probe only
|
|
93
|
+
netprober -i hosts.txt
|
|
94
|
+
|
|
95
|
+
# With ping + curl, using Google's DNS, 25 workers
|
|
96
|
+
netprober --ping --curl -r 8.8.8.8 -c 25
|
|
97
|
+
|
|
98
|
+
# Verbose output โ show every IP, not just live ones
|
|
99
|
+
netprober -v --curl -t 3
|
|
100
|
+
|
|
101
|
+
# Sweep a CIDR range with curl enabled
|
|
102
|
+
netprober -i ranges.txt --curl -c 50
|
|
103
|
+
|
|
104
|
+
# Custom output files
|
|
105
|
+
netprober -i targets.txt -o live.txt --output-ports open443.txt
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## ๐ Output Files
|
|
111
|
+
|
|
112
|
+
| File | Contents |
|
|
113
|
+
| ---------------- | ------------------------------------------------- |
|
|
114
|
+
| `ping_up.txt` | IPs responding to ICMP ping _(requires `--ping`)_ |
|
|
115
|
+
| `ports_open.txt` | IPs with port 443 open |
|
|
116
|
+
|
|
117
|
+
All files are written **in real time** as results come in โ no waiting for the run to finish.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
## Acknowledgements
|
|
121
|
+
|
|
122
|
+
Provider list sourced from: [Expen1/MonPing](https://github.com/Expen1/MonPing/blob/ac17f7726aacb8d27f6181e9b12ea3d16f758320/monping.py#L53)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
## ๐ License
|
|
126
|
+
|
|
127
|
+
MIT ยฉ [maanimis](https://github.com/maanimis)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as N2}from"node:module";var B2=Object.create;var{getPrototypeOf:W2,defineProperty:Y0,getOwnPropertyNames:L2}=Object;var j2=Object.prototype.hasOwnProperty;function I2($){return this[$]}var G2,D2,w2=($,T,P)=>{var q=$!=null&&typeof $==="object";if(q){var J=T?G2??=new WeakMap:D2??=new WeakMap,Q=J.get($);if(Q)return Q}P=$!=null?B2(W2($)):{};let X=T||!$||!$.__esModule?Y0(P,"default",{value:$,enumerable:!0}):P;for(let Z of L2($))if(!j2.call(X,Z))Y0(X,Z,{get:I2.bind($,Z),enumerable:!0});if(q)J.set($,X);return X};var F=($,T)=>()=>(T||$((T={exports:{}}).exports,T),T.exports);var S=N2(import.meta.url);var x=F((c2)=>{class r extends Error{constructor($,T,P){super(P);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=T,this.exitCode=$,this.nestedError=void 0}}class N0 extends r{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}c2.CommanderError=r;c2.InvalidArgumentError=N0});var m=F((i2)=>{var{InvalidArgumentError:l2}=x();class k0{constructor($,T){switch(this.description=T||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,T){if(T===this.defaultValue||!Array.isArray(T))return[$];return T.push($),T}default($,T){return this.defaultValue=$,this.defaultValueDescription=T,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(T,P)=>{if(!this.argChoices.includes(T))throw new l2(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(T,P);return T},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function d2($){let T=$.name()+($.variadic===!0?"...":"");return $.required?"<"+T+">":"["+T+"]"}i2.Argument=k0;i2.humanReadableArgName=d2});var a=F((s2)=>{var{humanReadableArgName:n2}=m();class F0{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let T=$.commands.filter((q)=>!q._hidden),P=$._getHelpCommand();if(P&&!P._hidden)T.push(P);if(this.sortSubcommands)T.sort((q,J)=>{return q.name().localeCompare(J.name())});return T}compareOptions($,T){let P=(q)=>{return q.short?q.short.replace(/^-/,""):q.long.replace(/^--/,"")};return P($).localeCompare(P(T))}visibleOptions($){let T=$.options.filter((q)=>!q.hidden),P=$._getHelpOption();if(P&&!P.hidden){let q=P.short&&$._findOption(P.short),J=P.long&&$._findOption(P.long);if(!q&&!J)T.push(P);else if(P.long&&!J)T.push($.createOption(P.long,P.description));else if(P.short&&!q)T.push($.createOption(P.short,P.description))}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let T=[];for(let P=$.parent;P;P=P.parent){let q=P.options.filter((J)=>!J.hidden);T.push(...q)}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((T)=>{T.description=T.description||$._argsDescription[T.name()]||""});if($.registeredArguments.find((T)=>T.description))return $.registeredArguments;return[]}subcommandTerm($){let T=$.registeredArguments.map((P)=>n2(P)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(T?" "+T:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,T){return T.visibleCommands($).reduce((P,q)=>{return Math.max(P,this.displayWidth(T.styleSubcommandTerm(T.subcommandTerm(q))))},0)}longestOptionTermLength($,T){return T.visibleOptions($).reduce((P,q)=>{return Math.max(P,this.displayWidth(T.styleOptionTerm(T.optionTerm(q))))},0)}longestGlobalOptionTermLength($,T){return T.visibleGlobalOptions($).reduce((P,q)=>{return Math.max(P,this.displayWidth(T.styleOptionTerm(T.optionTerm(q))))},0)}longestArgumentTermLength($,T){return T.visibleArguments($).reduce((P,q)=>{return Math.max(P,this.displayWidth(T.styleArgumentTerm(T.argumentTerm(q))))},0)}commandUsage($){let T=$._name;if($._aliases[0])T=T+"|"+$._aliases[0];let P="";for(let q=$.parent;q;q=q.parent)P=q.name()+" "+P;return P+T+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let T=[];if($.argChoices)T.push(`choices: ${$.argChoices.map((P)=>JSON.stringify(P)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")T.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)T.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)T.push(`env: ${$.envVar}`);if(T.length>0){let P=`(${T.join(", ")})`;if($.description)return`${$.description} ${P}`;return P}return $.description}argumentDescription($){let T=[];if($.argChoices)T.push(`choices: ${$.argChoices.map((P)=>JSON.stringify(P)).join(", ")}`);if($.defaultValue!==void 0)T.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(T.length>0){let P=`(${T.join(", ")})`;if($.description)return`${$.description} ${P}`;return P}return $.description}formatItemList($,T,P){if(T.length===0)return[];return[P.styleTitle($),...T,""]}groupItems($,T,P){let q=new Map;return $.forEach((J)=>{let Q=P(J);if(!q.has(Q))q.set(Q,[])}),T.forEach((J)=>{let Q=P(J);if(!q.has(Q))q.set(Q,[]);q.get(Q).push(J)}),q}formatHelp($,T){let P=T.padWidth($,T),q=T.helpWidth??80;function J(R,z){return T.formatItem(R,P,z,T)}let Q=[`${T.styleTitle("Usage:")} ${T.styleUsage(T.commandUsage($))}`,""],X=T.commandDescription($);if(X.length>0)Q=Q.concat([T.boxWrap(T.styleCommandDescription(X),q),""]);let Z=T.visibleArguments($).map((R)=>{return J(T.styleArgumentTerm(T.argumentTerm(R)),T.styleArgumentDescription(T.argumentDescription(R)))});if(Q=Q.concat(this.formatItemList("Arguments:",Z,T)),this.groupItems($.options,T.visibleOptions($),(R)=>R.helpGroupHeading??"Options:").forEach((R,z)=>{let K=R.map((W)=>{return J(T.styleOptionTerm(T.optionTerm(W)),T.styleOptionDescription(T.optionDescription(W)))});Q=Q.concat(this.formatItemList(z,K,T))}),T.showGlobalOptions){let R=T.visibleGlobalOptions($).map((z)=>{return J(T.styleOptionTerm(T.optionTerm(z)),T.styleOptionDescription(T.optionDescription(z)))});Q=Q.concat(this.formatItemList("Global Options:",R,T))}return this.groupItems($.commands,T.visibleCommands($),(R)=>R.helpGroup()||"Commands:").forEach((R,z)=>{let K=R.map((W)=>{return J(T.styleSubcommandTerm(T.subcommandTerm(W)),T.styleSubcommandDescription(T.subcommandDescription(W)))});Q=Q.concat(this.formatItemList(z,K,T))}),Q.join(`
|
|
3
|
+
`)}displayWidth($){return V0($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T==="[command]")return this.styleSubcommandText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleCommandText(T)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleSubcommandText(T)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,T){return Math.max(T.longestOptionTermLength($,T),T.longestGlobalOptionTermLength($,T),T.longestSubcommandTermLength($,T),T.longestArgumentTermLength($,T))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,T,P,q){let Q=" ".repeat(2);if(!P)return Q+$;let X=$.padEnd(T+$.length-q.displayWidth($)),Z=2,U=(this.helpWidth??80)-T-Z-2,R;if(U<this.minWidthToWrap||q.preformatted(P))R=P;else R=q.boxWrap(P,U).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(T+Z));return Q+X+" ".repeat(Z)+R.replace(/\n/g,`
|
|
5
|
+
${Q}`)}boxWrap($,T){if(T<this.minWidthToWrap)return $;let P=$.split(/\r\n|\n/),q=/[\s]*[^\s]+/g,J=[];return P.forEach((Q)=>{let X=Q.match(q);if(X===null){J.push("");return}let Z=[X.shift()],H=this.displayWidth(Z[0]);X.forEach((U)=>{let R=this.displayWidth(U);if(H+R<=T){Z.push(U),H+=R;return}J.push(Z.join(""));let z=U.trimStart();Z=[z],H=this.displayWidth(z)}),J.push(Z.join(""))}),J.join(`
|
|
6
|
+
`)}}function V0($){let T=/\x1b\[\d*(;\d*)*m/g;return $.replace(T,"")}s2.Help=F0;s2.stripColor=V0});var t=F(($1)=>{var{InvalidArgumentError:t2}=x();class y0{constructor($,T){this.flags=$,this.description=T||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let P=e2($);if(this.short=P.shortFlag,this.long=P.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,T){return this.defaultValue=$,this.defaultValueDescription=T,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let T=$;if(typeof $==="string")T={[$]:!0};return this.implied=Object.assign(this.implied||{},T),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,T){if(T===this.defaultValue||!Array.isArray(T))return[$];return T.push($),T}choices($){return this.argChoices=$.slice(),this.parseArg=(T,P)=>{if(!this.argChoices.includes(T))throw new t2(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(T,P);return T},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return O0(this.name().replace(/^no-/,""));return O0(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class A0{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((T)=>{if(T.negate)this.negativeOptions.set(T.attributeName(),T);else this.positiveOptions.set(T.attributeName(),T)}),this.negativeOptions.forEach((T,P)=>{if(this.positiveOptions.has(P))this.dualOptions.add(P)})}valueFromOption($,T){let P=T.attributeName();if(!this.dualOptions.has(P))return!0;let q=this.negativeOptions.get(P).presetArg,J=q!==void 0?q:!1;return T.negate===(J===$)}}function O0($){return $.split("-").reduce((T,P)=>{return T+P[0].toUpperCase()+P.slice(1)})}function e2($){let T,P,q=/^-[^-]$/,J=/^--[^-]/,Q=$.split(/[ |,]+/).concat("guard");if(q.test(Q[0]))T=Q.shift();if(J.test(Q[0]))P=Q.shift();if(!T&&q.test(Q[0]))T=Q.shift();if(!T&&J.test(Q[0]))T=P,P=Q.shift();if(Q[0].startsWith("-")){let X=Q[0],Z=`option creation failed due to '${X}' in option flags '${$}'`;if(/^-[^-][^-]/.test(X))throw Error(`${Z}
|
|
7
|
+
- a short flag is a single dash and a single character
|
|
8
|
+
- either use a single dash and a single character (for a short flag)
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(q.test(X))throw Error(`${Z}
|
|
10
|
+
- too many short flags`);if(J.test(X))throw Error(`${Z}
|
|
11
|
+
- too many long flags`);throw Error(`${Z}
|
|
12
|
+
- unrecognised flag format`)}if(T===void 0&&P===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:T,longFlag:P}}$1.Option=y0;$1.DualOptions=A0});var f0=F((Q1)=>{function q1($,T){if(Math.abs($.length-T.length)>3)return Math.max($.length,T.length);let P=[];for(let q=0;q<=$.length;q++)P[q]=[q];for(let q=0;q<=T.length;q++)P[0][q]=q;for(let q=1;q<=T.length;q++)for(let J=1;J<=$.length;J++){let Q=1;if($[J-1]===T[q-1])Q=0;else Q=1;if(P[J][q]=Math.min(P[J-1][q]+1,P[J][q-1]+1,P[J-1][q-1]+Q),J>1&&q>1&&$[J-1]===T[q-2]&&$[J-2]===T[q-1])P[J][q]=Math.min(P[J][q],P[J-2][q-2]+1)}return P[$.length][T.length]}function J1($,T){if(!T||T.length===0)return"";T=Array.from(new Set(T));let P=$.startsWith("--");if(P)$=$.slice(2),T=T.map((X)=>X.slice(2));let q=[],J=3,Q=0.4;if(T.forEach((X)=>{if(X.length<=1)return;let Z=q1($,X),H=Math.max($.length,X.length);if((H-Z)/H>Q){if(Z<J)J=Z,q=[X];else if(Z===J)q.push(X)}}),q.sort((X,Z)=>X.localeCompare(Z)),P)q=q.map((X)=>`--${X}`);if(q.length>1)return`
|
|
13
|
+
(Did you mean one of ${q.join(", ")}?)`;if(q.length===1)return`
|
|
14
|
+
(Did you mean ${q[0]}?)`;return""}Q1.suggestSimilar=J1});var x0=F((M1)=>{var U1=S("node:events").EventEmitter,e=S("node:child_process"),k=S("node:path"),l=S("node:fs"),M=S("node:process"),{Argument:Z1,humanReadableArgName:R1}=m(),{CommanderError:$0}=x(),{Help:H1,stripColor:z1}=a(),{Option:S0,DualOptions:Y1}=t(),{suggestSimilar:E0}=f0();class P0 extends U1{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(T)=>M.stdout.write(T),writeErr:(T)=>M.stderr.write(T),outputError:(T,P)=>P(T),getOutHelpWidth:()=>M.stdout.isTTY?M.stdout.columns:void 0,getErrHelpWidth:()=>M.stderr.isTTY?M.stderr.columns:void 0,getOutHasColors:()=>T0()??(M.stdout.isTTY&&M.stdout.hasColors?.()),getErrHasColors:()=>T0()??(M.stderr.isTTY&&M.stderr.hasColors?.()),stripColor:(T)=>z1(T)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let T=this;T;T=T.parent)$.push(T);return $}command($,T,P){let q=T,J=P;if(typeof q==="object"&&q!==null)J=q,q=null;J=J||{};let[,Q,X]=$.match(/([^ ]+) *(.*)/),Z=this.createCommand(Q);if(q)Z.description(q),Z._executableHandler=!0;if(J.isDefault)this._defaultCommandName=Z._name;if(Z._hidden=!!(J.noHelp||J.hidden),Z._executableFile=J.executableFile||null,X)Z.arguments(X);if(this._registerCommand(Z),Z.parent=this,Z.copyInheritedSettings(this),q)return this;return Z}createCommand($){return new P0($)}createHelp(){return Object.assign(new H1,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,T){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);if(T=T||{},T.isDefault)this._defaultCommandName=$._name;if(T.noHelp||T.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,T){return new Z1($,T)}argument($,T,P,q){let J=this.createArgument($,T);if(typeof P==="function")J.default(q).argParser(P);else J.default(P);return this.addArgument(J),this}arguments($){return $.trim().split(/ +/).forEach((T)=>{this.argument(T)}),this}addArgument($){let T=this.registeredArguments.slice(-1)[0];if(T?.variadic)throw Error(`only the last argument can be variadic '${T.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,T){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let P=$??"help [command]",[,q,J]=P.match(/([^ ]+) *(.*)/),Q=T??"display help for command",X=this.createCommand(q);if(X.helpOption(!1),J)X.arguments(J);if(Q)X.description(Q);if(this._addImplicitHelpCommand=!0,this._helpCommand=X,$||T)this._initCommandGroup(X);return this}addHelpCommand($,T){if(typeof $!=="object")return this.helpCommand($,T),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,T){let P=["preSubcommand","preAction","postAction"];if(!P.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
16
|
+
Expecting one of '${P.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(T);else this._lifeCycleHooks[$]=[T];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(T)=>{if(T.code!=="commander.executeSubCommandAsync")throw T};return this}_exit($,T,P){if(this._exitCallback)this._exitCallback(new $0($,T,P));M.exit($)}action($){let T=(P)=>{let q=this.registeredArguments.length,J=P.slice(0,q);if(this._storeOptionsAsProperties)J[q]=this;else J[q]=this.opts();return J.push(this),$.apply(this,J)};return this._actionHandler=T,this}createOption($,T){return new S0($,T)}_callParseArg($,T,P,q){try{return $.parseArg(T,P)}catch(J){if(J.code==="commander.invalidArgument"){let Q=`${q} ${J.message}`;this.error(Q,{exitCode:J.exitCode,code:J.code})}throw J}}_registerOption($){let T=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(T){let P=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${P}'
|
|
17
|
+
- already used by option '${T.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let T=(q)=>{return[q.name()].concat(q.aliases())},P=T($).find((q)=>this._findCommand(q));if(P){let q=T(this._findCommand(P)).join("|"),J=T($).join("|");throw Error(`cannot add command '${J}' as already have command '${q}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let T=$.name(),P=$.attributeName();if($.negate){let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource(P,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(P,$.defaultValue,"default");let q=(J,Q,X)=>{if(J==null&&$.presetArg!==void 0)J=$.presetArg;let Z=this.getOptionValue(P);if(J!==null&&$.parseArg)J=this._callParseArg($,J,Z,Q);else if(J!==null&&$.variadic)J=$._collectValue(J,Z);if(J==null)if($.negate)J=!1;else if($.isBoolean()||$.optional)J=!0;else J="";this.setOptionValueWithSource(P,J,X)};if(this.on("option:"+T,(J)=>{let Q=`error: option '${$.flags}' argument '${J}' is invalid.`;q(J,Q,"cli")}),$.envVar)this.on("optionEnv:"+T,(J)=>{let Q=`error: option '${$.flags}' value '${J}' from env '${$.envVar}' is invalid.`;q(J,Q,"env")});return this}_optionEx($,T,P,q,J){if(typeof T==="object"&&T instanceof S0)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Q=this.createOption(T,P);if(Q.makeOptionMandatory(!!$.mandatory),typeof q==="function")Q.default(J).argParser(q);else if(q instanceof RegExp){let X=q;q=(Z,H)=>{let U=X.exec(Z);return U?U[0]:H},Q.default(J).argParser(q)}else Q.default(q);return this.addOption(Q)}option($,T,P,q){return this._optionEx({},$,T,P,q)}requiredOption($,T,P,q){return this._optionEx({mandatory:!0},$,T,P,q)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,T){return this.setOptionValueWithSource($,T,void 0)}setOptionValueWithSource($,T,P){if(this._storeOptionsAsProperties)this[$]=T;else this._optionValues[$]=T;return this._optionValueSources[$]=P,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let T;return this._getCommandAndAncestors().forEach((P)=>{if(P.getOptionValueSource($)!==void 0)T=P.getOptionValueSource($)}),T}_prepareUserArgs($,T){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(T=T||{},$===void 0&&T.from===void 0){if(M.versions?.electron)T.from="electron";let q=M.execArgv??[];if(q.includes("-e")||q.includes("--eval")||q.includes("-p")||q.includes("--print"))T.from="eval"}if($===void 0)$=M.argv;this.rawArgs=$.slice();let P;switch(T.from){case void 0:case"node":this._scriptPath=$[1],P=$.slice(2);break;case"electron":if(M.defaultApp)this._scriptPath=$[1],P=$.slice(2);else P=$.slice(1);break;case"user":P=$.slice(0);break;case"eval":P=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${T.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",P}parse($,T){this._prepareForParse();let P=this._prepareUserArgs($,T);return this._parseCommand([],P),this}async parseAsync($,T){this._prepareForParse();let P=this._prepareUserArgs($,T);return await this._parseCommand([],P),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,T,P){if(l.existsSync($))return;let q=T?`searched for local subcommand relative to directory '${T}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",J=`'${$}' does not exist
|
|
19
|
+
- if '${P}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
+
- ${q}`;throw Error(J)}_executeSubCommand($,T){T=T.slice();let P=!1,q=[".js",".ts",".tsx",".mjs",".cjs"];function J(U,R){let z=k.resolve(U,R);if(l.existsSync(z))return z;if(q.includes(k.extname(R)))return;let K=q.find((W)=>l.existsSync(`${z}${W}`));if(K)return`${z}${K}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Q=$._executableFile||`${this._name}-${$._name}`,X=this._executableDir||"";if(this._scriptPath){let U;try{U=l.realpathSync(this._scriptPath)}catch{U=this._scriptPath}X=k.resolve(k.dirname(U),X)}if(X){let U=J(X,Q);if(!U&&!$._executableFile&&this._scriptPath){let R=k.basename(this._scriptPath,k.extname(this._scriptPath));if(R!==this._name)U=J(X,`${R}-${$._name}`)}Q=U||Q}P=q.includes(k.extname(Q));let Z;if(M.platform!=="win32")if(P)T.unshift(Q),T=C0(M.execArgv).concat(T),Z=e.spawn(M.argv[0],T,{stdio:"inherit"});else Z=e.spawn(Q,T,{stdio:"inherit"});else this._checkForMissingExecutable(Q,X,$._name),T.unshift(Q),T=C0(M.execArgv).concat(T),Z=e.spawn(M.execPath,T,{stdio:"inherit"});if(!Z.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((R)=>{M.on(R,()=>{if(Z.killed===!1&&Z.exitCode===null)Z.kill(R)})});let H=this._exitCallback;Z.on("close",(U)=>{if(U=U??1,!H)M.exit(U);else H(new $0(U,"commander.executeSubCommandAsync","(close)"))}),Z.on("error",(U)=>{if(U.code==="ENOENT")this._checkForMissingExecutable(Q,X,$._name);else if(U.code==="EACCES")throw Error(`'${Q}' not executable`);if(!H)M.exit(1);else{let R=new $0(1,"commander.executeSubCommandAsync","(error)");R.nestedError=U,H(R)}}),this.runningCommand=Z}_dispatchSubcommand($,T,P){let q=this._findCommand($);if(!q)this.help({error:!0});q._prepareForParse();let J;return J=this._chainOrCallSubCommandHook(J,q,"preSubcommand"),J=this._chainOrCall(J,()=>{if(q._executableHandler)this._executeSubCommand(q,T.concat(P));else return q._parseCommand(T,P)}),J}_dispatchHelpCommand($){if(!$)this.help();let T=this._findCommand($);if(T&&!T._executableHandler)T.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,T)=>{if($.required&&this.args[T]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(P,q,J)=>{let Q=q;if(q!==null&&P.parseArg){let X=`error: command-argument value '${q}' is invalid for argument '${P.name()}'.`;Q=this._callParseArg(P,q,J,X)}return Q};this._checkNumberOfArguments();let T=[];this.registeredArguments.forEach((P,q)=>{let J=P.defaultValue;if(P.variadic){if(q<this.args.length){if(J=this.args.slice(q),P.parseArg)J=J.reduce((Q,X)=>{return $(P,X,Q)},P.defaultValue)}else if(J===void 0)J=[]}else if(q<this.args.length){if(J=this.args[q],P.parseArg)J=$(P,J,P.defaultValue)}T[q]=J}),this.processedArgs=T}_chainOrCall($,T){if($?.then&&typeof $.then==="function")return $.then(()=>T());return T()}_chainOrCallHooks($,T){let P=$,q=[];if(this._getCommandAndAncestors().reverse().filter((J)=>J._lifeCycleHooks[T]!==void 0).forEach((J)=>{J._lifeCycleHooks[T].forEach((Q)=>{q.push({hookedCommand:J,callback:Q})})}),T==="postAction")q.reverse();return q.forEach((J)=>{P=this._chainOrCall(P,()=>{return J.callback(J.hookedCommand,this)})}),P}_chainOrCallSubCommandHook($,T,P){let q=$;if(this._lifeCycleHooks[P]!==void 0)this._lifeCycleHooks[P].forEach((J)=>{q=this._chainOrCall(q,()=>{return J(this,T)})});return q}_parseCommand($,T){let P=this.parseOptions(T);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(P.operands),T=P.unknown,this.args=$.concat(T),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),T);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(T),this._dispatchSubcommand(this._defaultCommandName,$,T);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(P.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let q=()=>{if(P.unknown.length>0)this.unknownOption(P.unknown[0])},J=`command:${this.name()}`;if(this._actionHandler){q(),this._processArguments();let Q;if(Q=this._chainOrCallHooks(Q,"preAction"),Q=this._chainOrCall(Q,()=>this._actionHandler(this.processedArgs)),this.parent)Q=this._chainOrCall(Q,()=>{this.parent.emit(J,$,T)});return Q=this._chainOrCallHooks(Q,"postAction"),Q}if(this.parent?.listenerCount(J))q(),this._processArguments(),this.parent.emit(J,$,T);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,T);if(this.listenerCount("command:*"))this.emit("command:*",$,T);else if(this.commands.length)this.unknownCommand();else q(),this._processArguments()}else if(this.commands.length)q(),this.help({error:!0});else q(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((T)=>T._name===$||T._aliases.includes($))}_findOption($){return this.options.find((T)=>T.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((T)=>{if(T.mandatory&&$.getOptionValue(T.attributeName())===void 0)$.missingMandatoryOptionValue(T)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((P)=>{let q=P.attributeName();if(this.getOptionValue(q)===void 0)return!1;return this.getOptionValueSource(q)!=="default"});$.filter((P)=>P.conflictsWith.length>0).forEach((P)=>{let q=$.find((J)=>P.conflictsWith.includes(J.attributeName()));if(q)this._conflictingOption(P,q)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let T=[],P=[],q=T;function J(U){return U.length>1&&U[0]==="-"}let Q=(U)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(U))return!1;return!this._getCommandAndAncestors().some((R)=>R.options.map((z)=>z.short).some((z)=>/^-\d$/.test(z)))},X=null,Z=null,H=0;while(H<$.length||Z){let U=Z??$[H++];if(Z=null,U==="--"){if(q===P)q.push(U);q.push(...$.slice(H));break}if(X&&(!J(U)||Q(U))){this.emit(`option:${X.name()}`,U);continue}if(X=null,J(U)){let R=this._findOption(U);if(R){if(R.required){let z=$[H++];if(z===void 0)this.optionMissingArgument(R);this.emit(`option:${R.name()}`,z)}else if(R.optional){let z=null;if(H<$.length&&(!J($[H])||Q($[H])))z=$[H++];this.emit(`option:${R.name()}`,z)}else this.emit(`option:${R.name()}`);X=R.variadic?R:null;continue}}if(U.length>2&&U[0]==="-"&&U[1]!=="-"){let R=this._findOption(`-${U[1]}`);if(R){if(R.required||R.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${R.name()}`,U.slice(2));else this.emit(`option:${R.name()}`),Z=`-${U.slice(2)}`;continue}}if(/^--[^=]+=/.test(U)){let R=U.indexOf("="),z=this._findOption(U.slice(0,R));if(z&&(z.required||z.optional)){this.emit(`option:${z.name()}`,U.slice(R+1));continue}}if(q===T&&J(U)&&!(this.commands.length===0&&Q(U)))q=P;if((this._enablePositionalOptions||this._passThroughOptions)&&T.length===0&&P.length===0){if(this._findCommand(U)){T.push(U),P.push(...$.slice(H));break}else if(this._getHelpCommand()&&U===this._getHelpCommand().name()){T.push(U,...$.slice(H));break}else if(this._defaultCommandName){P.push(U,...$.slice(H));break}}if(this._passThroughOptions){q.push(U,...$.slice(H));break}q.push(U)}return{operands:T,unknown:P}}opts(){if(this._storeOptionsAsProperties){let $={},T=this.options.length;for(let P=0;P<T;P++){let q=this.options[P].attributeName();$[q]=q===this._versionOptionName?this._version:this[q]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,T)=>Object.assign($,T.opts()),{})}error($,T){if(this._outputConfiguration.outputError(`${$}
|
|
22
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
|
+
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
24
|
+
`),this.outputHelp({error:!0});let P=T||{},q=P.exitCode||1,J=P.code||"commander.error";this._exit(q,J,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in M.env){let T=$.attributeName();if(this.getOptionValue(T)===void 0||["default","config","env"].includes(this.getOptionValueSource(T)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,M.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new Y1(this.options),T=(P)=>{return this.getOptionValue(P)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(P))};this.options.filter((P)=>P.implied!==void 0&&T(P.attributeName())&&$.valueFromOption(this.getOptionValue(P.attributeName()),P)).forEach((P)=>{Object.keys(P.implied).filter((q)=>!T(q)).forEach((q)=>{this.setOptionValueWithSource(q,P.implied[q],"implied")})})}missingArgument($){let T=`error: missing required argument '${$}'`;this.error(T,{code:"commander.missingArgument"})}optionMissingArgument($){let T=`error: option '${$.flags}' argument missing`;this.error(T,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let T=`error: required option '${$.flags}' not specified`;this.error(T,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,T){let P=(Q)=>{let X=Q.attributeName(),Z=this.getOptionValue(X),H=this.options.find((R)=>R.negate&&X===R.attributeName()),U=this.options.find((R)=>!R.negate&&X===R.attributeName());if(H&&(H.presetArg===void 0&&Z===!1||H.presetArg!==void 0&&Z===H.presetArg))return H;return U||Q},q=(Q)=>{let X=P(Q),Z=X.attributeName();if(this.getOptionValueSource(Z)==="env")return`environment variable '${X.envVar}'`;return`option '${X.flags}'`},J=`error: ${q($)} cannot be used with ${q(T)}`;this.error(J,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let T="";if($.startsWith("--")&&this._showSuggestionAfterError){let q=[],J=this;do{let Q=J.createHelp().visibleOptions(J).filter((X)=>X.long).map((X)=>X.long);q=q.concat(Q),J=J.parent}while(J&&!J._enablePositionalOptions);T=E0($,q)}let P=`error: unknown option '${$}'${T}`;this.error(P,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let T=this.registeredArguments.length,P=T===1?"":"s",J=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${T} argument${P} but got ${$.length}.`;this.error(J,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],T="";if(this._showSuggestionAfterError){let q=[];this.createHelp().visibleCommands(this).forEach((J)=>{if(q.push(J.name()),J.alias())q.push(J.alias())}),T=E0($,q)}let P=`error: unknown command '${$}'${T}`;this.error(P,{code:"commander.unknownCommand"})}version($,T,P){if($===void 0)return this._version;this._version=$,T=T||"-V, --version",P=P||"output the version number";let q=this.createOption(T,P);return this._versionOptionName=q.attributeName(),this._registerOption(q),this.on("option:"+q.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
25
|
+
`),this._exit(0,"commander.version",$)}),this}description($,T){if($===void 0&&T===void 0)return this._description;if(this._description=$,T)this._argsDescription=T;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let T=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)T=this.commands[this.commands.length-1];if($===T._name)throw Error("Command alias can't be the same as its name");let P=this.parent?._findCommand($);if(P){let q=[P.name()].concat(P.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${q}'`)}return T._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((T)=>this.alias(T)),this}usage($){if($===void 0){if(this._usage)return this._usage;let T=this.registeredArguments.map((P)=>{return R1(P)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?T:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=k.basename($,k.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let T=this.createHelp(),P=this._getOutputContext($);T.prepareContext({error:P.error,helpWidth:P.helpWidth,outputHasColors:P.hasColors});let q=T.formatHelp(this,T);if(P.hasColors)return q;return this._outputConfiguration.stripColor(q)}_getOutputContext($){$=$||{};let T=!!$.error,P,q,J;if(T)P=(X)=>this._outputConfiguration.writeErr(X),q=this._outputConfiguration.getErrHasColors(),J=this._outputConfiguration.getErrHelpWidth();else P=(X)=>this._outputConfiguration.writeOut(X),q=this._outputConfiguration.getOutHasColors(),J=this._outputConfiguration.getOutHelpWidth();return{error:T,write:(X)=>{if(!q)X=this._outputConfiguration.stripColor(X);return P(X)},hasColors:q,helpWidth:J}}outputHelp($){let T;if(typeof $==="function")T=$,$=void 0;let P=this._getOutputContext($),q={error:P.error,write:P.write,command:this};this._getCommandAndAncestors().reverse().forEach((Q)=>Q.emit("beforeAllHelp",q)),this.emit("beforeHelp",q);let J=this.helpInformation({error:P.error});if(T){if(J=T(J),typeof J!=="string"&&!Buffer.isBuffer(J))throw Error("outputHelp callback must return a string or a Buffer")}if(P.write(J),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",q),this._getCommandAndAncestors().forEach((Q)=>Q.emit("afterAllHelp",q))}helpOption($,T){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",T??"display help for command"),$||T)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let T=Number(M.exitCode??0);if(T===0&&$&&typeof $!=="function"&&$.error)T=1;this._exit(T,"commander.help","(outputHelp)")}addHelpText($,T){let P=["beforeAll","before","after","afterAll"];if(!P.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${P.join("', '")}'`);let q=`${$}Help`;return this.on(q,(J)=>{let Q;if(typeof T==="function")Q=T({error:J.error,command:J.command});else Q=T;if(Q)J.write(`${Q}
|
|
27
|
+
`)}),this}_outputHelpIfRequested($){let T=this._getHelpOption();if(T&&$.find((q)=>T.is(q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function C0($){return $.map((T)=>{if(!T.startsWith("--inspect"))return T;let P,q="127.0.0.1",J="9229",Q;if((Q=T.match(/^(--inspect(-brk)?)$/))!==null)P=Q[1];else if((Q=T.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(P=Q[1],/^\d+$/.test(Q[3]))J=Q[3];else q=Q[3];else if((Q=T.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)P=Q[1],q=Q[3],J=Q[4];if(P&&J!=="0")return`${P}=${q}:${parseInt(J)+1}`;return T})}function T0(){if(M.env.NO_COLOR||M.env.FORCE_COLOR==="0"||M.env.FORCE_COLOR==="false")return!1;if(M.env.FORCE_COLOR||M.env.CLICOLOR_FORCE!==void 0)return!0;return}M1.Command=P0;M1.useColor=T0});var u0=F((L1)=>{var{Argument:b0}=m(),{Command:q0}=x0(),{CommanderError:B1,InvalidArgumentError:h0}=x(),{Help:W1}=a(),{Option:v0}=t();L1.program=new q0;L1.createCommand=($)=>new q0($);L1.createOption=($,T)=>new v0($,T);L1.createArgument=($,T)=>new b0($,T);L1.Command=q0;L1.Option=v0;L1.Argument=b0;L1.Help=W1;L1.CommanderError=B1;L1.InvalidArgumentError=h0;L1.InvalidOptionArgumentError=h0});var M0=($=0)=>(T)=>`\x1B[${T+$}m`,K0=($=0)=>(T)=>`\x1B[${38+$};5;${T}m`,_0=($=0)=>(T,P,q)=>`\x1B[${38+$};2;${T};${P};${q}m`,_={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},X4=Object.keys(_.modifier),k2=Object.keys(_.color),F2=Object.keys(_.bgColor),U4=[...k2,...F2];function V2(){let $=new Map;for(let[T,P]of Object.entries(_)){for(let[q,J]of Object.entries(P))_[q]={open:`\x1B[${J[0]}m`,close:`\x1B[${J[1]}m`},P[q]=_[q],$.set(J[0],J[1]);Object.defineProperty(_,T,{value:P,enumerable:!1})}return Object.defineProperty(_,"codes",{value:$,enumerable:!1}),_.color.close="\x1B[39m",_.bgColor.close="\x1B[49m",_.color.ansi=M0(),_.color.ansi256=K0(),_.color.ansi16m=_0(),_.bgColor.ansi=M0(10),_.bgColor.ansi256=K0(10),_.bgColor.ansi16m=_0(10),Object.defineProperties(_,{rgbToAnsi256:{value(T,P,q){if(T===P&&P===q){if(T<8)return 16;if(T>248)return 231;return Math.round((T-8)/247*24)+232}return 16+36*Math.round(T/255*5)+6*Math.round(P/255*5)+Math.round(q/255*5)},enumerable:!1},hexToRgb:{value(T){let P=/[a-f\d]{6}|[a-f\d]{3}/i.exec(T.toString(16));if(!P)return[0,0,0];let[q]=P;if(q.length===3)q=[...q].map((Q)=>Q+Q).join("");let J=Number.parseInt(q,16);return[J>>16&255,J>>8&255,J&255]},enumerable:!1},hexToAnsi256:{value:(T)=>_.rgbToAnsi256(..._.hexToRgb(T)),enumerable:!1},ansi256ToAnsi:{value(T){if(T<8)return 30+T;if(T<16)return 90+(T-8);let P,q,J;if(T>=232)P=((T-232)*10+8)/255,q=P,J=P;else{T-=16;let Z=T%36;P=Math.floor(T/36)/5,q=Math.floor(Z/6)/5,J=Z%6/5}let Q=Math.max(P,q,J)*2;if(Q===0)return 30;let X=30+(Math.round(J)<<2|Math.round(q)<<1|Math.round(P));if(Q===2)X+=60;return X},enumerable:!1},rgbToAnsi:{value:(T,P,q)=>_.ansi256ToAnsi(_.rgbToAnsi256(T,P,q)),enumerable:!1},hexToAnsi:{value:(T)=>_.ansi256ToAnsi(_.hexToAnsi256(T)),enumerable:!1}}),_}var O2=V2(),w=O2;import p from"node:process";import y2 from"node:os";import B0 from"node:tty";function D($,T=globalThis.Deno?globalThis.Deno.args:p.argv){let P=$.startsWith("-")?"":$.length===1?"-":"--",q=T.indexOf(P+$),J=T.indexOf("--");return q!==-1&&(J===-1||q<J)}var{env:B}=p,c;if(D("no-color")||D("no-colors")||D("color=false")||D("color=never"))c=0;else if(D("color")||D("colors")||D("color=true")||D("color=always"))c=1;function A2(){if("FORCE_COLOR"in B){if(B.FORCE_COLOR==="true")return 1;if(B.FORCE_COLOR==="false")return 0;return B.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(B.FORCE_COLOR,10),3)}}function f2($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function S2($,{streamIsTTY:T,sniffFlags:P=!0}={}){let q=A2();if(q!==void 0)c=q;let J=P?c:q;if(J===0)return 0;if(P){if(D("color=16m")||D("color=full")||D("color=truecolor"))return 3;if(D("color=256"))return 2}if("TF_BUILD"in B&&"AGENT_NAME"in B)return 1;if($&&!T&&J===void 0)return 0;let Q=J||0;if(B.TERM==="dumb")return Q;if(p.platform==="win32"){let X=y2.release().split(".");if(Number(X[0])>=10&&Number(X[2])>=10586)return Number(X[2])>=14931?3:2;return 1}if("CI"in B){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((X)=>(X in B)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((X)=>(X in B))||B.CI_NAME==="codeship")return 1;return Q}if("TEAMCITY_VERSION"in B)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(B.TEAMCITY_VERSION)?1:0;if(B.COLORTERM==="truecolor")return 3;if(B.TERM==="xterm-kitty")return 3;if(B.TERM==="xterm-ghostty")return 3;if(B.TERM==="wezterm")return 3;if("TERM_PROGRAM"in B){let X=Number.parseInt((B.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(B.TERM_PROGRAM){case"iTerm.app":return X>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(B.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(B.TERM))return 1;if("COLORTERM"in B)return 1;return Q}function W0($,T={}){let P=S2($,{streamIsTTY:$&&$.isTTY,...T});return f2(P)}var E2={stdout:W0({isTTY:B0.isatty(1)}),stderr:W0({isTTY:B0.isatty(2)})},L0=E2;function j0($,T,P){let q=$.indexOf(T);if(q===-1)return $;let J=T.length,Q=0,X="";do X+=$.slice(Q,q)+T+P,Q=q+J,q=$.indexOf(T,Q);while(q!==-1);return X+=$.slice(Q),X}function I0($,T,P,q){let J=0,Q="";do{let X=$[q-1]==="\r";Q+=$.slice(J,X?q-1:q)+T+(X?`\r
|
|
28
|
+
`:`
|
|
29
|
+
`)+P,J=q+1,q=$.indexOf(`
|
|
30
|
+
`,J)}while(q!==-1);return Q+=$.slice(J),Q}var{stdout:G0,stderr:D0}=L0,o=Symbol("GENERATOR"),V=Symbol("STYLER"),E=Symbol("IS_EMPTY"),w0=["ansi","ansi","ansi256","ansi16m"],O=Object.create(null),C2=($,T={})=>{if(T.level&&!(Number.isInteger(T.level)&&T.level>=0&&T.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let P=G0?G0.level:0;$.level=T.level===void 0?P:T.level};var x2=($)=>{let T=(...P)=>P.join(" ");return C2(T,$),Object.setPrototypeOf(T,C.prototype),T};function C($){return x2($)}Object.setPrototypeOf(C.prototype,Function.prototype);for(let[$,T]of Object.entries(w))O[$]={get(){let P=g(this,s(T.open,T.close,this[V]),this[E]);return Object.defineProperty(this,$,{value:P}),P}};O.visible={get(){let $=g(this,this[V],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var n=($,T,P,...q)=>{if($==="rgb"){if(T==="ansi16m")return w[P].ansi16m(...q);if(T==="ansi256")return w[P].ansi256(w.rgbToAnsi256(...q));return w[P].ansi(w.rgbToAnsi(...q))}if($==="hex")return n("rgb",T,P,...w.hexToRgb(...q));return w[P][$](...q)},b2=["rgb","hex","ansi256"];for(let $ of b2){O[$]={get(){let{level:P}=this;return function(...q){let J=s(n($,w0[P],"color",...q),w.color.close,this[V]);return g(this,J,this[E])}}};let T="bg"+$[0].toUpperCase()+$.slice(1);O[T]={get(){let{level:P}=this;return function(...q){let J=s(n($,w0[P],"bgColor",...q),w.bgColor.close,this[V]);return g(this,J,this[E])}}}}var h2=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[o].level},set($){this[o].level=$}}}),s=($,T,P)=>{let q,J;if(P===void 0)q=$,J=T;else q=P.openAll+$,J=T+P.closeAll;return{open:$,close:T,openAll:q,closeAll:J,parent:P}},g=($,T,P)=>{let q=(...J)=>v2(q,J.length===1?""+J[0]:J.join(" "));return Object.setPrototypeOf(q,h2),q[o]=$,q[V]=T,q[E]=P,q},v2=($,T)=>{if($.level<=0||!T)return $[E]?"":T;let P=$[V];if(P===void 0)return T;let{openAll:q,closeAll:J}=P;if(T.includes("\x1B"))while(P!==void 0)T=j0(T,P.close,P.open),P=P.parent;let Q=T.indexOf(`
|
|
31
|
+
`);if(Q!==-1)T=I0(T,J,q,Q);return q+T+J};Object.defineProperties(C.prototype,O);var u2=C(),W4=C({level:D0?D0.level:0});var Y=u2;var c0=w2(u0(),1),{program:F4,createCommand:V4,createArgument:O4,createOption:y4,CommanderError:A4,InvalidArgumentError:f4,InvalidOptionArgumentError:S4,Command:g0,Argument:E4,Option:N,Help:C4}=c0.default;import{existsSync as s1}from"node:fs";import{appendFile as r1,readFile as a1}from"node:fs/promises";var A1=70,f1=10;function S1($){let T=(Date.now()-$)/1000;return T<60?`${T.toFixed(1)}s`:`${Math.floor(T/60)}m ${Math.floor(T%60)}s`}function E1($,T,P=26){let q=T?Math.round(P*$/T):0;return Y.green("โ".repeat(q))+Y.dim("โ".repeat(P-q))}function C1($,T){return T?`${Math.round(100*$/T)}%`:"0%"}function J0($){return $?Y.green("โ"):Y.red("โ")}function Q0(){return Y.bold.cyan("โ".repeat(A1))}function y($,T=!1){let P=T?"Final Summary":"Live Summary",{doneIps:q,totalIps:J}=$,Q=globalThis.config.ping?` ${Y.blue("IPs ")} found ${Y.bold(J)} ${Y.green(`ping-up ${$.pingUp}`)} ${Y.red(`down ${J-$.pingUp}`)}`:` ${Y.blue("IPs ")} found ${Y.bold(J)}`,X=globalThis.config.curl?` ${Y.blue("HTTPS ")} ${Y.green(`โ ok ${$.curlOk}`)} ${Y.red(`โ fail ${$.pingUp-$.curlOk}`)}`:` ${Y.blue("HTTPS ")} ${Y.dim("skipped (use --curl)")}`;return[Q0(),` ${Y.bold.cyan(P)}`,Q0(),` ${Y.blue("Progress")} ${E1(q,J)} ${Y.cyan(`${q}/${J} IPs`)} ${Y.dim(`${C1(q,J)} ${S1($.startTime)}`)}`,` ${Y.blue("Hosts ")} total ${Y.bold($.totalHosts)} done ${Y.bold($.doneHosts)} dns-fail ${Y.red($.dnsFail)}`,Q,` ${Y.blue("Port 443")} ${Y.green(`โ open ${$.port443Ok}`)} ${Y.red(`โ closed ${J-$.port443Ok}`)}`,X,Q0(),""].join(`
|
|
32
|
+
`)}function m0($){let T=$.curlOk?Y.green:Y.red,P=$.curlInfo?` ${Y.dim($.curlInfo)}`:"",q=globalThis.config.ping?` ping ${J0($.pingOk)}`:"",J=globalThis.config.curl?$.curlHttp?` curl ${J0($.curlOk)} HTTP ${T($.curlHttp)}${P}`:` ${Y.dim("curl n/a")}`:"";return` ${Y.cyan($.ip.padEnd(20))} ${Y.white($.host.padEnd(20))} ${Y.dim($.provider.padEnd(10))}`+q+` 443 ${J0($.port443Ok)}`+J}function b(){process.stdout.write(`\x1B[${f1}A\x1B[J`)}function l0($,T){console.log(Y.dim(`Checking ${Y.bold($)} host(s) ยท mode=${Y.bold(T)} ยท results appear above the summary
|
|
33
|
+
`))}function d0($){process.stdout.write(`${y($)}
|
|
34
|
+
`)}function x1($){for(let T=0;T<$.length;T++){let P=$.charCodeAt(T);if(P===58)return 6;if(P===46)return 4}return 0}var G=[0,0,0,0,0,0,0,0],h=[0,0,0,0,0,0,0,0],b1=[0n,112n,96n,80n,64n,48n,32n,16n],h1=Array(256),v1=Array(256);for(let $=0;$<256;$++)h1[$]=$.toString(16),v1[$]=$.toString(16).padStart(2,"0");var A=new DataView(new ArrayBuffer(16));function i0($,T){let P=0n,q=0;for(;q+1<T;q+=2)P=P<<32n|BigInt(($[q]<<16|$[q+1])>>>0);if(q<T)P=P<<16n|BigInt($[q]);return P}function p0($){let T=x1($);if(!T)throw Error(`Invalid IP address: ${$}`);if(T===4){let I=0,L=0;for(let i=0;i<$.length;i++){let z0=$.charCodeAt(i);if(z0===46)I=I*256+L,L=0;else L=L*10+z0-48}return{number:BigInt(I*256+L),version:4}}let P,q,J=0,Q=0,X=!1,Z=0,H=0,U=!1,R=!1,z=0;for(let I=0;I<$.length;I++){let L=$.charCodeAt(I);if(L===58){if(U){if(X)h[Q++]=Z;else G[J++]=Z;Z=0,H=0,U=!1}if(I+1<$.length&&$.charCodeAt(I+1)===58)X=!0,I++}else if(L===46){if(!R)R=!0,z=H;else z=z*256+H;Z=0,H=0,U=!1}else if(L===37){q=$.slice(I+1);break}else{if(R)H=H*10+L-48;else if(L<=57)Z=Z<<4|L-48,H=H*10+L-48;else if(L>=97)Z=Z<<4|L-87;else Z=Z<<4|L-55;U=!0}}if(R)if(z=z*256+H,X)h[Q++]=z>>>16&65535,h[Q++]=z&65535;else G[J++]=z>>>16&65535,G[J++]=z&65535;else if(U)if(X)h[Q++]=Z;else G[J++]=Z;let K;if(!X)A.setUint32(0,(G[0]<<16|G[1])>>>0,!1),A.setUint32(4,(G[2]<<16|G[3])>>>0,!1),A.setUint32(8,(G[4]<<16|G[5])>>>0,!1),A.setUint32(12,(G[6]<<16|G[7])>>>0,!1),K=A.getBigUint64(0,!1)<<64n|A.getBigUint64(8,!1);else{let I=i0(h,Q);if(J>0)K=i0(G,J)<<b1[J]|I;else K=I}if(R&&K>=281470681743360n&&K<=281474976710655n)P=!0;let W={number:K,version:6};if(P)W.ipv4mapped=P;if(q)W.scopeid=q;return W}var o0={4:32,6:128},m4=Array.from({length:256},($,T)=>String(T)),l4=Array.from({length:256},($,T)=>`${T}.`),d4=Array.from({length:129},($,T)=>`/${T}`);var u1=($,T)=>$.start-T.start;var c1=($,T)=>$.start>T.start?1:$.start<T.start?-1:0;function g1($,T){let P=0,q=0,J=0,Q=0;for(let X=0;X<T;X++){let Z=$.charCodeAt(X);if(Z===46){if(Q===0||q>255)return-1;P=P<<8|q,q=0,J++,Q=0}else if(Z>=48&&Z<=57)q=q*10+(Z-48),Q++;else return-1}if(J!==3||Q===0||q>255)return-1;return(P<<8|q)>>>0}function s0($,T){if(T===-1)return-1;if(T+1>=$.length)throw Error(`Network is not a CIDR or IP: "${$}"`);let P=0;for(let q=T+1;q<$.length;q++){let J=$.charCodeAt(q);if(J<48||J>57)throw Error(`Network is not a CIDR or IP: "${$}"`);P=P*10+(J-48)}return P}var v=0,u=0,n0=0,f=-1;function X0($){f=$.indexOf("/");let T=g1($,f!==-1?f:$.length);if(T===-1)return!1;n0=f!==-1?s0($,f):32;let P=32-n0;if(P>=32)v=0,u=4294967295;else{let q=P>0?(1<<P>>>0)-1:0;v=(T&~q)>>>0,u=(T|q)>>>0}return!0}function d($){if(X0($))return{start:v,end:u,version:4};let T=f,P=T!==-1?$.substring(0,T):$,q=T!==-1?s0($,T):-1,{number:J,version:Q}=p0(P);if(!Q)throw Error(`Network is not a CIDR or IP: "${$}"`);if(q===-1)q=o0[Q];let X=o0[Q]-q;if(Q===4){let H=Number(J);if(X>=32)return{start:0,end:4294967295,version:4};let U=X>0?(1<<X>>>0)-1:0;return{start:(H&~U)>>>0,end:(H|U)>>>0,version:4}}let Z=X>0?(1n<<BigInt(X))-1n:0n;return{start:J&~Z,end:J|Z,version:6}}function r0($,T){if(!Array.isArray($)&&!Array.isArray(T)){if(X0($)){let R=v,z=u;if(X0(T))return R<=v&&z>=u}let H=d($),U=d(T);if(H.version!==U.version)return!1;return H.start<=U.start&&H.end>=U.end}let P=Array.isArray($)?$:[$],q=Array.isArray(T)?T:[T],J=[],Q=[],X=[],Z=[];for(let H of P){let U=d(H);if(U.version===4)J.push(U);else Q.push(U)}for(let H of q){let U=d(H);if(U.version===4)X.push(U);else Z.push(U)}if(X.length>0){if(J.length===0)return!1;if(X.length===1){let H=X[0].start,U=X[0].end,R=!1;for(let z of J)if(z.start<=H&&z.end>=U){R=!0;break}if(!R)return!1}else{J.sort(u1);let H=Array(J.length);H[0]=J[0].end;for(let U=1;U<J.length;U++)H[U]=Math.max(J[U].end,H[U-1]);for(let U of X){let R=0,z=J.length-1,K=-1;while(R<=z){let W=R+z>>1;if(J[W].start<=U.start)K=W,R=W+1;else z=W-1}if(K<0||H[K]<U.end)return!1}}}if(Z.length>0){if(Q.length===0)return!1;if(Z.length===1){let H=Z[0].start,U=Z[0].end,R=!1;for(let z of Q)if(z.start<=H&&z.end>=U){R=!0;break}if(!R)return!1}else{Q.sort(c1);let H=Array(Q.length);H[0]=Q[0].end;for(let U=1;U<Q.length;U++)H[U]=Q[U].end>H[U-1]?Q[U].end:H[U-1];for(let U of Z){let R=0,z=Q.length-1,K=-1;while(R<=z){let W=R+z>>1;if(Q[W].start<=U.start)K=W,R=W+1;else z=W-1}if(K<0||H[K]<U.end)return!1}}}return!0}var a0={Cloudflare:["104.16.0.0/20","104.16.16.0/20","104.16.32.0/20","104.16.48.0/20","104.16.64.0/20","104.16.80.0/20","104.16.96.0/20","104.16.112.0/20","104.16.128.0/20","104.16.144.0/20","104.16.160.0/20","104.16.176.0/20","104.16.192.0/20","104.16.208.0/20","104.16.224.0/20","104.16.240.0/20","104.17.0.0/20","104.17.16.0/20","104.17.32.0/20","104.17.48.0/20","104.17.64.0/20","104.17.80.0/20","104.17.96.0/20","104.17.112.0/20","104.17.128.0/20","104.17.144.0/20","104.17.160.0/20","104.17.176.0/20","104.17.192.0/20","104.17.208.0/20","104.17.224.0/20","104.17.240.0/20","104.18.0.0/20","104.18.16.0/20","104.18.32.0/20","104.18.64.0/20","104.18.80.0/20","104.18.96.0/20","104.18.112.0/20","104.18.128.0/20","104.18.144.0/20","104.18.160.0/20","104.18.176.0/20","104.18.192.0/20","104.18.208.0/20","104.18.224.0/20","104.18.240.0/20","104.19.0.0/20","104.19.16.0/20","104.19.32.0/20","104.19.48.0/20","104.19.64.0/20","104.19.80.0/20","104.19.96.0/20","104.19.112.0/20","104.19.128.0/20","104.19.144.0/20","104.19.160.0/20","104.19.176.0/20","104.19.192.0/20","104.19.208.0/20","104.19.224.0/20","104.19.240.0/20","104.20.0.0/20","104.20.16.0/20","104.20.32.0/20","104.20.48.0/20","104.21.0.0/20","104.21.16.0/20","104.21.32.0/20","104.21.48.0/20","104.21.64.0/20","104.21.80.0/20","104.21.96.0/20","104.21.112.0/20","104.21.192.0/20","104.21.208.0/20","104.21.224.0/20","104.24.0.0/20","104.24.16.0/20","104.24.32.0/20","104.24.48.0/20","104.24.64.0/20","104.24.80.0/20","104.24.128.0/20","104.24.144.0/20","104.24.160.0/20","104.24.176.0/20","104.24.192.0/20","104.24.208.0/20","104.24.224.0/20","104.24.240.0/20","104.25.0.0/20","104.25.16.0/20","104.25.32.0/20","104.25.48.0/20","104.25.64.0/20","104.25.80.0/20","104.25.96.0/20","104.25.112.0/20","104.25.128.0/20","104.25.144.0/20","104.25.160.0/20","104.25.176.0/20","104.25.192.0/20","104.25.208.0/20","104.25.224.0/20","104.25.240.0/20","104.26.0.0/20","104.27.0.0/20","104.27.16.0/20","104.27.32.0/20","104.27.48.0/20","104.27.64.0/20","104.27.80.0/20","104.27.96.0/20","104.27.112.0/20","104.27.192.0/20","104.28.0.0/20","104.28.16.0/20","104.28.32.0/20","104.28.48.0/20","104.28.64.0/20","104.28.80.0/20","104.28.96.0/20","104.28.112.0/20","104.28.128.0/20","104.28.144.0/20","104.28.160.0/20","104.28.176.0/20","104.28.192.0/20","104.28.208.0/20","104.28.224.0/20","104.28.240.0/20","104.30.0.0/22","104.30.4.0/22","104.30.8.0/22","104.30.12.0/22","104.30.16.0/20","104.30.32.0/23","104.30.128.0/23","104.30.144.0/21","104.30.160.0/20","104.30.176.0/20","104.31.0.0/21","104.31.16.0/23","108.162.192.0/20","141.101.76.0/23","141.101.112.0/20","141.101.114.0/23","141.101.120.0/22","162.158.0.0/22","162.158.16.0/22","162.158.20.0/22","162.158.24.0/23","162.158.76.0/22","162.158.84.0/22","162.158.180.0/22","162.158.208.0/22","162.158.226.0/23","162.158.234.0/23","162.158.240.0/22","162.158.250.0/23","162.159.0.0/20","162.159.16.0/20","162.159.32.0/23","162.159.34.0/23","162.159.40.0/23","162.159.42.0/23","162.159.48.0/20","162.159.64.0/20","162.159.128.0/19","162.159.192.0/22","162.159.240.0/20","172.64.32.0/20","172.64.36.0/23","172.64.48.0/20","172.64.80.0/20","172.64.100.0/23","172.64.240.0/20","172.65.0.0/19","172.65.0.0/20","172.65.16.0/20","172.65.32.0/20","172.65.48.0/20","172.65.64.0/20","172.65.80.0/20","172.65.96.0/20","172.65.112.0/20","172.65.128.0/20","172.65.144.0/20","172.65.160.0/20","172.65.176.0/20","172.65.192.0/20","172.65.208.0/20","172.65.224.0/20","172.65.240.0/20","172.66.0.0/22","172.66.40.0/21","172.66.128.0/20","172.66.144.0/20","172.66.160.0/20","172.66.192.0/20","172.66.208.0/21","172.67.64.0/20","172.67.80.0/20","172.67.96.0/20","172.67.112.0/20","172.67.128.0/20","172.67.144.0/20","172.67.160.0/20","172.67.176.0/20","172.67.192.0/20","172.67.208.0/20","172.67.224.0/20","172.67.240.0/20","172.68.60.0/22","172.68.72.0/23","172.68.180.0/22","173.245.60.0/23","188.114.106.0/23","190.93.240.0/20","190.93.244.0/22","198.41.132.0/22","198.41.136.0/22","198.41.192.0/21","198.41.200.0/21","198.41.208.0/23","198.41.214.0/23","199.27.128.0/22","199.27.134.0/23","static.cloudflareinsights.com","cloudflare.com"],"Amazon AWS":["amazonaws.com","52.94.198.0/24","13.32.0.0/11","3.128.0.0/11","18.160.0.0/11","52.0.0.0/8"],Google:["google.com","cloud.google.com","34.64.0.0/11","35.184.0.0/13","130.211.0.0/16"],"Microsoft Azure":["microsoft.com","azure.microsoft.com","13.64.0.0/11","40.64.0.0/10"],"Major Ranges":["1.0.0.0/24","1.1.1.0/24","8.6.112.0/24","8.6.144.0/24","8.6.145.0/24","23.227.38.0/23","23.227.42.0/23","23.227.48.0/23","45.250.152.0/22","49.238.236.0/22","103.219.64.0/22","131.0.72.0/22","150.48.128.0/18","152.114.0.0/17","152.114.128.0/18","203.168.192.0/20","204.195.192.0/18","222.167.32.0/22"]};function t0($){let T=$.replace(/["'\s]/g,"").trim();if(T=T.replace(/[?&].*$/,""),/^[\d.]+\/\d+$/.test(T))return T;let P=T.match(/(?:https?:\/\/)?([a-zA-Z0-9._\-:/]+)/);return P?P[1]:T}function e0($){if(!$.includes("/"))return!1;try{let[T,P]=$.split("/"),q=T.split(".").map(Number);if(q.length!==4||q.some((Q)=>Number.isNaN(Q)||Q<0||Q>255))return!1;let J=parseInt(P,10);return!Number.isNaN(J)&&J>=0&&J<=32}catch{return!1}}function $2($){for(let[T,P]of Object.entries(a0))if(r0(P,$))return T;return"Unknown"}function T2($){let[T,P]=$.split("/"),q=parseInt(P,10),J=T.split(".").map(Number),Q=(J[0]<<24|J[1]<<16|J[2]<<8|J[3])>>>0,X=q===0?0:-1<<32-q>>>0,Z=(Q&X)>>>0,H=(Z|~X>>>0)>>>0,U=[],R=q>=31?Z:Z+1,z=q>=31?H:H-1;for(let K=R;K<=z;K++)U.push(`${K>>>24&255}.${K>>>16&255}.${K>>>8&255}.${K&255}`);return U}import{appendFile as m1,readFile as a4,writeFile as t4}from"node:fs/promises";async function P2($,T){await m1($,T,"utf-8")}class U0{queue=[];locked=!1;async run($){await this.lock();try{return await $()}finally{this.unlock()}}lock(){if(!this.locked)return this.locked=!0,Promise.resolve();return new Promise(($)=>this.queue.push($))}unlock(){let $=this.queue.shift();if($)$();else this.locked=!1}}import l1 from"node:dns/promises";import{exec as d1}from"node:child_process";import*as q2 from"node:net";import{promisify as i1}from"node:util";var p1=i1(d1);async function Z0($,T){try{let{stdout:P,stderr:q}=await Promise.race([p1($,{timeout:T}),new Promise((J,Q)=>setTimeout(()=>Q(Error("timeout")),T))]);return{code:0,stdout:P,stderr:q}}catch(P){let q=P;return{code:q.code??-1,stdout:q.stdout??"",stderr:q.stderr??"timeout"}}}async function J2($,T){let P=new l1.Resolver;P.setServers([T]);try{let[q,J]=await Promise.allSettled([P.resolve4($),P.resolve6($)]),Q=[];if(q.status==="fulfilled")Q.push(...q.value);if(J.status==="fulfilled")Q.push(...J.value);return Q.map((X)=>X.trim()).filter(Boolean)}catch{return[]}}async function Q2($){let T=globalThis.config.timeout*globalThis.config.pingCount+5,{code:P}=await Z0(`ping -c ${globalThis.config.pingCount} -W ${globalThis.config.timeout} ${$}`,T*1000);return P===0}async function X2($,T){return new Promise((P)=>{let q=new q2.Socket,J=setTimeout(()=>{q.destroy(),P(!1)},T*1000);q.connect(443,$,()=>{clearTimeout(J),q.destroy(),P(!0)}).on("error",()=>{clearTimeout(J),P(!1)})})}function U2($,T){let P=$.trim(),q=T.split(`
|
|
35
|
+
`).find((Q)=>Q.includes("Connected to")||Q.includes("SSL connection"))?.trim().replace(/^\*\s*/,"")??"";return{ok:/^[23]/.test(P),code:P,info:q}}async function Z2($,T,P){let{code:q,stdout:J,stderr:Q}=await Z0(`curl -kv -s -o /dev/null --write-out "%{http_code}" --max-time ${P} https://${$} --connect-to ${$}:443:${T}`,(P+5)*1000),X=U2(J,Q);return{...X,ok:q===0&&X.ok}}async function R2($,T){let{code:P,stdout:q,stderr:J}=await Z0(`curl -kv -s -o /dev/null --write-out "%{http_code}" --max-time ${T} http://${$}`,(T+5)*1000),Q=U2(q,J);return{...Q,ok:P===0&&Q.ok}}var j={totalHosts:0,doneHosts:0,totalIps:0,doneIps:0,pingUp:0,port443Ok:0,curlOk:0,dnsFail:0,startTime:Date.now()};var H2=($)=>{return`[${$.host}] ${$.ip} ${$.provider}
|
|
36
|
+
`},z2=($)=>{return`[${$.host}] ${$.ip} ${$.provider} Port=443
|
|
37
|
+
`};var M2=new U0;async function Y2($,T,P,q){if(!q)return;let J=P($);await P2(T,J)}async function o1($){if(!globalThis.config.verbose&&!$.pingOk&&!$.port443Ok)return;await M2.run(async()=>{b(),process.stdout.write(`${m0($)}
|
|
38
|
+
`),process.stdout.write(`${y(j)}
|
|
39
|
+
`)})}async function R0(){await M2.run(async()=>{b(),process.stdout.write(`${y(j)}
|
|
40
|
+
`)})}async function n1($,T,P,q){let J={host:T,ip:$,provider:$2($),pingOk:!1,port443Ok:!1,curlOk:!1,curlHttp:"",curlInfo:""};if(globalThis.config.ping){if(J.pingOk=await q.run(()=>Q2($)),J.pingOk)j.pingUp++;await Y2(J,globalThis.config.outputPing,H2,J.pingOk)}if(J.port443Ok=await q.run(()=>X2($,globalThis.config.timeout)),J.port443Ok)j.port443Ok++;if(await Y2(J,globalThis.config.outputPorts,z2,J.port443Ok),globalThis.config.curl){let Q=await q.run(()=>P?R2($,globalThis.config.timeout):Z2(T,$,globalThis.config.timeout));if(J.curlOk=Q.ok,J.curlHttp=Q.code,J.curlInfo=Q.info,J.curlOk)j.curlOk++}return j.doneIps++,await o1(J),J}async function K2($,T){let P={host:$,ips:[],digErr:""},q=e0($),J=q?T2($):await T.run(()=>J2($,globalThis.config.resolver));if(!J.length)return P.digErr=q?"invalid CIDR":"no IPs resolved",j.doneHosts++,j.dnsFail++,await R0(),P;return j.totalIps+=J.length,await R0(),P.ips=await Promise.all(J.map((Q)=>n1(Q,$,q,T))),j.doneHosts++,await R0(),P}class H0{limit;queue=[];active=0;constructor($){this.limit=$}async acquire(){if(this.active<this.limit){this.active++;return}await new Promise(($)=>this.queue.push($)),this.active++}release(){this.active--;let $=this.queue.shift();if($)$()}async run($){await this.acquire();try{return await $()}finally{this.release()}}}import{readFileSync as t1}from"node:fs";var e1=JSON.parse(t1(new URL("../package.json",import.meta.url),"utf-8"));function $4($){return{inputFile:$.input,outputPing:$.outputPing,outputPorts:$.outputPorts,resolver:$.resolver,concurrency:Number($.concurrency),timeout:Number($.timeout),pingCount:Number($.pingCount),verbose:Boolean($.verbose),ping:Boolean($.ping),curl:Boolean($.curl)}}function T4(){let $=[];if(globalThis.config.ping)$.push("ping");if(globalThis.config.curl)$.push("curl");if($.push("port443"),globalThis.config.verbose)$.push("verbose");return $.join("+")}async function P4($){let P=`
|
|
41
|
+
|
|
42
|
+
# Generated: ${new Date().toISOString().replace("T"," ").slice(0,19)} mode=${$}
|
|
43
|
+
|
|
44
|
+
`;for(let q of[globalThis.config.outputPing,globalThis.config.outputPorts])await r1(q,P,"utf-8")}async function q4($){if(!s1($))console.error(Y.red(`Error: '${$}' not found.`)),process.exit(1);return(await a1($,"utf-8")).split(`
|
|
45
|
+
`).map((P)=>P.trim()).filter(Boolean).map(t0).filter(Boolean)}var _2=new g0;_2.name("netprobe").description("Async host/IP prober โ DNS resolution, port 443, ping, curl").version(e1.version).addOption(new N("-i, --input <file>","input hosts file").default("hosts.txt")).addOption(new N("--output-ping <file>","ping-up IPs output").default("ping_up.txt")).addOption(new N("--output-ports <file>","port-open IPs output").default("ports_open.txt")).addOption(new N("-r, --resolver <ip>","DNS resolver").default("127.0.0.1")).addOption(new N("-c, --concurrency <n>","concurrent workers").default("10")).addOption(new N("-t, --timeout <s>","per-check timeout in seconds").default("5")).addOption(new N("--ping-count <n>","ping packet count").default("3")).addOption(new N("--ping","enable ICMP ping checks").default(!1)).addOption(new N("--curl","enable HTTPS curl checks").default(!1)).addOption(new N("-v, --verbose","show all IPs, not just up ones").default(!1)).action(async($)=>{globalThis.config=$4($);let T=await q4(globalThis.config.inputFile);if(!T.length)console.log(Y.yellow(`No hosts found in ${globalThis.config.inputFile}.`)),process.exit(0);j.totalHosts=T.length,j.startTime=Date.now();let P=T4();await P4(P),l0(T.length,P),d0(j);let q=new H0(globalThis.config.concurrency);await Promise.all(T.map((J)=>K2(J,q))),b(),process.stdout.write(`${y(j,!0)}
|
|
46
|
+
`)});_2.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "netprober",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"author": "maanimis",
|
|
5
|
+
"description": "Async host/IP prober โ DNS resolution, port 443, ping, curl",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"check": "biome check --write --no-errors-on-unmatched",
|
|
10
|
+
"lint": "biome lint --write --unsafe",
|
|
11
|
+
"format": "biome format --write",
|
|
12
|
+
"build": "bun build --target=node --production --minify src/index.ts --outfile dist/netprober.bundled.mjs",
|
|
13
|
+
"build:bin": "node ./build-bin.js",
|
|
14
|
+
"dev": "tsx src/index.ts",
|
|
15
|
+
"start": "npm run build && node dist/netprober.bundled.mjs",
|
|
16
|
+
"prepare": "husky"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"netprober": "dist/netprober.bundled.mjs"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"preferGlobal": true,
|
|
28
|
+
"lint-staged": {
|
|
29
|
+
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
|
|
30
|
+
"biome check --write --no-errors-on-unmatched"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"chalk": "^5.6.2",
|
|
35
|
+
"cidr-tools": "^11.3.3",
|
|
36
|
+
"commander": "^14.0.3",
|
|
37
|
+
"tsx": "^4.21.0",
|
|
38
|
+
"typescript": "^6.0.2"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@biomejs/biome": "2.4.12",
|
|
42
|
+
"@types/node": "^25.6.0",
|
|
43
|
+
"husky": "^9.1.7",
|
|
44
|
+
"lint-staged": "^16.4.0"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"netprober",
|
|
48
|
+
"cli",
|
|
49
|
+
"network",
|
|
50
|
+
"prober",
|
|
51
|
+
"ping",
|
|
52
|
+
"curl",
|
|
53
|
+
"dns",
|
|
54
|
+
"port-scan"
|
|
55
|
+
]
|
|
56
|
+
}
|