mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 05:47:10 -04:00
fix: refactor using IPv4/6 Utils
Parse IPMask (ie, 192.168.0.5/255.255.255.0) to CIDR (ie 192.168.0.5/24), Fix #603
This commit is contained in:
parent
94f0b9ef93
commit
328afe5ec0
8 changed files with 162 additions and 779 deletions
|
@ -2,14 +2,13 @@
|
|||
import { convertBase } from '../integer-base-converter/integer-base-converter.model';
|
||||
import { getIPClass } from '../ipv4-subnet-calculator/ipv4-subnet-calculator.models';
|
||||
import { ipv4ToInt, ipv4ToIpv6, isValidIpv4 } from './ipv4-address-converter.service';
|
||||
import { getIPNetworkType, to6to4Prefix, toARPA, toIPv4MappedAddressDecimal } from '@/utils/ip';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import Network from '@/libs/ip_calculator/network';
|
||||
|
||||
const rawIpAddress = useStorage('ipv4-converter:ip', '192.168.1.1');
|
||||
const rawIpAddress = useStorage('ipv4-converter:ip', '192.168.1.1'); // NOSONAR
|
||||
|
||||
const convertedSections = computed(() => {
|
||||
const ipInDecimal = ipv4ToInt({ ip: rawIpAddress.value });
|
||||
const networkInfo = new Network(rawIpAddress.value || '', 32);
|
||||
|
||||
return [
|
||||
{
|
||||
|
@ -34,11 +33,11 @@ const convertedSections = computed(() => {
|
|||
},
|
||||
{
|
||||
label: 'Ipv6 (decimal): ',
|
||||
value: networkInfo.toIPv4MappedAddressDecimal()?.toString() || '',
|
||||
value: toIPv4MappedAddressDecimal(rawIpAddress.value),
|
||||
},
|
||||
{
|
||||
label: '6to4 prefix',
|
||||
value: networkInfo.to6to4Prefix()?.toString() || '',
|
||||
value: to6to4Prefix(rawIpAddress.value),
|
||||
},
|
||||
{
|
||||
label: 'CIDR notation',
|
||||
|
@ -46,7 +45,7 @@ const convertedSections = computed(() => {
|
|||
},
|
||||
{
|
||||
label: 'ARPA',
|
||||
value: networkInfo.toARPA()?.toString() || '',
|
||||
value: toARPA(rawIpAddress.value),
|
||||
},
|
||||
{
|
||||
label: 'IP class',
|
||||
|
@ -54,7 +53,7 @@ const convertedSections = computed(() => {
|
|||
},
|
||||
{
|
||||
label: 'Type',
|
||||
value: networkInfo.printInfo()?.toString() || '',
|
||||
value: getIPNetworkType(rawIpAddress.value),
|
||||
},
|
||||
];
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue