Socket
Socket
Sign inDemoInstall

googlebot-verify

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    googlebot-verify

Verify that a request is from Google using Google's recommended DNS verification steps


Version published
Weekly downloads
549
increased by68.92%
Maintainers
1
Install size
5.25 kB
Created
Weekly downloads
 

Readme

Source

googlebot-verify

Build Status Coverage Status

Synopsis

Verify that an IP address is from Google using Google's recommended DNS verification steps.

Motivation

You may wish to verify that a web crawler accessing your server is Googlebot (or another Google user-agent) and not spammers or other bots scraping your site while claiming to be Googlebot. Since you cannot rely on the User-Agent header which is easily spoofed, you need to use DNS look up to verify that the IP address belongs to Google.

This library implements Google's own verification steps outlined here: https://support.google.com/webmasters/answer/80553?hl=en

Installation

npm install googlebot-verify

Code Examples

Using a callback

  const verify = require('googlebot-verify');
  const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;

  verify(ip, (error, isGoogle) => {
    if (isGoogle) {
      // do something with result...
    }
  });

Using a Promise

  verify(ip)
  .then( isGoogle => { /* handle result */ })
  .catch( e => { /* handle error */ });

Tests

npm test

License

MIT

Keywords

FAQs

Last updated on 18 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc