diff --git a/package.json b/package.json index 929408e4..5a358e47 100644 --- a/package.json +++ b/package.json @@ -206,6 +206,11 @@ "is-cidr": "^5.0.3", "is-ip": "^5.0.1", "ip-matching": "^2.1.2", + "ip-address": "^9.0.5", + "ip-bigint": "^8.0.2", + "ip-cidr": "^4.0.0", + "is-cidr": "^5.0.3", + "is-ip": "^5.0.1", "json5": "^2.2.3", "jsonpath": "^1.1.1", "jsonar-mod": "^1.9.0", diff --git a/src/tools/index.ts b/src/tools/index.ts index 27ffa952..b6f93785 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -207,6 +207,7 @@ import { tool as barcodeGenerator } from './barcode-generator'; import { tool as htmlToMarkdown } from './html-to-markdown'; import { tool as pdfUnlock } from './pdf-unlock'; import { tool as ipCidrToRange } from './ip-cidr-to-range'; +import { tool as ipRangeToCidr } from './ip-range-to-cidr'; export const toolsByCategory: ToolCategory[] = [ { @@ -422,6 +423,8 @@ export const toolsByCategory: ToolCategory[] = [ websocketTester, ipv4RangeExpander, ipCidrToRange, + ipv4RangeExpander, + ipRangeToCidr, macAddressLookup, macAddressGenerator, ipv6UlaGenerator, diff --git a/src/tools/ip-range-to-cidr/index.ts b/src/tools/ip-range-to-cidr/index.ts new file mode 100644 index 00000000..c8a44411 --- /dev/null +++ b/src/tools/ip-range-to-cidr/index.ts @@ -0,0 +1,12 @@ +import { Binary } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'IPv4/6 Range to CIDR(s) Calculator', + path: '/ip-range-to-cidr', + description: 'Calculate CIDR(s) from an IP Range (IPv4/6)', + keywords: ['ip', 'range', 'to', 'cidr'], + component: () => import('./ip-range-to-cidr.vue'), + icon: Binary, + createdAt: new Date('2024-01-10'), +}); diff --git a/src/tools/ip-range-to-cidr/ip-bigint.d.ts b/src/tools/ip-range-to-cidr/ip-bigint.d.ts new file mode 100644 index 00000000..eff26030 --- /dev/null +++ b/src/tools/ip-range-to-cidr/ip-bigint.d.ts @@ -0,0 +1,17 @@ +declare module 'ip-bigint' { + type IPInfo = { + number: bigint; + version: number; + ipv4mapped?: boolean; + scopeid?:string; + }; + type StringifyOptions = { + compress?:boolean; + hexify?:boolean; + }; + + export function normalizeIp(ip: string, options: StringifyOptions = {compress = true, hexify = false} = {}) + export function stringifyIp(ip: IPInfo, options: StringifyOptions = {compress = true, hexify = false}): string; + export function ipVersion(ip: string): number; + export function parseIp(ip): IPInfo; +} \ No newline at end of file diff --git a/src/tools/ip-range-to-cidr/ip-range-to-cidr.vue b/src/tools/ip-range-to-cidr/ip-range-to-cidr.vue new file mode 100644 index 00000000..397b1564 --- /dev/null +++ b/src/tools/ip-range-to-cidr/ip-range-to-cidr.vue @@ -0,0 +1,117 @@ + + +