Skip to content

roccomuso/is-duckduck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is-duckduck

NPM Version Build Status node Dependency Status JavaScript Style Guide

Verify that a request is from DuckDuckBot, the Web crawler for DuckDuckGo

This library implements DuckDuckGo's own verification steps outlined here.

Install

npm install --save is-duckduck

Example

const isDuckDuck = require('is-duckduck')

let ip = '72.94.249.34'
isDuckDuck(ip).then((outcome) => {
  if (outcome) {
    // it's duckduck.
  }
}).catch(console.error)

Example with express

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
    }
  })
})

Tests

npm test

License

MIT

Author

Rocco Musolino @roccomuso

About

Verify that a request is from DuckDuckBot, the Web crawler for DuckDuckGo

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published