Skip to content

Commit 2fe369a

Browse files
committed
feat(new tool): IPv4/6 Range To CIDR
IPv4/6 Range To CIDR Fix CorentinTh#802
1 parent 7f5fa00 commit 2fe369a

File tree

7 files changed

+280
-4
lines changed

7 files changed

+280
-4
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ declare module '@vue/runtime-core' {
112112
IconMdiVideo: typeof import('~icons/mdi/video')['default']
113113
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
114114
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
115+
IpRangeToCidr: typeof import('./src/tools/ip-range-to-cidr/ip-range-to-cidr.vue')['default']
115116
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
116117
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
117118
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@vueuse/router": "^10.0.0",
4949
"bcryptjs": "^2.4.3",
5050
"change-case": "^4.1.2",
51+
"cidr-tools": "^7.0.4",
5152
"colord": "^2.9.3",
5253
"composerize-ts": "^0.6.2",
5354
"country-code-lookup": "^0.1.0",
@@ -62,6 +63,11 @@
6263
"highlight.js": "^11.7.0",
6364
"iarna-toml-esm": "^3.0.5",
6465
"ibantools": "^4.3.3",
66+
"ip-address": "^9.0.5",
67+
"ip-bigint": "^8.0.2",
68+
"ip-cidr": "^4.0.0",
69+
"is-cidr": "^5.0.3",
70+
"is-ip": "^5.0.1",
6571
"json5": "^2.2.3",
6672
"jwt-decode": "^3.1.2",
6773
"libphonenumber-js": "^1.10.28",

pnpm-lock.yaml

Lines changed: 117 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { tool as uuidGenerator } from './uuid-generator';
7777
import { tool as macAddressLookup } from './mac-address-lookup';
7878
import { tool as xmlFormatter } from './xml-formatter';
7979
import { tool as yamlViewer } from './yaml-viewer';
80+
import { tool as ipRangeToCidr } from './ip-range-to-cidr';
8081

8182
export const toolsByCategory: ToolCategory[] = [
8283
{
@@ -147,7 +148,15 @@ export const toolsByCategory: ToolCategory[] = [
147148
},
148149
{
149150
name: 'Network',
150-
components: [ipv4SubnetCalculator, ipv4AddressConverter, ipv4RangeExpander, macAddressLookup, macAddressGenerator, ipv6UlaGenerator],
151+
components: [
152+
ipv4SubnetCalculator,
153+
ipv4AddressConverter,
154+
ipv4RangeExpander,
155+
ipRangeToCidr,
156+
macAddressLookup,
157+
macAddressGenerator,
158+
ipv6UlaGenerator,
159+
],
151160
},
152161
{
153162
name: 'Math',

src/tools/ip-range-to-cidr/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Binary } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'IPv4/6 Range to CIDR(s) Calculator',
6+
path: '/ip-range-to-cidr',
7+
description: 'Calculate CIDR(s) from an IP Range (IPv4/6)',
8+
keywords: ['ip', 'range', 'to', 'cidr'],
9+
component: () => import('./ip-range-to-cidr.vue'),
10+
icon: Binary,
11+
createdAt: new Date('2024-01-10'),
12+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
declare module 'ip-bigint' {
2+
type IPInfo = {
3+
number: bigint;
4+
version: number;
5+
ipv4mapped?: boolean;
6+
scopeid?:string;
7+
};
8+
type StringifyOptions = {
9+
compress?:boolean;
10+
hexify?:boolean;
11+
};
12+
13+
export function normalizeIp(ip: string, options: StringifyOptions = {compress = true, hexify = false} = {})
14+
export function stringifyIp(ip: IPInfo, options: StringifyOptions = {compress = true, hexify = false}): string;
15+
export function ipVersion(ip: string): number;
16+
export function parseIp(ip): IPInfo;
17+
}

0 commit comments

Comments
 (0)