feat(IPv4 Subnet/Address Calculator): add more ip info

Add IPv4 range info (ie, private use, apipa...)
Add ARPA, Ipv6, 6to4 and class for both tools
This commit is contained in:
sharevb 2024-04-03 23:36:17 +02:00
parent 23f82d956a
commit 070ec0b36e
7 changed files with 806 additions and 0 deletions

View file

@ -1,12 +1,15 @@
<script setup lang="ts">
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 { useValidation } from '@/composable/validation';
import Network from '@/libs/ip_calculator/network';
const rawIpAddress = useStorage('ipv4-converter:ip', '192.168.1.1');
const convertedSections = computed(() => {
const ipInDecimal = ipv4ToInt({ ip: rawIpAddress.value });
const networkInfo = new Network(rawIpAddress.value || '', 32);
return [
{
@ -29,6 +32,30 @@ const convertedSections = computed(() => {
label: 'Ipv6 (short): ',
value: ipv4ToIpv6({ ip: rawIpAddress.value, prefix: '::ffff:' }),
},
{
label: 'Ipv6 (decimal): ',
value: networkInfo.toIPv4MappedAddressDecimal()?.toString() || '',
},
{
label: '6to4 prefix',
value: networkInfo.to6to4Prefix()?.toString() || '',
},
{
label: 'CIDR notation',
value: `${rawIpAddress.value}/32`,
},
{
label: 'ARPA',
value: networkInfo.toARPA()?.toString() || '',
},
{
label: 'IP class',
value: getIPClass({ ip: rawIpAddress.value }),
},
{
label: 'Type',
value: networkInfo.printInfo()?.toString() || '',
},
];
});