rule

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RULE_WHITE  string = "white"
	RULE_BLACK  string = "black"
	RULE_REJECT string = "reject"
	RULE_AUTO   string = "auto"

	PASS_WHITE  string = "white"
	PASS_BLACK  string = "black"
	PASS_PROXY  string = "proxy"
	PASS_DIRECT string = "direct"

	MODE_DIRECT byte = 0x00
	MODE_PROXY  byte = 0x01
	MODE_REJECT byte = 0x02
	MODE_UNKOWN byte = 0x05

	SYNTAX_NORMAL byte = 0x00
	SYNTAX_FULL   byte = 0x01
	SYNTAX_REGEXP byte = 0x02
)

Variables

View Source
var Timeout int64 = 30 * 60 * 1000

Functions

func AddOrUpdateMyRules

func AddOrUpdateMyRules(mode byte, host string)

func AddToAutoList

func AddToAutoList(addrType byte, host string)

func CanAutoTry

func CanAutoTry(s string) bool

func Clear

func Clear()

func FileNotExist

func FileNotExist(path string) bool

func How

func How(t byte, host string) (mode byte)

func Init

func Init(create bool)

func Inited

func Inited() bool

func LazySave

func LazySave()

func NewSite

func NewSite(mode byte, host string) *site

func NewSiteFromBytes

func NewSiteFromBytes(b []byte) (s *site, err error)

func QueryRule

func QueryRule(host string) byte

func RemoteFromMyRule

func RemoteFromMyRule(host string)

func SetRule

func SetRule(host string, mode byte)

Types

type Domain

type Domain struct {
	Name   string
	Syntax byte
}

func NewDomain

func NewDomain(b []byte) (d *Domain, err error)

func (Domain) Host

func (d Domain) Host() string

type IP

type IP struct {
	*net.IPNet
}

func NewIP

func NewIP(ipstr string) (ip *IP, err error)

func (IP) Host

func (i IP) Host() string

type List

type List interface {
	kit.OrderedMap

	Hit(s string) bool

	ParseOne(b []byte) (h hoster, err error)

	SaveOne(w io.Writer, v interface{}) (err error)
}

type RuleList

type RuleList struct {
	List
	Path   string
	Inited bool
}
var PreDomainBlackList,
	PreDomainWhiteList,
	PreDomainRejectList,
	PreIpBlackList,
	PreIpWhiteList,
	PreIpRejectList,
	MyList,
	AutoTryList *RuleList

func NewDomainList

func NewDomainList(path string) *RuleList

func NewIPList

func NewIPList(path string) *RuleList

func NewSiteList

func NewSiteList(path string) *RuleList

func (RuleList) IsEmpty

func (l RuleList) IsEmpty() bool

func (RuleList) Load

func (l RuleList) Load() (err error)

func (RuleList) LoadFrom

func (l RuleList) LoadFrom(filePath string) (err error)

func (RuleList) Save

func (l RuleList) Save() (err error)

func (RuleList) SaveTo

func (l RuleList) SaveTo(filePath string) (err error)

Jump to

Keyboard shortcuts

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