Verify that a request is from DuckDuckBot, the Web crawler for DuckDuckGo
This library implements DuckDuckGo's own verification steps outlined here.
npm install --save is-duckduck
const isDuckDuck = require('is-duckduck')
let ip = '72.94.249.34'
isDuckDuck(ip).then((outcome) => {
if (outcome) {
// it's duckduck.
}
}).catch(console.error)
app.enable('trust proxy')
app.use((req, res, next) => {
let ip = req.ip || req.connection.remoteAddress
isDuckDuck(ip).then(outcome => {
if (outcome) {
res.status(404).text('Nothing to scan') // block duckduck crawler
} else {
next() // it's a user
}
})
})
npm test
MIT
Rocco Musolino @roccomuso