ipblocklist

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package ipblocklist contains default implementation of the 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 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,
	remoteURLs []string,
	localFiles []string) (*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 (*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.

Jump to

Keyboard shortcuts

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