cdncheck

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 8 Imported by: 96

README

cdncheck

Helper library that checks if a given IP belongs to known CDN ranges (akamai, cloudflare, incapsula and sucuri). The library can be used by importing github.com/projectdiscovery/cdncheck. here follows a basic example:

package main

import (
    "log"
    "net"
    "github.com/projectdiscovery/cdncheck"
)

func main() {
    // uses projectdiscovery endpoint with cached data to avoid ip ban
    // Use cdncheck.New() if you want to scrape each endpoint (don't do it too often or your ip can be blocked)
    client, err := cdncheck.NewWithCache()
    if err != nil {
        log.Fatal(err)
    }
    if found, err := client.Check(net.ParseIP("173.245.48.12")); found && err == nil {
        log.Println("ip is part of cdn")
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Data map[string]struct{}
	// contains filtered or unexported fields
}

Client checks for CDN based IPs which should be excluded during scans since they belong to third party firewalls.

func New

func New() (*Client, error)

New creates a new firewall IP checking client.

func NewWithCache

func NewWithCache() (*Client, error)

NewWithCache creates a new firewall IP with cached data from project discovery (faster)

func (*Client) Check

func (c *Client) Check(ip net.IP) (bool, error)

Check checks if an IP is contained in the blacklist

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL