hosterrorscache

package
v3.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 14 Imported by: 6 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultMaxHostsCount = 10000

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	MaxHostError int

	TrackError []string
	// contains filtered or unexported fields
}

Cache is a cache for host based errors. It allows skipping certain hosts based on an error threshold.

It uses an LRU cache internally for skipping unresponsive hosts that remain so for a duration.

func New

func New(maxHostError, maxHostsCount int, trackError []string) *Cache

New returns a new host max errors cache

func (*Cache) Check

func (c *Cache) Check(protoType string, ctx *contextargs.Context) bool

Check returns true if a host should be skipped as it has been unresponsive for a certain number of times.

The value can be many formats -

  • URL: https?:// type
  • Host:port type
  • host type

func (*Cache) Close

func (c *Cache) Close()

Close closes the host errors cache

func (*Cache) GetKeyFromContext added in v3.2.8

func (c *Cache) GetKeyFromContext(ctx *contextargs.Context, err error) string

GetKeyFromContext returns the key for the cache from the context

func (*Cache) IsPermanentErr added in v3.7.0

func (c *Cache) IsPermanentErr(ctx *contextargs.Context, err error) bool

IsPermanentErr returns true if the error is permanent for the host.

func (*Cache) MarkFailed deprecated

func (c *Cache) MarkFailed(protoType string, ctx *contextargs.Context, err error)

MarkFailed marks a host as failed previously

Deprecated: Use MarkFailedOrRemove instead.

func (*Cache) MarkFailedOrRemove added in v3.3.9

func (c *Cache) MarkFailedOrRemove(protoType string, ctx *contextargs.Context, err error)

MarkFailedOrRemove marks a host as failed previously or removes it

func (*Cache) NormalizeCacheValue added in v3.3.3

func (c *Cache) NormalizeCacheValue(value string) string

NormalizeCacheValue processes the input value and returns a normalized cache value.

func (*Cache) Remove added in v3.3.9

func (c *Cache) Remove(ctx *contextargs.Context)

Remove removes a host from the cache

func (*Cache) SetVerbose

func (c *Cache) SetVerbose(verbose bool)

SetVerbose sets the cache to log at verbose level

type CacheInterface

type CacheInterface interface {
	SetVerbose(verbose bool)                                                  // log verbosely
	Close()                                                                   // close the cache
	Check(protoType string, ctx *contextargs.Context) bool                    // return true if the host should be skipped
	Remove(ctx *contextargs.Context)                                          // remove a host from the cache
	MarkFailed(protoType string, ctx *contextargs.Context, err error)         // record a failure (and cause) for the host
	MarkFailedOrRemove(protoType string, ctx *contextargs.Context, err error) // record a failure (and cause) for the host or remove it
	IsPermanentErr(ctx *contextargs.Context, err error) bool                  // return true if the error is permanent for the host
}

CacheInterface defines the signature of the hosterrorscache so that users of Nuclei as embedded lib may implement their own cache

Jump to

Keyboard shortcuts

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