21 lines
417 B
JavaScript
21 lines
417 B
JavaScript
|
const express = require('express')
|
||
|
const { Resolver } = require('dns').promises
|
||
|
|
||
|
const app = express()
|
||
|
const r = new Resolver()
|
||
|
|
||
|
app.get('/', async (req, res) => {
|
||
|
res.header('Content-type: text/plain')
|
||
|
const ip = req.connection.remoteAddress
|
||
|
let host
|
||
|
try {
|
||
|
host = await r.reverse(ip)
|
||
|
} catch(err) {
|
||
|
console.log(err.message)
|
||
|
host = 'ERR'
|
||
|
}
|
||
|
res.send(`${ip}\n${host}\n`)
|
||
|
})
|
||
|
|
||
|
app.listen(18080)
|