rules

package
v0.0.0-...-9ed9f2e Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddrTypeIPv4       byte = 0x01
	AddrTypeDomainName byte = 0x03
	AddrTypeIPv6       byte = 0x04

	ActionAccept = "ACCEPT"
	ActionProxy  = "PROXY"
	ActionReject = "REJECT"
	ActionDirect = "DIRECT"

	RuleTypeBypass         byte = 0x01
	RuleTypeHosts          byte = 0x02
	RuleTypeDomains        byte = 0x03
	RuleTypeSuffixDomains  byte = 0x04
	RuleTypeKeywordDomains byte = 0x05
	RuleTypeUserAgent      byte = 0x06
	RuleTypeIPCIDR         byte = 0x07
	RuleTypeGeoIP          byte = 0x08
	RuleTypePort           byte = 0x09
	RuleTypeFinal          byte = 0x0A
	RuleTypeMATCH          byte = 0x0B
)

Variables

This section is empty.

Functions

func FromGeoIP

func FromGeoIP(name string) (db *geoip2.Reader, err error)

func RuleType

func RuleType(rt byte) string

Types

type Filter

type Filter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(rules []byte) (element *Filter)

func (*Filter) AddGeoIP

func (c *Filter) AddGeoIP(match, adapter string)

func (*Filter) AddHosts

func (c *Filter) AddHosts(addr, host string)

func (*Filter) FromFinal

func (c *Filter) FromFinal(adapter string)

func (*Filter) FromGeoIP

func (c *Filter) FromGeoIP(name string) (err error)

func (*Filter) FromHosts

func (c *Filter) FromHosts()

func (*Filter) FromPort

func (c *Filter) FromPort(elements ...string)

func (*Filter) FromRules

func (c *Filter) FromRules(b []byte)

func (*Filter) GeoIP

func (c *Filter) GeoIP(ip net.IP) string

Return Country code

func (*Filter) GeoIPString

func (c *Filter) GeoIPString(ipaddr string) string

func (*Filter) GeoIPs

func (c *Filter) GeoIPs(ips []net.IP) string

func (*Filter) MatchBypass

func (c *Filter) MatchBypass(addr string) bool

func (*Filter) MatchHosts

func (c *Filter) MatchHosts(host string) string

func (*Filter) MatchPort

func (c *Filter) MatchPort(port string) bool

func (*Filter) MatchRule

func (c *Filter) MatchRule(m goproxy.Metadata) goproxy.Rule

func (*Filter) SetGeoIP

func (c *Filter) SetGeoIP(match, adapter string)

func (*Filter) SetHosts

func (c *Filter) SetHosts(addr, host string)

func (*Filter) SystemBypass

func (c *Filter) SystemBypass() []string

type Rule

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

func (*Rule) Adapter

func (r *Rule) Adapter() string

func (*Rule) RuleType

func (r *Rule) RuleType() byte

func (*Rule) String

func (r *Rule) String() string

type RuleHost

type RuleHost struct {
	Addr string
	Host string
}

func FromHosts

func FromHosts() (hosts []*RuleHost)

type RuleIPCIDR

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

Jump to

Keyboard shortcuts

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