From ba96de2c59bfd02971c38d07eeba1a6feb9487c8 Mon Sep 17 00:00:00 2001 From: Brendan <94894839+abrendan@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:45:38 +0000 Subject: [PATCH] Added reverse domain lookup by IP --- index.js | 14 +++++++++++++- public/index.html | 32 +++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f85f937..6beb037 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,18 @@ app.post('/reverseLookup', async (req, res) => { } }); +// Endpoint for performing reverse domain lookup by IP +app.post('/reverseLookupByIP', async (req, res) => { + try { + const { ip } = req.body; + const reverseResult = await dns.reverse(ip); + res.json({ success: true, ip, reverseResult }); + } catch (error) { + console.error(error); + res.status(500).json({ success: false, message: 'Reverse lookup failed', error: error.message }); + } +}); + app.post('/whoisLookup', (req, res) => { const { domain } = req.body; whois.lookup(domain, (err, data) => { @@ -39,4 +51,4 @@ app.post('/whoisLookup', (req, res) => { app.listen(port, () => { console.log(`Server running at http://localhost:${port}`); -}); +}); \ No newline at end of file diff --git a/public/index.html b/public/index.html index 7b0472f..2571db9 100644 --- a/public/index.html +++ b/public/index.html @@ -7,15 +7,23 @@