generate-ip 2.6.0 โ 2.8.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/README.md +30 -22
- package/dist/cli/index.min.js +2 -2
- package/dist/cli/lib/init.min.js +6 -0
- package/dist/cli/lib/jsdelivr.min.js +6 -0
- package/dist/cli/lib/language.min.js +2 -2
- package/dist/cli/lib/log.min.js +14 -14
- package/dist/cli/lib/pkg.min.js +1 -1
- package/dist/cli/lib/settings.min.js +2 -2
- package/dist/data/generate-ip.config.mjs +6 -4
- package/dist/data/messages.json +7 -0
- package/dist/data/package-data.json +1 -1
- package/dist/generate-ip.min.js +1 -1
- package/docs/README.md +32 -24
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
<a href="#%EF%B8%8F-mit-license">
|
|
12
12
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
13
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.
|
|
14
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.
|
|
13
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.8.0">
|
|
14
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.8.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
15
15
|
<a href="https://www.npmjs.com/package/generate-ip?activeTab=code">
|
|
16
16
|
<img height=31 src="https://img.shields.io/npm/unpacked-size/generate-ip?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
17
|
-
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.
|
|
18
|
-
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.
|
|
17
|
+
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.8.0/generate-ip/dist/generate-ip.min.js">
|
|
18
|
+
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.8.0&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
19
19
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:generate-ip/src/generate-ip.js">
|
|
20
20
|
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Agenerate-ip%2Fsrc%2Fgenerate-ip.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
21
21
|
<a href="https://github.com/toolleeo/cli-apps#networking">
|
|
@@ -87,14 +87,14 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
87
87
|
#### <> HTML script tag:
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
|
-
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
90
|
+
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js"></script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
#### ES6:
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js')
|
|
98
98
|
// Your code here...
|
|
99
99
|
})()
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
...
|
|
106
|
-
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
106
|
+
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js
|
|
107
107
|
// ==/UserScript==
|
|
108
108
|
|
|
109
109
|
// Your code here...
|
|
@@ -111,7 +111,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
111
111
|
|
|
112
112
|
<br>
|
|
113
113
|
|
|
114
|
-
๐ **Note:** To always import the latest version (not recommended in production!) remove the `@2.
|
|
114
|
+
๐ **Note:** To always import the latest version (not recommended in production!) remove the `@2.8.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js`
|
|
115
115
|
|
|
116
116
|
<br>
|
|
117
117
|
|
|
@@ -151,10 +151,12 @@ ipv4.generate() ยป 194.84.176.172, 192.186.53.120, 50.191.111.87
|
|
|
151
151
|
|
|
152
152
|
Available options:
|
|
153
153
|
|
|
154
|
-
Name
|
|
155
|
-
|
|
156
|
-
`verbose`
|
|
157
|
-
`qty`
|
|
154
|
+
Name | Type | Description | Default Value
|
|
155
|
+
-------------|---------|----------------------------------------------------------|---------------
|
|
156
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
157
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
158
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
159
|
+
`network` | String | starting network address (required for sequential mode). | `null`
|
|
158
160
|
|
|
159
161
|
#
|
|
160
162
|
|
|
@@ -220,12 +222,14 @@ ipv6.generate() ยป 8218:19b9:7709:4282:65e1:7ee:319e:32ef, e940:754d:ae46:ae18:9
|
|
|
220
222
|
|
|
221
223
|
Available options:
|
|
222
224
|
|
|
223
|
-
Name | Type | Description
|
|
224
|
-
|
|
225
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
226
|
-
`qty` | Integer | Number of IP addresses to generate.
|
|
227
|
-
`leadingZeros` | Boolean | Include leading zeros in hex pieces.
|
|
228
|
-
`doubleColon` | Boolean | Replace series of zeros w/ `::`
|
|
225
|
+
Name | Type | Description | Default Value
|
|
226
|
+
---------------|---------|----------------------------------------------------------|---------------
|
|
227
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
228
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
229
|
+
`leadingZeros` | Boolean | Include leading zeros in hex pieces. | `false`
|
|
230
|
+
`doubleColon` | Boolean | Replace series of zeros w/ `::` | `true`
|
|
231
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
232
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
229
233
|
|
|
230
234
|
#
|
|
231
235
|
|
|
@@ -315,10 +319,12 @@ mac.generate() ยป 1d:3a:af:21:b1:8c, af:fb:6f:b6:1b:8a
|
|
|
315
319
|
|
|
316
320
|
Available options:
|
|
317
321
|
|
|
318
|
-
Name | Type | Description
|
|
319
|
-
|
|
320
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
321
|
-
`qty` | Integer | Number of IP addresses to generate.
|
|
322
|
+
Name | Type | Description | Default Value
|
|
323
|
+
---------------|---------|----------------------------------------------------------|---------------
|
|
324
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
325
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
326
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
327
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
322
328
|
|
|
323
329
|
#
|
|
324
330
|
|
|
@@ -371,10 +377,12 @@ Parameter options:
|
|
|
371
377
|
--qty=n Generate n IP address(es).
|
|
372
378
|
--ui-lang="code" ISO 639-1 code of language to display UI in.
|
|
373
379
|
--config="path/to/file" Load custom config file.
|
|
380
|
+
--network="address" Starting network address (required for sequential mode).
|
|
374
381
|
|
|
375
382
|
Boolean options:
|
|
376
383
|
-6, --ipv6 Generate IPv6 address.
|
|
377
384
|
-m, --mac Generate MAC address.
|
|
385
|
+
-s, --sequential Generate addresses in sequence.
|
|
378
386
|
-q, --quiet Suppress all logging except errors.
|
|
379
387
|
|
|
380
388
|
Commands:
|
package/dist/cli/index.min.js
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
5
5
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
6
6
|
*/
|
|
7
|
-
(async()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e))
|
|
8
|
-
${cli.msgs.info_copyingToClip}...`)
|
|
7
|
+
(async()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e)),env.modExt=`${env.devMode?"":".min"}.js`;var e=require("node-clipboardy"),i=require("../generate-ip"+env.modExt),n=require("./lib/init"+env.modExt),o=require("./lib/log"+env.modExt);return await n.cli(),cli.config.init?n.configFile():cli.config.help?o.help():cli.config.version?o.version():(n={qty:cli.config.qty,sequential:cli.config.sequential,network:cli.config.network,verbose:!cli.config.quietMode},e.writeSync([].concat(i[cli.config.mode||"ipv4"].generate(n)).join("\n")),void o.ifNotQuiet(`
|
|
8
|
+
${cli.msgs.info_copyingToClip}...`))})();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ยฉ 2024โ2026 Adam Lui & contributors under the MIT license.
|
|
3
|
+
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
|
+
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
|
+
*/
|
|
6
|
+
let language=require("./language"+env.modExt),log=require("./log"+env.modExt),settings=require("./settings"+env.modExt),dataPath="../../"+(env.devMode?"../":"data/");module.exports={async cli(){Object.assign(globalThis.cli??={},require(dataPath+"package-data.json")),cli.lang=settings.load("uiLang")||(env.debugMode?language.generateRandomLang({excludes:["en"]}):language.getSysLang()),cli.msgs=await language.getMsgs(cli.lang),cli.urls.cliDocs||=cli.urls.docs+"/#-command-line-usage",settings.load()},async configFile(e=settings.configFilename){var t=require("fs"),a=require("path"),i={target:a.resolve(process.cwd(),e)};if(t.existsSync(i.target))return log.warn(cli.msgs.warn_configFileExists+":",i.target);if(t.existsSync(i.src=a.resolve(__dirname,""+dataPath+e)))t.copyFileSync(i.src,i.target);else{a=require("./jsdelivr"+env.modExt).pkgVerURL+`/${e}/`;log.data(cli.msgs.info_fetchingRemoteConfigFrom+` ${a}...`);try{var s=require("./data"+env.modExt),g=await s.fetch(a);if(!g.ok)return log.warn(`${cli.msgs.warn_remoteConfigNotFound}: ${a} (${g.status})`);s.atomicWrite(i.target,await g.text())}catch(e){return log.warn(cli.msgs.warn_remoteConfigFailed+`: ${a} `+e.message)}}log.success(`${cli.msgs.info_configFileCreated}: ${i.target}\n`),log.tip(cli.msgs.tip_editToSetDefaults+"."),log.tip(cli.msgs.tip_cliArgsPrioritized+".")}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ยฉ 2024โ2026 Adam Lui & contributors under the MIT license.
|
|
3
|
+
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
|
+
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
|
+
*/
|
|
6
|
+
module.exports={pkgVerURL(e){e||=cli.version||=require("./pkg"+env.modExt).getVer("local")||"none";e=/^\d+\.\d+\.\d+$/.test(e)?cli.name+"-"+e:"latest";return cli.urls.jsdelivr+`@${e}/`+cli.name},commitURL(e="latest"){return cli.urls.jsdelivr+`@${e}/`+cli.name}};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
let data=require(
|
|
7
|
-
`),l},async getMsgs(
|
|
6
|
+
let data=require("./data"+env.modExt),log=require("./log"+env.modExt);module.exports={formatCode(e){return e.replace(/([a-z]{2,8})[-_]([a-z]{2})/i,(e,r,t)=>r.toLowerCase()+"_"+t.toUpperCase())},generateRandomLang({includes:e=[],excludes:r=[]}={}){let a=require("fs"),s=require("path"),t=e.length?e:(()=>{var e=s.join(__dirname,"..",".cache"),r=s.join(e,"locales.json");if(a.existsSync(r))try{return JSON.parse(a.readFileSync(r,"utf8"))}catch(e){}var t=s.resolve(process.cwd(),"_locales");return a.existsSync(t)?(t=a.readdirSync(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^\w{2}[-_]?\w{0,2}$/.test(e)),a.mkdirSync(e,{recursive:!0}),data.atomicWrite(r,JSON.stringify(t,null,2)),t):["en"]})(),n=new Set(r),l="en";return(t=t.filter(e=>!n.has(e))).length&&(l=t[Math.floor(Math.random()*t.length)]),log.debug(`Random language: ${l}
|
|
7
|
+
`),l},async getMsgs(a="en"){if(a=module.exports.formatCode(a),env.msgs&&a==cli.lang)return env.msgs;let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`));if(!a.startsWith("en")){var s=require("./jsdelivr"+env.modExt).commitURL(cli.commitHashes.locales)+"/_locales/";let r=s+a+"/messages.json",t=0;for(;t<3;)try{e=data.flatten(await(await data.fetch(r)).json());break}catch(e){if(3<=++t)break;log.debug(r=a.includes("-")&&1==t?r.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):s+"en/messages.json")}}return e},getSysLang(){try{var e;return"win32"==process.platform?require("child_process").execSync("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim():((e=process.env).LANG||e.LANGUAGE||e.LC_ALL||e.LC_MESSAGES||e.LC_NAME).split(".")[0]}catch(e){return log.error(cli.msgs.error_failedToFetchSysLang+":",e.message),"en"}},validateLangCode(e){return"string"==typeof e&&/^[a-z]{2,8}(?:[-_][a-z]{2,3})?$/i.test(e)}};
|
package/dist/cli/lib/log.min.js
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
module.exports={colors:{nc:"[0m",br:"[1;91m",by:"[1;33m",bo:"[38;5;214m",bg:"[1;92m",bw:"[1;97m",blk:"[30m",tlBG:"[106m"},configURL(){this.info(`
|
|
7
|
-
${cli.msgs.info_exampleValidConfigFile}: `+cli.urls.config)},configURLandExit(...
|
|
8
|
-
`+this.colors.bw+
|
|
9
|
-
${this.colors.bo}DEBUG:`,
|
|
10
|
-
${this.colors.br}ERROR:`,...
|
|
11
|
-
`+this.colors.by+
|
|
12
|
-
`+this.colors.bg+
|
|
13
|
-
${this.colors.bo}WARNING:`,...
|
|
6
|
+
module.exports={colors:{nc:"[0m",br:"[1;91m",by:"[1;33m",bo:"[38;5;214m",bg:"[1;92m",bw:"[1;97m",gry:"[90m",blk:"[30m",tlBG:"[106m"},configURL(){this.info(`
|
|
7
|
+
${cli.msgs.info_exampleValidConfigFile}: `+cli.urls.config)},configURLandExit(...s){this.error(...s),this.configURL(),process.exit(1)},data(s){console.log(`
|
|
8
|
+
`+this.colors.bw+s+this.colors.nc)},debug(s){env.debugMode&&console.debug(`
|
|
9
|
+
${this.colors.bo}DEBUG:`,s,this.colors.nc,"\n")},dim(s){console.log(""+this.colors.gry+s+this.colors.nc)},error(...s){console.error(`
|
|
10
|
+
${this.colors.br}ERROR:`,...s,this.colors.nc)},errorAndExit(...s){this.error(...s),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(s){cli.config.quietMode||console.info(s)},info(s){console.info(`
|
|
11
|
+
`+this.colors.by+s+this.colors.nc)},tip(s){console.info(this.colors.by+"TIP: "+s+this.colors.nc)},success(s){console.log(`
|
|
12
|
+
`+this.colors.bg+s+this.colors.nc)},warn(...s){console.warn(`
|
|
13
|
+
${this.colors.bo}WARNING:`,...s,this.colors.nc)},help(s=["header","usage","params","flags","cmds"]){cli.prefix=""+this.colors.tlBG+this.colors.blk+`[30m ${cli.name} ${this.colors.nc} `;let o={header:[`
|
|
14
14
|
โ ${cli.prefix}${cli.msgs.appCopyright}.`,""+cli.prefix+cli.msgs.prefix_source+": "+cli.urls.src],usage:[`
|
|
15
15
|
${this.colors.bw}o ${cli.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}ยป `+this.colors.bg+cli.cmdFormat+this.colors.nc],params:[`
|
|
16
|
-
${this.colors.bw}o ${cli.msgs.helpSection_params}:`+this.colors.nc,` --qty=n ${cli.msgs.optionDesc_qty}.`,` --ui-lang="code" ${cli.msgs.optionDesc_uiLang}.`,` --config="path/to/file" ${cli.msgs.optionDesc_config}.`],flags:[`
|
|
17
|
-
${this.colors.bw}o ${cli.msgs.helpSection_flags}:`+this.colors.nc,` -6, --ipv6 ${cli.msgs.optionDesc_ipv6}.`,` -m, --mac ${cli.msgs.optionDesc_mac}.`,` -q, --quiet ${cli.msgs.optionDesc_quiet}.`],cmds:[`
|
|
18
|
-
${this.colors.bw}o ${cli.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${cli.msgs.optionDesc_init}.`,` -h, --help ${cli.msgs.optionDesc_help}.`,` -v, --version ${cli.msgs.optionDesc_version}.`]};
|
|
19
|
-
${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.
|
|
16
|
+
${this.colors.bw}o ${cli.msgs.helpSection_params}:`+this.colors.nc,` --qty=n ${cli.msgs.optionDesc_qty}.`,` --ui-lang="code" ${cli.msgs.optionDesc_uiLang}.`,` --config="path/to/file" ${cli.msgs.optionDesc_config}.`,` --network="address" ${cli.msgs.optionDesc_network}.`],flags:[`
|
|
17
|
+
${this.colors.bw}o ${cli.msgs.helpSection_flags}:`+this.colors.nc,` -6, --ipv6 ${cli.msgs.optionDesc_ipv6}.`,` -m, --mac ${cli.msgs.optionDesc_mac}.`,` -s, --sequential ${cli.msgs.optionDesc_sequential}.`,` -q, --quiet ${cli.msgs.optionDesc_quiet}.`],cmds:[`
|
|
18
|
+
${this.colors.bw}o ${cli.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${cli.msgs.optionDesc_init}.`,` -h, --help ${cli.msgs.optionDesc_help}.`,` -v, --version ${cli.msgs.optionDesc_version}.`]};s.forEach(t=>o[t]?.forEach(o=>{{var e=/header|usage/.test(t)?1:29;let i=process.stdout.columns||80,s=o.match(/\S+|\s+/g),c=[],l="";s.forEach(s=>{var o=i-(c.length?e:0);l.length+"| ".length+s.length>o&&(c.push(c.length?l.trimStart():l),l=""),l+=s}),c.push(c.length?l.trimStart():l),c.forEach((s,o)=>console.info("| "+(0==o?s:" ".repeat(e)+s)))}})),console.info(`
|
|
19
|
+
${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.cliDocs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
|
|
20
20
|
${cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${cli.name} --help' ${cli.msgs.info_or} ${cli.msgs.info_visit}
|
|
21
|
-
`+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var
|
|
22
|
-
${cli.msgs.prefix_localVer}: `+(
|
|
21
|
+
`+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var s=require("./pkg"+env.modExt).getVer;this.info(cli.name),this.data(`${cli.msgs.prefix_globalVer}: ${s("global")||"none"}
|
|
22
|
+
${cli.msgs.prefix_localVer}: `+(s("local")||"none"))}};
|
package/dist/cli/lib/pkg.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
let log=require(
|
|
6
|
+
let log=require("./log"+env.modExt);module.exports={getVer(e="any"){let r;if("global"!=e)try{var l=require("path").resolve(process.cwd(),"node_modules",cli.name,"package.json");r=require(l).version}catch(e){log.debug(cli.msgs.error_readingLocalPkgVer+": "+e.message)}if("global"==e||"all"==e&&!r)try{r=require("child_process").execSync(`npm view ${JSON.stringify(cli.name)} version`).toString().trim()}catch(e){log.debug(cli.msgs.error_failedToFetchGlobalVer+": "+e.message)}return r}};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
let fs=require("fs"),log=require(
|
|
7
|
-
`+e.message)}return env.args.forEach(i=>{
|
|
6
|
+
let fs=require("fs"),log=require("./log"+env.modExt),path=require("path");(globalThis.cli??={}).config={},module.exports={configFilename:"generate-ip.config.mjs",controls:{qty:{type:"param",valType:"positiveInt",defaultVal:1,regex:/^--?qu?a?n?ti?t?y(?:=.*|$)/},network:{type:"param",regex:/^--network(?:=.*|$)/},uiLang:{type:"param",valType:"langCode",regex:/^--?ui[-_]?lang(?:=.*|$)/},config:{type:"param",valType:"filepath",regex:/^--?config(?:=.*|$)/},ipv6mode:{type:"flag",mode:!0,regex:/^--?(?:ip)?v?6(?:[-_]?mode)?$/},macMode:{type:"flag",mode:!0,regex:/^--?m(?:ac)?(?:[-_]?mode)?$/},quietMode:{type:"flag",regex:/^--?q(?:uiet)?(?:[-_]?mode)?$/},sequential:{type:"flag",regex:/^--(?:s|equen(?:tial|ce))$/},init:{type:"cmd",regex:/^-{0,2}i(?:nit)?$/},help:{type:"cmd",regex:/^--?h(?:elp)?$/},version:{type:"cmd",regex:/^--?ve?r?s?i?o?n?$/}},load(e=Object.keys(this.controls)){let r=[].concat(e);if(cli.defaultsSet||arguments.length||(r.forEach(e=>{var i=this.controls[e];i.mode||(cli.config[e]??=i.defaultVal??("param"==i.type&&""))}),cli.defaultsSet=!0),!cli.configPathTried){e=env.args.find(e=>this.controls.config.regex.test(e));if(e){/=/.test(e)||log.errorAndExit(`[${e}] `+cli.msgs.error_mustIncludePath);e=e.split("=")[1];cli.configPath=path.isAbsolute(e)?e:path.resolve(process.cwd(),e),fs.existsSync(cli.configPath)||log.configURLandExit(cli.msgs.error_configFileNotFound+":",cli.configPath)}else for(var i of[".mjs",".cjs",".js"]){i=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,i));if(fs.existsSync(i)){cli.configPath=i;break}}cli.configPathTried=!0}if(cli.configPath)try{let e=require(cli.configPath),o=e?.default??e;o&&"object"==typeof o||log.configURLandExit(cli.msgs.error_invalidConfigFile+"."),Object.assign(cli.config,arguments.length?r.reduce((e,i)=>o[i]?{...e,[i]:o[i]}:e,{}):o)}catch(e){log.configURLandExit(cli.msgs.error_failedToLoadConfigFile+":",cli.configPath,`
|
|
7
|
+
`+e.message)}return env.args.forEach(i=>{var e,o;/^[^-]|--?(?:config|debug)/.test(i)&&"init"!=i||(!(e=Object.keys(this.controls).find(e=>this.controls[e]?.regex?.test(i)))&&cli.msgs&&log.errorAndExit(`[${i}] ${cli.msgs.error_notRecognized}.`),r.includes(e)&&((o=this.controls[e]).mode?cli.config.mode=e.replace(/mode$/i,"").toLowerCase():cli.config[e]="param"!=o.type||(i.split("=")[1]?.trim()??"")))}),this.parseValidateConfig(r),1==r.length?cli.config[r[0]]:cli.config},parseValidateConfig(e=Object.keys(this.controls)){let r=require("./language"+env.modExt);for(let o of[].concat(e)){let e=this.controls[o],i=cli.config[o];e.parser&&!e.parsed&&(cli.config[o]=e.parser(i),e.parsed=!0),e.valType&&{positiveInt(){var e=parseInt(i,10);(isNaN(e)||e<1)&&log.errorAndExit(`[${o}] ${cli.msgs.error_nonPositiveNum}: `+i),cli.config[o]=e},filepath(){i&&!fs.existsSync(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidFilepath}: `+i)},langCode(){i&&!r.validateLangCode(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidLangCode}: `+i)}}[e.valType]?.(),cli.config.sequential&&(cli.config.network?cli.config.qty<=1&&log.errorAndExit(`--qty ${cli.msgs.error_mustBeGreaterThanOne} ${cli.msgs.error_whenPassing} --sequential.`):log.errorAndExit(`--network ${cli.msgs.error_isRequired} ${cli.msgs.error_whenPassing} --sequential.`))}}};
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
|
-
mode: 'ipv4',
|
|
13
|
-
qty: 1,
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
mode: 'ipv4', // <ipv4|ipv6|mac> type of address to generate
|
|
13
|
+
qty: 1, // # of IPs to generate
|
|
14
|
+
sequential: false, // generate addresses in sequence
|
|
15
|
+
network: null, // starting network address (required for sequential mode)
|
|
16
|
+
quietMode: false, // suppress all logging except errors
|
|
17
|
+
uiLang: '' // ISO 639-1 code of language to display UI in
|
|
16
18
|
}
|
package/dist/data/messages.json
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"error_readingLocalPkgVer": { "message": "Error reading local package version" },
|
|
8
8
|
"error_notRecognized": { "message": "not recognized" },
|
|
9
9
|
"error_nonPositiveNum": { "message": "argument can only be > 0" },
|
|
10
|
+
"error_invalidFilepath": { "message": "must be a valid existing file path. Got" },
|
|
11
|
+
"error_invalidLangCode": { "message": "is an invalid language code" },
|
|
10
12
|
"error_invalidURL": { "message": "Invalid URL" },
|
|
11
13
|
"error_invalidConfigFile": { "message": "Config file must export an object" },
|
|
12
14
|
"error_configFileNotFound": { "message": "Config file not found" },
|
|
@@ -14,6 +16,9 @@
|
|
|
14
16
|
"error_failedToFetchGlobalVer": { "message": "Failed to fetch global version" },
|
|
15
17
|
"error_failedToFetchSysLang": { "message": "Failed to fetch system language" },
|
|
16
18
|
"error_mustIncludePath": { "message": "must include =path" },
|
|
19
|
+
"error_isRequired": { "message": "is required" },
|
|
20
|
+
"error_whenPassing": { "message": "when passing" },
|
|
21
|
+
"error_mustBeGreaterThanOne": { "message": "must be > 1" },
|
|
17
22
|
"warn_configFileExists": { "message": "Config file already exists" },
|
|
18
23
|
"warn_remoteConfigNotFound": { "message": "Remote config file not found" },
|
|
19
24
|
"warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
|
|
@@ -36,6 +41,8 @@
|
|
|
36
41
|
"optionDesc_config": { "message": "Load custom config file" },
|
|
37
42
|
"optionDesc_ipv6": { "message": "Generate IPv6 address" },
|
|
38
43
|
"optionDesc_mac": { "message": "Generate MAC address" },
|
|
44
|
+
"optionDesc_sequential": { "message": "Generate addresses in sequence" },
|
|
45
|
+
"optionDesc_network": { "message": "Starting network address (required for sequential mode)" },
|
|
39
46
|
"optionDesc_quiet": { "message": "Suppress all logging except errors" },
|
|
40
47
|
"optionDesc_init": { "message": "Create config file (in project root)" },
|
|
41
48
|
"optionDesc_help": { "message": "Display help screen" },
|
package/dist/generate-ip.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/js-utils/tree/main/generate-ip/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/js-utils/tree/main/generate-ip/docs
|
|
5
5
|
*/
|
|
6
|
-
Object.assign(globalThis.api??={},{name:"generate-ip",aliases:{ipv4:["ipV4","IPv4","IPV4","Ipv4","IpV4","ip","IP","Ip"],ipv6:["ipV6","IPv6","IPV6","Ipv6","IpV6"],mac:["MAC","Mac","ethernet","Ethernet"]}});let ipv4={generate(t={}){var e={verbose:!0,qty:1};if(log.prefix="ipv4.generate()",validateOptions({options:t,defaultOptions:
|
|
6
|
+
Object.assign(globalThis.api??={},{name:"generate-ip",aliases:{ipv4:["ipV4","IPv4","IPV4","Ipv4","IpV4","ip","IP","Ip"],ipv6:["ipV6","IPv6","IPV6","Ipv6","IpV6"],mac:["MAC","Mac","ethernet","Ethernet"]}});let ipv4={generate(t={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv4generateoptions",r={verbose:!0,qty:1,sequential:!1,network:null};if(log.prefix="ipv4.generate()",validateOptions({options:t,defaultOptions:r,helpURL:e,exampleCall:"ipv4.generate({ verbose: false, qty: 3 })"})){(t={...r,...t}).verbose&&log.info(`Generating IPv4 address${1<t.qty?"es":""}...`);var o=[];if(t.sequential){t.network&&this.validate(t.network)?(!t.qty||t.qty<=1)&&log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid IP when options.sequential is `true`."});var[i,a,s,l]=t.network.split(".").map(Number);for(let e=0;e<t.qty;e++)o.push(i+`.${a}.${s}.`+(l+e))}else if(1<t.qty)for(let e=0;e<t.qty;e++)o.push(this.generate({...t,qty:1,verbose:!1}));else{var n=[];for(let e=0;e<4;e++)n.push(random.int(0,256));o.push(n.join("."))}r=1<t.qty?o:o[0];return t.verbose&&(log.info(`IPv4 address${1<t.qty?"es":""} generated!`),log.info(1==t.qty?r:r.join(", "))),r}},validate(e,t={}){var r="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv4validateaddress-options",o={verbose:!0};if(log.prefix="ipv4.validate()","string"!=typeof e&&log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:r}),validateOptions({options:t,defaultOptions:o,helpURL:r,exampleCall:"ipv4.validate('0.0.255.255', { verbose: false })"}))return(t={...o,...t}).verbose&&log.info(`Validating ${e}...`),o=!(4!=(r=e.split(".")).length||r.some(e=>!/^\d+$/.test(e)||parseInt(e,10)<0||255<parseInt(e,10))),t.verbose&&log.info(`IP is ${o?"":"in"}valid IPv4 address!`),o}},ipv6={generate(a={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6generateoptions",t={verbose:!0,qty:1,leadingZeros:!1,doubleColon:!0,sequential:!1,network:null};if(log.prefix="ipv6.generate()",validateOptions({options:a,defaultOptions:t,helpURL:e,exampleCall:"ipv6.generate({ leadingZeros: true, qty: 5 })"})){(a={...t,...a}).verbose&&log.info(`Generating IPv6 address${1<a.qty?"es":""}...`);var s=[];if(a.sequential){a.network&&this.validate(a.network)?(!a.qty||a.qty<=1)&&log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid IP when options.sequential is `true`."});var r=a.network.split(":").map(e=>parseInt(e,16)||0);for(let e=0;e<a.qty;e++){var o=r[7];r[7]=o+e,r[7]>o+1&&(r[7]=o+1),s.push(r.map(e=>e.toString(16).padStart(4,"0")).join(":"))}}else if(1<a.qty)for(let e=0;e<a.qty;e++)s.push(this.generate({...a,qty:1,verbose:!1}));else{let t=[],{qty:e,sequential:r,network:o,...i}=a;for(let e=0;e<8;e++)t.push(random.hex(4));s.push(this.format(t.join(":"),{...i,verbose:!1}))}t=1<a.qty?s:s[0];return a.verbose&&(log.info(`IPv6 address${1<a.qty?"es":""} generated!`),log.info(1==a.qty?t:t.join(", "))),t}},format(t,r={}){var o="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6formatipv6address-options",i={verbose:!0,leadingZeros:!1,doubleColon:!0};if(log.prefix="ipv6.format()","string"!=typeof t&&log.errHelpURLandThrow({errMsg:"1st arg <ipv6address> must be a string.",helpURL:o}),this.validate(t,{verbose:!1})||log.errHelpURLandThrow({errMsg:t+" is not a valid IPv6 address.",helpURL:o}),validateOptions({options:r,defaultOptions:i,helpURL:o,exampleCall:"ipv6.format('0d::ffff:192.1.56.10/96', { leadingZeros: true, doubleColon: false })"})){r={...i,...r};let e=t;if(e=r.doubleColon?(r.verbose&&log.info("Replacing zero series w/ '::'..."),e.replace(/:(?:0+:)+/,"::")):(r.verbose&&log.info("Expanding '::' into zero series..."),o=e.split(":").filter(Boolean).length,i=r.leadingZeros?"0000":"0",o=Array(8-o).fill(i).join(":"),e.replace("::",`:${o}:`)),r.leadingZeros){r.verbose&&log.info("Adding leading zeros...");var a=e.split(":");for(let e=0;e<a.length;e++)for(;a[e].length<4;)a[e]="0"+a[e];e=a.join(":")}else r.verbose&&log.info("Stripping leading zeros..."),e=t.replace(/(^|(?<=:))0+(?!:)/g,"$1");return r.verbose&&(e!=t?log.info("IP formatted successfully!"):log.info("IP already formatted to specs."),log.info(e)),e}},validate(r,o={}){var i="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#ipv6validateaddress-options",a={verbose:!0};if(log.prefix="ipv6.validate()","string"!=typeof r&&log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:i}),validateOptions({options:o,defaultOptions:a,helpURL:i,exampleCall:"ipv6.validate('0:0:0:0:0:ffff:192.1.56.10/96', { verbose: false })"})){(o={...a,...o}).verbose&&log.info(`Validating ${r}...`);let e=r.split(/::?/),t=e[e.length-1];i=!(r.includes("::")&&2<r.split("::").length||/:{3,}/.test(r)||e.length<2||8<e.length||e.some(e=>!(/^[\da-f]{1,4}$/i.test(e)||e==t&&ipv4.validate(t.replace(/\/(?:12[0-8]|[1-9]?\d)$/,""),{verbose:!1}))));return o.verbose&&log.info(`IP is ${i?"":"in"}valid IPv6 address!`),i}}},mac={generate(t={}){var e="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#macgenerateoptions",r={verbose:!0,qty:1,sequential:!1,network:null};if(log.prefix="mac.generate()",validateOptions({options:t,defaultOptions:r,helpURL:e,exampleCall:"mac.generate({ verbose: false, qty: 2 })"})){(t={...r,...t}).verbose&&log.info(`Generating MAC address${1<t.qty?"es":""}...`);var o=[];if(t.sequential){t.network&&this.validate(t.network)?(!t.qty||t.qty<=1)&&log.errHelpURLandThrow({helpURL:e,errMsg:"options.qty must be > 1 when options.sequential is `true`."}):log.errHelpURLandThrow({helpURL:e,errMsg:"options.network must be a valid MAC when options.sequential is `true`."});var i=t.network.split(":").map(e=>parseInt(e,16)||0);for(let e=0;e<t.qty;e++){var a=i[5];i[5]=a+e,i[5]>a+1&&(i[5]=a+1),o.push(i.map(e=>e.toString(16).padStart(2,"0")).join(":"))}}else if(1<t.qty)for(let e=0;e<t.qty;e++)o.push(this.generate({...t,qty:1,verbose:!1}));else{var[r,e]=Array.from({length:2},()=>{var t=[];for(let e=0;e<3;e++)t.push(random.hex(2));return t.join(":")});o.push(r+":"+e)}r=1<t.qty?o:o[0];return t.verbose&&(log.info(`MAC address${1<t.qty?"es":""} generated!`),log.info(1==t.qty?r:r.join(", "))),r}},validate(e,t={}){var r="https://github.com/adamlui/js-utils/tree/main/generate-ip/docs/#macvalidateaddress-options",o={verbose:!0};if(log.prefix="mac.validate()","string"!=typeof e&&log.errHelpURLandThrow({errMsg:"1st arg <address> must be a string.",helpURL:r}),validateOptions({options:t,defaultOptions:o,helpURL:r,exampleCall:"mac.validate('00:1A:2B:3C:4D:5E', { verbose: false })"}))return(t={...o,...t}).verbose&&log.info(`Validating ${e}...`),r=/^(?:[\da-f]{2}[:-]){5}[\da-f]{2}$/i.test(e),t.verbose&&log.info(`Address is ${r?"":"in"}valid MAC address!`),r}};function validateOptions({options:e,defaultOptions:t,helpURL:r,exampleCall:o}){var i,a,s=Object.keys(t).filter(e=>"boolean"==typeof t[e]),l=Object.keys(t).filter(e=>Number.isInteger(t[e]));if("object"!=typeof e)return i=o.split(",").findIndex(e=>e.trim().startsWith("{"))+1,i+=["st","nd","rd"][i-1]||"th",log.error(`${"0th"==i?"[O":i+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",o),log.validOptions(t),log.helpURL(r),!1;for(a in e){if(!Object.prototype.hasOwnProperty.call(t,a))return log.error(`\`${a}\` is an invalid option.`),log.validOptions(t),log.helpURL(r),!1;if(s.includes(a)&&"boolean"!=typeof e[a])return log.error(`[${a}] option can only be \`true\` or \`false\`.`),log.helpURL(r),!1;if(l.includes(a)&&(e[a]=parseInt(e[a],10),isNaN(e[a])||e[a]<1))return log.error(`[${a}] option can only be an integer > 0.`),log.helpURL(r),!1}return!0}let random={int(e,t){var r;return"undefined"==typeof require?(r=(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random(),Math.floor(r*(t-e))+e):require("crypto").randomInt(e,t)},hex(t){let r="";for(let e=0;e<t;e++)r+=random.int(0,16).toString(16);return r}},log={prefix:api.name,errHelpURLandThrow({errMsg:e,helpURL:t}){throw this.error(e),this.helpURL(t),new Error(e)},error(...e){console.error(this.prefix+" ยป ERROR:",...e)},helpURL(e=api.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" ยป",...e)},validOptions(e){var t=Object.keys(e).join(", "),e=JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${t}]`),this.info("If omitted, default settings are: "+e)}};api.exports={ipv4:ipv4,ipv6:ipv6,mac:mac};try{module.exports={...api.exports}}catch(e){}try{Object.assign(window,api.exports)}catch(e){}for(let t in api.aliases)api.aliases[t].forEach(e=>{try{module.exports[e]??=module.exports[t]}catch(e){}try{window[e]??=window[t]}catch(e){}});
|
package/docs/README.md
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
<a href="#%EF%B8%8F-mit-license">
|
|
12
12
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
13
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.
|
|
14
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.
|
|
13
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-ip-2.8.0">
|
|
14
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.8.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
15
15
|
<a href="https://www.npmjs.com/package/generate-ip?activeTab=code">
|
|
16
16
|
<img height=31 src="https://img.shields.io/npm/unpacked-size/generate-ip?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
17
|
-
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.
|
|
18
|
-
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.
|
|
17
|
+
<a href="https://github.com/adamlui/js-utils/blob/generate-ip-2.8.0/generate-ip/dist/generate-ip.min.js">
|
|
18
|
+
<img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-ip/dist/generate-ip.min.js?branch=generate-ip-2.8.0&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
19
19
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:generate-ip/src/generate-ip.js">
|
|
20
20
|
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Agenerate-ip%2Fsrc%2Fgenerate-ip.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
21
21
|
<a href="https://github.com/toolleeo/cli-apps#networking">
|
|
@@ -87,14 +87,14 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
87
87
|
#### <> HTML script tag:
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
|
-
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
90
|
+
<script src="https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js"></script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
#### ES6:
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js')
|
|
98
98
|
// Your code here...
|
|
99
99
|
})()
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
...
|
|
106
|
-
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.
|
|
106
|
+
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.8.0/dist/generate-ip.min.js
|
|
107
107
|
// ==/UserScript==
|
|
108
108
|
|
|
109
109
|
// Your code here...
|
|
@@ -111,7 +111,7 @@ const { ipv4, ipv6, mac } = require('generate-ip')
|
|
|
111
111
|
|
|
112
112
|
<br>
|
|
113
113
|
|
|
114
|
-
๐ **Note:** To always import the latest version (not recommended in production!) remove the `@2.
|
|
114
|
+
๐ **Note:** To always import the latest version (not recommended in production!) remove the `@2.8.0` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/generate-ip/dist/generate-ip.min.js`
|
|
115
115
|
|
|
116
116
|
<br>
|
|
117
117
|
|
|
@@ -151,10 +151,12 @@ ipv4.generate() ยป 194.84.176.172, 192.186.53.120, 50.191.111.87
|
|
|
151
151
|
|
|
152
152
|
Available options:
|
|
153
153
|
|
|
154
|
-
Name
|
|
155
|
-
|
|
156
|
-
`verbose`
|
|
157
|
-
`qty`
|
|
154
|
+
Name | Type | Description | Default Value
|
|
155
|
+
-------------|---------|----------------------------------------------------------|---------------
|
|
156
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
157
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
158
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
159
|
+
`network` | String | starting network address (required for sequential mode). | `null`
|
|
158
160
|
|
|
159
161
|
#
|
|
160
162
|
|
|
@@ -220,12 +222,14 @@ ipv6.generate() ยป 8218:19b9:7709:4282:65e1:7ee:319e:32ef, e940:754d:ae46:ae18:9
|
|
|
220
222
|
|
|
221
223
|
Available options:
|
|
222
224
|
|
|
223
|
-
Name | Type | Description
|
|
224
|
-
|
|
225
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
226
|
-
`qty` | Integer | Number of IP addresses to generate.
|
|
227
|
-
`leadingZeros` | Boolean | Include leading zeros in hex pieces.
|
|
228
|
-
`doubleColon` | Boolean | Replace series of zeros w/ `::`
|
|
225
|
+
Name | Type | Description | Default Value
|
|
226
|
+
---------------|---------|----------------------------------------------------------|---------------
|
|
227
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
228
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
229
|
+
`leadingZeros` | Boolean | Include leading zeros in hex pieces. | `false`
|
|
230
|
+
`doubleColon` | Boolean | Replace series of zeros w/ `::` | `true`
|
|
231
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
232
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
229
233
|
|
|
230
234
|
#
|
|
231
235
|
|
|
@@ -315,10 +319,12 @@ mac.generate() ยป 1d:3a:af:21:b1:8c, af:fb:6f:b6:1b:8a
|
|
|
315
319
|
|
|
316
320
|
Available options:
|
|
317
321
|
|
|
318
|
-
Name | Type | Description
|
|
319
|
-
|
|
320
|
-
`verbose` | Boolean | Show logging in console/terminal.
|
|
321
|
-
`qty` | Integer | Number of IP addresses to generate.
|
|
322
|
+
Name | Type | Description | Default Value
|
|
323
|
+
---------------|---------|----------------------------------------------------------|---------------
|
|
324
|
+
`verbose` | Boolean | Show logging in console/terminal. | `true`
|
|
325
|
+
`qty` | Integer | Number of IP addresses to generate. | `1`
|
|
326
|
+
`sequential` | Boolean | Generate addresses in sequence. | `false`
|
|
327
|
+
`network` | String | Starting network address (required for sequential mode). | `null`
|
|
322
328
|
|
|
323
329
|
#
|
|
324
330
|
|
|
@@ -371,10 +377,12 @@ Parameter options:
|
|
|
371
377
|
--qty=n Generate n IP address(es).
|
|
372
378
|
--ui-lang="code" ISO 639-1 code of language to display UI in.
|
|
373
379
|
--config="path/to/file" Load custom config file.
|
|
380
|
+
--network="address" Starting network address (required for sequential mode).
|
|
374
381
|
|
|
375
382
|
Boolean options:
|
|
376
383
|
-6, --ipv6 Generate IPv6 address.
|
|
377
384
|
-m, --mac Generate MAC address.
|
|
385
|
+
-s, --sequential Generate addresses in sequence.
|
|
378
386
|
-q, --quiet Suppress all logging except errors.
|
|
379
387
|
|
|
380
388
|
Commands:
|
|
@@ -387,7 +395,7 @@ Commands:
|
|
|
387
395
|
|
|
388
396
|
### Configuration file
|
|
389
397
|
|
|
390
|
-
**generate-ip** can be customized using `generate-ip.config.mjs` or `generate-ip.config.js` placed in your project root.
|
|
398
|
+
**generate-ip** can be customized using a `generate-ip.config.mjs` or `generate-ip.config.js` placed in your project root.
|
|
391
399
|
|
|
392
400
|
Example defaults:
|
|
393
401
|
|
|
@@ -400,7 +408,7 @@ export default {
|
|
|
400
408
|
}
|
|
401
409
|
```
|
|
402
410
|
|
|
403
|
-
๐ก
|
|
411
|
+
๐ก Run `generate-ip init` to generate a template `generate-ip.config.mjs` in your project root.
|
|
404
412
|
|
|
405
413
|
<br>
|
|
406
414
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generate-ip",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Randomly generate, format, and validate IPv4 + IPv6 + MAC addresses.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -43,9 +43,10 @@
|
|
|
43
43
|
"build:data": "node utils/build --data",
|
|
44
44
|
"build:json": "node utils/build --json",
|
|
45
45
|
"debug": "node src/cli --debug",
|
|
46
|
-
"translate": "
|
|
46
|
+
"translate": "translate-messages",
|
|
47
47
|
"bump:patch": "bash utils/bump.sh patch",
|
|
48
48
|
"bump:minor": "bash utils/bump.sh minor",
|
|
49
|
+
"bump:feat": "npm run bump:minor",
|
|
49
50
|
"bump:major": "bash utils/bump.sh major"
|
|
50
51
|
},
|
|
51
52
|
"repository": {
|
|
@@ -53,16 +54,20 @@
|
|
|
53
54
|
"url": "git+https://github.com/adamlui/js-utils.git"
|
|
54
55
|
},
|
|
55
56
|
"keywords": [
|
|
56
|
-
"
|
|
57
|
-
"generator",
|
|
58
|
-
"unique",
|
|
59
|
-
"generate",
|
|
57
|
+
"address",
|
|
60
58
|
"api",
|
|
61
59
|
"cli",
|
|
62
|
-
"
|
|
60
|
+
"generate",
|
|
61
|
+
"generator",
|
|
62
|
+
"internet",
|
|
63
|
+
"ip",
|
|
63
64
|
"ipv4",
|
|
64
65
|
"ipv6",
|
|
65
|
-
"mac"
|
|
66
|
+
"mac",
|
|
67
|
+
"network",
|
|
68
|
+
"privacy",
|
|
69
|
+
"utility",
|
|
70
|
+
"unique"
|
|
66
71
|
],
|
|
67
72
|
"bugs": {
|
|
68
73
|
"url": "https://github.com/adamlui/js-utils/issues"
|
|
@@ -71,6 +76,6 @@
|
|
|
71
76
|
"node-clipboardy": "^1.0.3"
|
|
72
77
|
},
|
|
73
78
|
"devDependencies": {
|
|
74
|
-
"@adamlui/minify.js": "^2.
|
|
79
|
+
"@adamlui/minify.js": "^2.3.0"
|
|
75
80
|
}
|
|
76
81
|
}
|