ipfilter

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2019 License: BSD-3-Clause, GPL-2.0 Imports: 13 Imported by: 6

Documentation

Overview

Package lru implements an LRU cache.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDNSNotFound = errors.New("dns not found")
	ErrType        = errors.New("type error")
)

Functions

func ListConatins

func ListConatins(iplist []*net.IPNet, ip net.IP) bool

func ParseLine

func ParseLine(line string) (ipnet *net.IPNet, err error)

Types

type Cache

type Cache struct {
	// MaxEntries is the maximum number of cache entries before
	// an item is evicted. Zero means no limit.
	MaxEntries int

	// OnEvicted optionally specificies a callback function to be
	// executed when an entry is purged from the cache.
	OnEvicted func(key Key, value interface{})
	// contains filtered or unexported fields
}

Cache is an LRU cache. It is not safe for concurrent access.

func New

func New(maxEntries int) *Cache

New creates a new Cache. If maxEntries is zero, the cache has no limit and it's assumed that eviction is done by the caller.

func (*Cache) Add

func (c *Cache) Add(key Key, value interface{})

Add adds a value to the cache.

func (*Cache) Get

func (c *Cache) Get(key Key) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Remove

func (c *Cache) Remove(key Key)

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

type DNSCache

type DNSCache struct {
	common.Resolver
	// contains filtered or unexported fields
}

func CreateDNSCache

func CreateDNSCache(resolver common.Resolver) (dc *DNSCache)

func (*DNSCache) LookupIP

func (dc *DNSCache) LookupIP(hostname string) (addrs []net.IP, err error)

type FilterPair

type FilterPair struct {
	common.Dialer
	*IPFilter
}

type FilteredDialer

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

func NewFilteredDialer

func NewFilteredDialer(def common.Dialer, resolver common.Resolver) (fd *FilteredDialer)

func (*FilteredDialer) Dial

func (fd *FilteredDialer) Dial(network, address string) (conn net.Conn, err error)

func (*FilteredDialer) DialTimeout

func (fd *FilteredDialer) DialTimeout(network, address string, timeout time.Duration) (conn net.Conn, err error)

func (*FilteredDialer) Getaddrs

func (fd *FilteredDialer) Getaddrs(hostname string) (ips []net.IP)

func (*FilteredDialer) LoadFilter

func (fd *FilteredDialer) LoadFilter(dialer common.Dialer, filename string) (err error)

type IPFilter

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

func ReadIPList

func ReadIPList(f io.Reader) (filter *IPFilter, err error)

func ReadIPListFile

func ReadIPListFile(filename string) (filter *IPFilter, err error)

func (IPFilter) Contain

func (f IPFilter) Contain(ip net.IP) bool

type Key

type Key interface{}

A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators

Jump to

Keyboard shortcuts

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