ipblocklist

package
v2.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ipblocklist contains default implementation of the mtglib.IPBlocklist for mtg.

Please check documentation for mtglib.IPBlocklist interface to get an idea of this abstraction.

Index

Constants

View Source
const (
	// DefaultFireholDownloadConcurrency defines a default max number of
	// concurrent downloads of ip blocklists for Firehol.
	DefaultFireholDownloadConcurrency = 1

	// DefaultFireholUpdateEach defines a default time period when Firehol
	// requests updates of the blocklists.
	DefaultFireholUpdateEach = 6 * time.Hour
)

Variables

This section is empty.

Functions

func NewNoop

func NewNoop() mtglib.IPBlocklist

NewNoop returns a dummy ipblocklist which allows all incoming connections.

Types

type Firehol

type Firehol struct {
	// contains filtered or unexported fields
}

Firehol is mtglib.IPBlocklist which uses lists from FireHOL: https://iplists.firehol.org/

It can use both local files and remote URLs. This is not necessary that blocklists should be taken from this website, we expect only compatible formats here.

Example of the format:

# this is a comment
# to ignore
127.0.0.1   # you can specify an IP
10.0.0.0/8  # or cidr

func NewFirehol

func NewFirehol(logger mtglib.Logger, network mtglib.Network,
	downloadConcurrency uint,
	urls []string,
	localFiles []string,
	updateCallback FireholUpdateCallback,
) (*Firehol, error)

NewFirehol creates a new instance of FireHOL IP blocklist.

This method does not start an update process so please execute Run when it is necessary.

func NewFireholFromFiles added in v2.1.3

func NewFireholFromFiles(logger mtglib.Logger,
	downloadConcurrency uint,
	blocklists []files.File,
	updateCallback FireholUpdateCallback,
) (*Firehol, error)

NewFirehol creates a new instance of FireHOL IP blocklist.

This method creates this instances from a given list of files.

func (*Firehol) Contains

func (f *Firehol) Contains(ip net.IP) bool

Contains is given IP list can be found in FireHOL blocklists.

func (*Firehol) Run

func (f *Firehol) Run(updateEach time.Duration)

Run starts a background update process.

This is a blocking method so you probably want to run it in a goroutine.

func (*Firehol) Shutdown

func (f *Firehol) Shutdown()

Shutdown stop a background update process.

type FireholUpdateCallback added in v2.1.5

type FireholUpdateCallback func(context.Context, int)

FireholUpdateCallback defines a signature of the callback that has to be execute when ip list is updated.

Directories

Path Synopsis
files defines a set of abstraction for 'files': an openable entities that could be read after.
files defines a set of abstraction for 'files': an openable entities that could be read after.

Jump to

Keyboard shortcuts

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