mirror of
https://github.com/Lissy93/web-check.git
synced 2025-06-19 19:28:00 +02:00
Adds component for displaying DNS results
This commit is contained in:
parent
e0ffc8e418
commit
8d8307e60e
@ -16,6 +16,7 @@ import SslCertCard from 'components/Results/SslCert';
|
|||||||
import HeadersCard from 'components/Results/Headers';
|
import HeadersCard from 'components/Results/Headers';
|
||||||
import CookiesCard from 'components/Results/Cookies';
|
import CookiesCard from 'components/Results/Cookies';
|
||||||
import RobotsTxtCard from 'components/Results/RobotsTxt';
|
import RobotsTxtCard from 'components/Results/RobotsTxt';
|
||||||
|
import DnsRecordsCard from 'components/Results/DnsRecords';
|
||||||
import keys from 'utils/get-keys';
|
import keys from 'utils/get-keys';
|
||||||
import { determineAddressType, AddressType } from 'utils/address-type-checker';
|
import { determineAddressType, AddressType } from 'utils/address-type-checker';
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ const ResultsContent = styled.section`
|
|||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: calc(100% - 2rem);
|
width: calc(100% - 2rem);
|
||||||
|
padding-bottom: 1rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Header = styled(Card)`
|
const Header = styled(Card)`
|
||||||
@ -63,6 +65,7 @@ const Results = (): JSX.Element => {
|
|||||||
const [ lighthouseResults, setLighthouseResults ] = useState<any>();
|
const [ lighthouseResults, setLighthouseResults ] = useState<any>();
|
||||||
const [ sslResults, setSslResults ] = useState<any>();
|
const [ sslResults, setSslResults ] = useState<any>();
|
||||||
const [ headersResults, setHeadersResults ] = useState<any>();
|
const [ headersResults, setHeadersResults ] = useState<any>();
|
||||||
|
const [ dnsResults, setDnsResults ] = useState<any>();
|
||||||
const [ robotsTxtResults, setRobotsTxtResults ] = useState<any>();
|
const [ robotsTxtResults, setRobotsTxtResults ] = useState<any>();
|
||||||
const [ cookieResults, setCookieResults ] = useState<Cookie[] | null>(null);
|
const [ cookieResults, setCookieResults ] = useState<Cookie[] | null>(null);
|
||||||
const [ screenshotResult, setScreenshotResult ] = useState<string>();
|
const [ screenshotResult, setScreenshotResult ] = useState<string>();
|
||||||
@ -81,6 +84,7 @@ const Results = (): JSX.Element => {
|
|||||||
const jobNames = [
|
const jobNames = [
|
||||||
'get-ip',
|
'get-ip',
|
||||||
'ssl',
|
'ssl',
|
||||||
|
'dns',
|
||||||
'cookies',
|
'cookies',
|
||||||
'robots-txt',
|
'robots-txt',
|
||||||
'headers',
|
'headers',
|
||||||
@ -197,6 +201,18 @@ const Results = (): JSX.Element => {
|
|||||||
.catch(err => updateLoadingJobs('headers', 'error', err));
|
.catch(err => updateLoadingJobs('headers', 'error', err));
|
||||||
}, [address, addressType])
|
}, [address, addressType])
|
||||||
|
|
||||||
|
/* Get DNS records */
|
||||||
|
useEffect(() => {
|
||||||
|
if (addressType !== 'url') return;
|
||||||
|
fetch(`/get-dns?url=${address}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => {
|
||||||
|
setDnsResults(response);
|
||||||
|
updateLoadingJobs('dns', 'success');
|
||||||
|
})
|
||||||
|
.catch(err => updateLoadingJobs('dns', 'error', err));
|
||||||
|
}, [address, addressType])
|
||||||
|
|
||||||
/* Get Lighthouse report */
|
/* Get Lighthouse report */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (addressType !== 'url') return;
|
if (addressType !== 'url') return;
|
||||||
@ -337,6 +353,7 @@ const Results = (): JSX.Element => {
|
|||||||
{ headersResults && <HeadersCard headers={headersResults} />}
|
{ headersResults && <HeadersCard headers={headersResults} />}
|
||||||
{ hostNames && <HostNamesCard hosts={hostNames} />}
|
{ hostNames && <HostNamesCard hosts={hostNames} />}
|
||||||
{ whoIsResults && <WhoIsCard {...whoIsResults} />}
|
{ whoIsResults && <WhoIsCard {...whoIsResults} />}
|
||||||
|
{ dnsResults && <DnsRecordsCard dnsRecords={dnsResults} />}
|
||||||
{ lighthouseResults && <LighthouseCard lighthouse={lighthouseResults} />}
|
{ lighthouseResults && <LighthouseCard lighthouse={lighthouseResults} />}
|
||||||
{ cookieResults && <CookiesCard cookies={cookieResults} />}
|
{ cookieResults && <CookiesCard cookies={cookieResults} />}
|
||||||
{ screenshotResult && <ScreenshotCard screenshot={screenshotResult} />}
|
{ screenshotResult && <ScreenshotCard screenshot={screenshotResult} />}
|
||||||
|
@ -148,8 +148,11 @@ type RobotsRule = {
|
|||||||
export const parseRobotsTxt = (content: string): RobotsRule[] => {
|
export const parseRobotsTxt = (content: string): RobotsRule[] => {
|
||||||
const lines = content.split('\n');
|
const lines = content.split('\n');
|
||||||
const rules: RobotsRule[] = [];
|
const rules: RobotsRule[] = [];
|
||||||
|
|
||||||
lines.forEach(line => {
|
lines.forEach(line => {
|
||||||
const match = line.match(/^(Allow|Disallow):\s*(\S*)$/);
|
line = line.trim(); // This removes trailing and leading whitespaces
|
||||||
|
|
||||||
|
let match = line.match(/^(Allow|Disallow):\s*(\S*)$/i);
|
||||||
if (match) {
|
if (match) {
|
||||||
const rule: RobotsRule = {
|
const rule: RobotsRule = {
|
||||||
lbl: match[1],
|
lbl: match[1],
|
||||||
@ -157,7 +160,20 @@ export const parseRobotsTxt = (content: string): RobotsRule[] => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
rules.push(rule);
|
rules.push(rule);
|
||||||
|
} else {
|
||||||
|
match = line.match(/^(User-agent):\s*(\S*)$/i);
|
||||||
|
if (match) {
|
||||||
|
const rule: RobotsRule = {
|
||||||
|
lbl: match[1],
|
||||||
|
val: match[2],
|
||||||
|
};
|
||||||
|
|
||||||
|
rules.push(rule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user