rule

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	INTERNAL_IPS = []string{
		"0.0.0.0/8",
		"127.0.0.0/8",
		"100.64.0.0/10",
		"10.0.0.0/8",
		"172.16.0.0/12",
		"192.168.0.0/16",
		"169.254.0.0/16",
		"192.0.0.0/24",
		"192.0.2.0/24",
		"192.18.0.0/15",
		"198.51.100.0/24",
		"203.0.113.0/24",
		"224.0.0.0/4",
		"192.88.99.0/24",
		"240.0.0.0/4",
		"fc00::/7",
		"fe80::/10",
	}
)

Functions

This section is empty.

Types

type CustomRule

type CustomRule struct {
	Ports []uint32 `yaml:"ports"`
	Name  string   `yaml:"name"`
}

type CustomRuleSet

type CustomRuleSet struct {
	Applications []CustomRule `yaml:"applications"`
}

type IPAddressRules

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

IPAddressRules manages rules associated with IPAddresses

func NewIPAddressRules

func NewIPAddressRules() *IPAddressRules

NewIPAddressRules returns a new IPAddressRules

func (*IPAddressRules) AddIPAddress

func (r *IPAddressRules) AddIPAddress(ipAddress string, matchType Match) error

AddIPAddress adds a rule match by IP Address

func (*IPAddressRules) Check

func (r *IPAddressRules) Check(ip net.IP) Match

Check checks which Matches match the input IP

type Match

type Match uint32

Match holds IP/ASN match results in a bitmask - can match multiple types

var MatchNone Match = 0

MatchNone is a Match that represents no match

var MatchPrivateASN Match = 7

MatchPrivateASN is a Match that represents a match from a static list of private ASNs (non-cloud)

var MatchPrivateIP Match = 1

MatchPrivateIP is a Match that represents a match from a static list of private IPs

func NewMatch

func NewMatch(ruleMatch uint32) Match

NewMatch returns a new Match

func (Match) Uint32

func (m Match) Uint32() uint32

Uint32 returns a uint32 version

type RuleSet

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

RuleSet holds a list of network classification rules

func NewRuleSet

func NewRuleSet(appMap string, log logger.ContextL) (*RuleSet, error)

NewRuleSet returns a new RuleSet

func (*RuleSet) GetService

func (r *RuleSet) GetService(ip net.IP, port uint32, protocol uint8) (string, bool)

IP is for future proofing if there's demand.

func (*RuleSet) IsInternal

func (r *RuleSet) IsInternal(ip net.IP, as uint32) bool

IsInternal returns whether an IP/ASN is from static list of private IPs.

Jump to

Keyboard shortcuts

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