diff --git a/src/tools/arpa-decoder/arpa-decoder.vue b/src/tools/arpa-decoder/arpa-decoder.vue new file mode 100644 index 00000000..db6a5dc7 --- /dev/null +++ b/src/tools/arpa-decoder/arpa-decoder.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/tools/arpa-decoder/index.ts b/src/tools/arpa-decoder/index.ts new file mode 100644 index 00000000..2ca3fd33 --- /dev/null +++ b/src/tools/arpa-decoder/index.ts @@ -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', +}); diff --git a/src/tools/ptr-dns-generator/index.ts b/src/tools/ptr-dns-generator/index.ts new file mode 100644 index 00000000..22ac3251 --- /dev/null +++ b/src/tools/ptr-dns-generator/index.ts @@ -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', +}); diff --git a/src/tools/ptr-dns-generator/ptr-dns-generator.vue b/src/tools/ptr-dns-generator/ptr-dns-generator.vue new file mode 100644 index 00000000..cc3f11b3 --- /dev/null +++ b/src/tools/ptr-dns-generator/ptr-dns-generator.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/utils/ip.test.ts b/src/utils/ip.test.ts index e78c67d9..69f8e5ff 100644 --- a/src/utils/ip.test.ts +++ b/src/utils/ip.test.ts @@ -1,5 +1,5 @@ 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('parseAsCIDR', () => { @@ -195,10 +195,10 @@ describe('ipv4/6 util', () => { describe('toARPA', () => { it('returns ARPA address', () => { - 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('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('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('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('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('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 }); // 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 diff --git a/src/utils/ip.ts b/src/utils/ip.ts index f0be59d5..06827876 100644 --- a/src/utils/ip.ts +++ b/src/utils/ip.ts @@ -122,12 +122,26 @@ export function toARPA(address: string) { (bigInt >> BigInt(24) & BigInt(255)), ].join('.') ); - return `${reverseIP}.in-addr.arpa`; + return `${reverseIP}.in-addr.arpa.`; } 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) { if (!isIPv4(address)) { return '';