mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 22:02:38 +03:00
1 parent
1cafdfa9ad
commit
ed2519e937
6 files changed
+105
-6
No files matched your search
@@ -0,0 +1,26 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { fromARPA } from '@/utils/ip';
|
||||||
|
|
||||||
|
const arpaInput = ref('');
|
||||||
|
|
||||||
|
const decodedIP = computed(() => {
|
||||||
|
try {
|
||||||
|
return fromARPA(arpaInput.value.trim());
|
||||||
|
}
|
||||||
|
catch (e: any) {
|
||||||
|
return `# ${e.toString()}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<NFormItem label="ARPA Address:" label-placement="left" mb-2>
|
||||||
|
<NInput v-model:value="arpaInput" placeholder="e.g. 10.1.168.192.in-addr.arpa. or xxxx.ip6.arpa." />
|
||||||
|
</NFormItem>
|
||||||
|
|
||||||
|
<c-card v-if="decodedIP">
|
||||||
|
<textarea-copyable :value="decodedIP" />
|
||||||
|
</c-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { World } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'ARPA Decoder',
|
||||||
|
path: '/arpa-decoder',
|
||||||
|
description: 'Decode IPv4/6 ARPA addresses or PTR record',
|
||||||
|
keywords: ['arpa', 'ptr', 'ip', 'dns', 'decoder'],
|
||||||
|
component: () => import('./arpa-decoder.vue'),
|
||||||
|
icon: World,
|
||||||
|
createdAt: new Date('2026-01-01'),
|
||||||
|
category: 'Network',
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { World } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'PTR DNS Generator',
|
||||||
|
path: '/ptr-dns-generator',
|
||||||
|
description: 'Generate DNS PTR records',
|
||||||
|
keywords: ['ptr', 'arpa', 'ip', 'dns', 'generator'],
|
||||||
|
component: () => import('./ptr-dns-generator.vue'),
|
||||||
|
icon: World,
|
||||||
|
createdAt: new Date('2026-01-01'),
|
||||||
|
category: 'Network',
|
||||||
|
});
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { toARPA } from '@/utils/ip';
|
||||||
|
|
||||||
|
const ipInput = ref('');
|
||||||
|
const ptrRecord = computed(() => {
|
||||||
|
try {
|
||||||
|
return toARPA(ipInput.value.trim());
|
||||||
|
}
|
||||||
|
catch (e: any) {
|
||||||
|
return `# ${e.toString()}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<NFormItem label="IP Address (IPv4 or IPv6):" label-placement="left" mb-2>
|
||||||
|
<NInput v-model:value="ipInput" placeholder="e.g. 192.168.1.10 or 2001:db8::1" />
|
||||||
|
</NFormItem>
|
||||||
|
|
||||||
|
<c-card v-if="ptrRecord">
|
||||||
|
<textarea-copyable :value="ptrRecord" />
|
||||||
|
</c-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
+13
-5
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { getIPNetworkType, getNetworksCount, getSubnets, parseAsCIDR, to6to4Prefix, toARPA, toIPv4MappedAddress, toIPv4MappedAddressDecimal } from './ip';
|
import { fromARPA, getIPNetworkType, getNetworksCount, getSubnets, parseAsCIDR, to6to4Prefix, toARPA, toIPv4MappedAddress, toIPv4MappedAddressDecimal } from './ip';
|
||||||
|
|
||||||
describe('ipv4/6 util', () => {
|
describe('ipv4/6 util', () => {
|
||||||
describe('parseAsCIDR', () => {
|
describe('parseAsCIDR', () => {
|
||||||
@@ -195,10 +195,10 @@ describe('ipv4/6 util', () => {
|
|||||||
|
|
||||||
describe('toARPA', () => {
|
describe('toARPA', () => {
|
||||||
it('returns ARPA address', () => {
|
it('returns ARPA address', () => {
|
||||||
expect(toARPA('1.1.1.1')).to.eql('1.1.1.1.in-addr.arpa'); // NOSONAR
|
expect(toARPA('1.1.1.1')).to.eql('1.1.1.1.in-addr.arpa.'); // NOSONAR
|
||||||
expect(toARPA('10.10.1.1')).to.eql('1.1.10.10.in-addr.arpa'); // NOSONAR
|
expect(toARPA('10.10.1.1')).to.eql('1.1.10.10.in-addr.arpa.'); // NOSONAR
|
||||||
expect(toARPA('192.168.1.1')).to.eql('1.1.168.192.in-addr.arpa'); // NOSONAR
|
expect(toARPA('192.168.1.1')).to.eql('1.1.168.192.in-addr.arpa.'); // NOSONAR
|
||||||
expect(toARPA('255.255.255.0')).to.eql('0.255.255.255.in-addr.arpa'); // NOSONAR
|
expect(toARPA('255.255.255.0')).to.eql('0.255.255.255.in-addr.arpa.'); // NOSONAR
|
||||||
expect(toARPA('FF02::2')).to.eql('2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.f.f.ip6.arpa.'); // NOSONAR
|
expect(toARPA('FF02::2')).to.eql('2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.f.f.ip6.arpa.'); // NOSONAR
|
||||||
expect(toARPA('2345:0425:2CA1:0000:0000:0567:5673:23b5')).to.eql('5.b.3.2.3.7.6.5.7.6.5.0.0.0.0.0.0.0.0.0.1.a.c.2.5.2.4.0.5.4.3.2.ip6.arpa.'); // NOSONAR
|
expect(toARPA('2345:0425:2CA1:0000:0000:0567:5673:23b5')).to.eql('5.b.3.2.3.7.6.5.7.6.5.0.0.0.0.0.0.0.0.0.1.a.c.2.5.2.4.0.5.4.3.2.ip6.arpa.'); // NOSONAR
|
||||||
expect(toARPA('fdf8:f53b:82e4::53')).to.eql('3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.e.2.8.b.3.5.f.8.f.d.f.ip6.arpa.'); // NOSONAR
|
expect(toARPA('fdf8:f53b:82e4::53')).to.eql('3.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.e.2.8.b.3.5.f.8.f.d.f.ip6.arpa.'); // NOSONAR
|
||||||
@@ -235,4 +235,12 @@ describe('ipv4/6 util', () => {
|
|||||||
expect(to6to4Prefix('2001:db8:0:85a3::ac1f:8001')).to.eql(''); // NOSONAR
|
expect(to6to4Prefix('2001:db8:0:85a3::ac1f:8001')).to.eql(''); // NOSONAR
|
||||||
}); // NOSONAR
|
}); // NOSONAR
|
||||||
}); // NOSONAR
|
}); // NOSONAR
|
||||||
|
describe('fromARPA', () => {
|
||||||
|
it('returns IP', () => {
|
||||||
|
expect(fromARPA('42.2.0.192.in-addr.arpa.')).to.eql('192.0.2.42'); // NOSONAR
|
||||||
|
expect(fromARPA('42.2.0.192.in-addr.arpa')).to.eql('192.0.2.42'); // NOSONAR
|
||||||
|
expect(fromARPA('e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.')).to.eql('2001:0:ce49:7601:e866:efff:62c3:fffe'); // NOSONAR
|
||||||
|
expect(fromARPA('e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa')).to.eql('2001:0:ce49:7601:e866:efff:62c3:fffe'); // NOSONAR
|
||||||
|
}); // NOSONAR
|
||||||
|
}); // NOSONAR
|
||||||
}); // NOSONAR
|
}); // NOSONAR
|
||||||
+15
-1
@@ -122,12 +122,26 @@ export function toARPA(address: string) {
|
|||||||
(bigInt >> BigInt(24) & BigInt(255)),
|
(bigInt >> BigInt(24) & BigInt(255)),
|
||||||
].join('.')
|
].join('.')
|
||||||
);
|
);
|
||||||
return `${reverseIP}.in-addr.arpa`;
|
return `${reverseIP}.in-addr.arpa.`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new Address6(address)).reverseForm();
|
return (new Address6(address)).reverseForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fromARPA(arpa: string) {
|
||||||
|
if (!arpa) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!arpa.endsWith('.')) {
|
||||||
|
arpa = `${arpa}.`;
|
||||||
|
}
|
||||||
|
if (arpa.includes('.in-addr.arpa')) {
|
||||||
|
return Address4.fromArpa(arpa).correctForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Address6.fromArpa(arpa).correctForm();
|
||||||
|
}
|
||||||
|
|
||||||
export function toIPv4MappedAddress(address: string) {
|
export function toIPv4MappedAddress(address: string) {
|
||||||
if (!isIPv4(address)) {
|
if (!isIPv4(address)) {
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
Reference in new issue
Block a user