Full Toolkit for Next-Level Domain Analysis
Add link to reverse domain results in IP Modal 🔗
Felix Wotschofsky3e3d3e512b74
diff --git a/components/IpDetailsModal.tsx b/components/IpDetailsModal.tsxindex 02efe6c..71c2799 100644--- a/components/IpDetailsModal.tsx+++ b/components/IpDetailsModal.tsx@@ -1,7 +1,11 @@import dynamic from 'next/dynamic';+import NextLink from 'next/link';+import { ExternalLinkIcon } from '@chakra-ui/icons';import {chakra,Flex,+ IconButton,+ Link,Modal,ModalBody,ModalCloseButton,@@ -12,6 +16,7 @@ import {Table,Tbody,Td,+ Tooltip,Tr,} from '@chakra-ui/react';import { css } from '@emotion/react';@@ -20,6 +25,16 @@ import type { LatLngExpression } from 'leaflet';import type { IpLookupResponse } from '@/api/lookupIp';+enum EntryTypes {+ IP,+ Reverse,+ Organization,+ ISP,+ Location,+ Coordinates,+ Timezone,+}+type IpDetailsModalProps = {ip: string;isOpen: boolean;@@ -31,36 +46,43 @@ const IpDetailsModal = (props: IpDetailsModalProps) => {props.isOpen ? `/api/lookupIp?ip=${encodeURIComponent(props.ip)}` : null);- let mappedEntries: { label: string; value: string }[] = [];+ let mappedEntries: { label: string; value: string; type: EntryTypes }[] = [];let location: LatLngExpression = [0, 0];if (data) {mappedEntries = [{+ type: EntryTypes.IP,label: 'IP',value: props.ip,},...data.reverse.map((address) => ({+ type: EntryTypes.Reverse,label: 'Reverse',value: address,})),{+ type: EntryTypes.Organization,label: 'Organization',value: data.org,},{+ type: EntryTypes.ISP,label: 'ISP',value: data.isp,},{+ type: EntryTypes.Location,label: 'Location',value: `${data.country}, ${data.region}, ${data.city}`,},{+ type: EntryTypes.Coordinates,label: 'Coordinates',value: `Latitude: ${data.lat}; Longitude: ${data.lon}`,},{+ type: EntryTypes.Timezone,label: 'Timezone',value: data.timezone,},@@ -93,7 +115,27 @@ const IpDetailsModal = (props: IpDetailsModalProps) => {{mappedEntries.map((el) => (<Tr key={el.label + el.value}><Td pl={0}>{el.label}</Td>- <Td pr={0}>{el.value}</Td>+ <Td pr={0}>+ <>+ <span>{el.value}</span>{' '}+ {el.type === EntryTypes.Reverse && (+ <Tooltip label="View Domain Records">+ <NextLink href={`/lookup/${el.value}`} passHref>+ <Link>+ <IconButton+ variant="link"+ size="sm"+ ml={-2.5}+ mr={-1.5}+ aria-label="View Domain Records"+ icon={<ExternalLinkIcon />}+ />+ </Link>+ </NextLink>+ </Tooltip>+ )}+ </>+ </Td></Tr>))}</Tbody>diff --git a/components/RecordRow.tsx b/components/RecordRow.tsxindex ed96a90..94423c7 100644--- a/components/RecordRow.tsx+++ b/components/RecordRow.tsx@@ -9,7 +9,7 @@ import {useDisclosure,} from '@chakra-ui/react';import { useRouter } from 'next/router';-import { useState, ReactNodeArray } from 'react';+import { ReactNodeArray, useEffect, useState } from 'react';import isIP from 'validator/lib/isIP';import NextLink from 'next/link';import reactStringReplace from 'react-string-replace';@@ -21,9 +21,18 @@ const domainRegex =/(_)*(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;const RecordRow = ({ record }: { record: RawRecord }) => {+ const router = useRouter();const [detailedIp, setDetailedIp] = useState<string | null>(null);const { isOpen, onOpen, onClose } = useDisclosure();+ useEffect(() => {+ router.events.on('routeChangeStart', onClose);++ return () => {+ router.events.off('routeChangeStart', onClose);+ };+ });+let interpolatedValue: ReactNodeArray | null = null;const domainMatches = record.data.match(domainRegex);