ipexist

package
v4.0.0-...-5981c31 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 10 Imported by: 0

README

ipexist

A library for efficiently storing and checking for the existence of an IPv4 set with high density sets.

Purpose

The purpose of this library is to trade the size of the resulting set for efficiency in lookups.

For very sparse IP sets the memory footprint is innefficient, for very dense sets the footprint can be very efficient.

Documentation

Index

Constants

View Source
const (
	AccessNormal     uintptr = 0
	AccessRandom     uintptr = 1
	AccessSequential uintptr = 2

	//memory map protection bits
	ProtRO uintptr = 0x1
	ProtWO uintptr = 0x2
	ProtRW uintptr = 0x3

	//memory map control bits
	MapShared  uintptr = 0x1
	MapPrivate uintptr = 0x2
)

Variables

View Source
var (
	ErrInvalidIPv4       = errors.New("Invalid IPv4 Address")
	ErrInvalidBaseOffset = errors.New("Invalid IPv4 base offset, potential corruption")
	ErrNotMmapBacked     = errors.New("IPBitMap is not backed by a memory map")
)
View Source
var (
	ErrInvalidFileHandle = errors.New("Invalid file handle")
	ErrMapClosed         = errors.New("File mapping closed")
	ErrOutsideOfBounds   = errors.New("Size is outside of file bounds")
	ErrFileTooLarge      = errors.New("Mapped file is too large")
)

Functions

func CheckDecodeHeader

func CheckDecodeHeader(r io.Reader) (err error)

Types

type FileMap

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

func MapFile

func MapFile(f *os.File) (*FileMap, error)

func (*FileMap) Close

func (m *FileMap) Close() error

func (*FileMap) Expand

func (m *FileMap) Expand() (err error)

func (*FileMap) Preload

func (m *FileMap) Preload(offset int64, sz int64) (err error)

func (*FileMap) PreloadFile

func (m *FileMap) PreloadFile() (err error)

func (*FileMap) SetSize

func (m *FileMap) SetSize(sz int64) error

func (*FileMap) Size

func (m *FileMap) Size() int64

type IpBitMap

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

func LoadIPBitMap

func LoadIPBitMap(r io.Reader) (*IpBitMap, error)

func LoadIPBitMapMemoryMapped

func LoadIPBitMapMemoryMapped(r io.Reader, p string) (*IpBitMap, error)

func NewIPBitMap

func NewIPBitMap() *IpBitMap

func NewIPBitMapMemoryMapped

func NewIPBitMapMemoryMapped(p string) (ipm *IpBitMap, err error)

func (*IpBitMap) AddIP

func (ipbm *IpBitMap) AddIP(ip net.IP) (err error)

func (*IpBitMap) Close

func (ipbm *IpBitMap) Close() (err error)

func (*IpBitMap) Decode

func (ipbm *IpBitMap) Decode(r io.Reader) (err error)

func (*IpBitMap) Encode

func (ipbm *IpBitMap) Encode(w io.Writer) (err error)

func (*IpBitMap) IPExists

func (ipbm *IpBitMap) IPExists(ip net.IP) (ok bool, err error)

func (*IpBitMap) RemoveIP

func (ipbm *IpBitMap) RemoveIP(ip net.IP) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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