filters

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPRange

type IPRange struct {
	Lower net.IP
	Upper net.IP
}

IPRange is a range of IP represented by a lower and an upper bound

func NewIPRange

func NewIPRange(lower net.IP, upper net.IP) IPRange

NewIPRange created a new ip range from a lower and an upper bound

func (IPRange) ContainsIP

func (iprg IPRange) ContainsIP(ip net.IP) bool

ContainsIP is an helper that checks if a range contains the given IP

func (IPRange) ContainsIPRange

func (iprg IPRange) ContainsIPRange(iprange IPRange) bool

ContainsIPRange is an helper that checks if a range contains the given IP range

func (IPRange) ContainsIPString

func (iprg IPRange) ContainsIPString(ipstr string) bool

ContainsIPString is an helper that checks if a range contains the given IP string

func (*IPRange) Equals

func (iprg *IPRange) Equals(iprange IPRange) bool

Equals is an helper that checks if an IPRange is equal to another

func (IPRange) IsUpperOrLowerBoundary

func (iprg IPRange) IsUpperOrLowerBoundary(ip net.IP) bool

IsUpperOrLowerBoundary is an helper that checks if the given IP is either the lower of the upper bound of a range

type IPRanges

type IPRanges []IPRange

IPRanges abstracts an array of IPRange

func (*IPRanges) Add

func (iprgs *IPRanges) Add(ip net.IP)

Add is an helper that adds a range made of a single IP

func (*IPRanges) AddRange

func (iprgs *IPRanges) AddRange(lower net.IP, upper net.IP)

AddRange is an helper that adds a range of IP made of two IPs

func (*IPRanges) AddString

func (iprgs *IPRanges) AddString(ipstr string) error

AddString is an helper that parses and adds a range of IP from a string

func (*IPRanges) MergeOverlapping

func (iprgs *IPRanges) MergeOverlapping()

MergeOverlapping optimize the parsed IPRange by keeping only non-overlapping ranges

func (*IPRanges) RemoveAt

func (iprgs *IPRanges) RemoveAt(index int)

RemoveAt is an helper that removes a range at the the given index

type IPRules

type IPRules struct {
	WhitelistedIPs IPRanges
	BlacklistedIPs IPRanges
}

IPRules groups the whitelisted and blacklisted ip rules

func (*IPRules) Blacklist

func (iprl *IPRules) Blacklist(ip string) error

Blacklist checks the validity of an IP string and adds it to the IPRules' blacklist

func (*IPRules) BlacklistCIDR

func (iprl *IPRules) BlacklistCIDR(rawIPCIDR string) error

BlacklistCIDR parses and adds a CIDR string to the IPRules' blacklist

func (*IPRules) BlacklistRange

func (iprl *IPRules) BlacklistRange(rawIPRange string) error

BlacklistRange parses and adds an IP range string to the IPRules' blacklist

func (*IPRules) ParseRules

func (iprl *IPRules) ParseRules(whitelist []string, blacklist []string)

ParseRules loads a whitelist and a blacklist into a set of IPRules

func (*IPRules) Whitelist

func (iprl *IPRules) Whitelist(ip string) error

Whitelist checks the validity of an IP string and adds it to the IPRules' whitelist

func (*IPRules) WhitelistCIDR

func (iprl *IPRules) WhitelistCIDR(rawIPCIDR string) error

WhitelistCIDR parses and adds a CIDR string to the IPRules' whitelist

func (*IPRules) WhitelistRange

func (iprl *IPRules) WhitelistRange(rawIPRange string) error

WhitelistRange parses and adds an IP range string to the IPRules' whitelist

type PortRange

type PortRange struct {
	Lower uint16
	Upper uint16
}

PortRange is a range of Port represented by a lower and an upper bound

func NewPortRange

func NewPortRange(lower uint16, upper uint16) PortRange

NewPortRange created a new ip range from a lower and an upper bound

func (PortRange) ContainsPort

func (prg PortRange) ContainsPort(port uint16) bool

ContainsPort is an helper that checks if a range contains the given Port

func (PortRange) ContainsPortRange

func (prg PortRange) ContainsPortRange(portRange PortRange) bool

ContainsPortRange is an helper that checks if a range contains the given Port range

func (*PortRange) Equals

func (prg *PortRange) Equals(portRange PortRange) bool

Equals is an helper that checks if a PortRange is equal to another

func (PortRange) IsUpperOrLowerBoundary

func (prg PortRange) IsUpperOrLowerBoundary(port uint16) bool

IsUpperOrLowerBoundary is an helper that checks if the given Port is either the lower of the upper bound of a range

type PortRanges

type PortRanges []PortRange

PortRanges abstracts an array of PortRange

func (*PortRanges) Add

func (prgs *PortRanges) Add(port uint16)

Add is an helper that adds a range made of a single Port

func (*PortRanges) AddRange

func (prgs *PortRanges) AddRange(lower uint16, upper uint16)

AddRange is an helper that parses and adds a range of Port

func (*PortRanges) MergeOverlapping

func (prgs *PortRanges) MergeOverlapping()

MergeOverlapping optimize the parsed PortRange by keeping only non-overlapping ranges

func (*PortRanges) RemoveAt

func (prgs *PortRanges) RemoveAt(index int)

RemoveAt is an helper that removes a range at the the given index

type PortRules

type PortRules struct {
	WhitelistedPorts PortRanges
	BlacklistedPorts PortRanges
}

PortRules groups the whitelisted and blacklisted ip rules

func (*PortRules) Blacklist

func (prls *PortRules) Blacklist(port string) error

Blacklist checks the validity of a Port string and adds it to the PortRules' blacklist

func (*PortRules) BlacklistRange

func (prls *PortRules) BlacklistRange(rawPortRange string) error

BlacklistRange parses and adds a Port range string to the PortRules' blacklist

func (*PortRules) ParseRules

func (prls *PortRules) ParseRules(whitelist []string, blacklist []string)

ParseRules loads a whitelist and a blacklist into a set of PortRules

func (*PortRules) Whitelist

func (prls *PortRules) Whitelist(port string) error

Whitelist checks the validity of a Port string and adds it to the PortRules' whitelist

func (*PortRules) WhitelistRange

func (prls *PortRules) WhitelistRange(rawPortRange string) error

WhitelistRange parses and adds a Port range string to the PortRules' whitelist

Jump to

Keyboard shortcuts

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