Skip to content

Commit 5bd2929

Browse files
committed
feat(new tool): IPv6 Address Converter
Equivalent for IPv6 of https://it-tools.tech/ipv4-address-converter Fix CorentinTh#548
1 parent 7f5fa00 commit 5bd2929

File tree

9 files changed

+339
-4
lines changed

9 files changed

+339
-4
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ declare module '@vue/runtime-core' {
115115
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
116116
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
117117
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
118+
Ipv6AddressConverter: typeof import('./src/tools/ipv6-address-converter/ipv6-address-converter.vue')['default']
118119
Ipv6UlaGenerator: typeof import('./src/tools/ipv6-ula-generator/ipv6-ula-generator.vue')['default']
119120
JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default']
120121
JsonMinify: typeof import('./src/tools/json-minify/json-minify.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 ipv6AddressConverter } from './ipv6-address-converter';
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+
ipv6AddressConverter,
155+
ipv4RangeExpander,
156+
macAddressLookup,
157+
macAddressGenerator,
158+
ipv6UlaGenerator,
159+
],
151160
},
152161
{
153162
name: 'Math',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
declare module 'cidr-tools' {
2+
type IPv4Address = string;
3+
type IPv4CIDR = string;
4+
type IPv6Address = string;
5+
type IPv6CIDR = string;
6+
7+
type Network = IPv4Address | IPv4CIDR | IPv6Address | IPv6CIDR;
8+
type Networks = Network | Network[];
9+
10+
type Parsed = {
11+
cidr: string;
12+
version: number;
13+
prefix: string;
14+
start: bigint;
15+
end: bigint;
16+
single: boolean;
17+
};
18+
19+
type NormalizeOpts = {
20+
compress?: boolean;
21+
hexify?: boolean;
22+
};
23+
24+
export function merge(networks: Networks): Network[];
25+
export function exclude(baseNetworks: Networks, excludeNetworks: Networks): Network[];
26+
export function expand(networks: Networks): Network[];
27+
export function overlap(networksA: Networks, networksB: Networks): boolean;
28+
export function normalize(cidr: Networks, opts?: NormalizeOpts): Networks;
29+
export function contains(networksA: Networks, networksB: Networks): boolean;
30+
export function parse(network: Network): Parsed;
31+
32+
declare const _default: {
33+
merge: typeof merge;
34+
exclude: typeof exclude;
35+
expand: typeof expand;
36+
overlap: typeof overlap;
37+
normalize: typeof normalize;
38+
contains: typeof contains;
39+
parse: typeof parse;
40+
};
41+
export default _default;
42+
}
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: 'Ipv6 address converter',
6+
path: '/ipv6-address-converter',
7+
description: 'Convert an ip address into decimal, binary, hexadecimal and get infos',
8+
keywords: ['ipv6', 'address', 'converter', 'decimal', 'hexadecimal', 'binary', 'ipv4'],
9+
component: () => import('./ipv6-address-converter.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)