aclrouter

package
v0.0.0-...-df37d59 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	RuleBlock = iota
	RulePrivate
	RuleMatchedPass
	RulePass
	RuleMatchedProxy
	RuleProxy
	RuleIPv6
	RuleUnknown
)

Variables

View Source
var (
	ChinaIP = `` /* 211955-byte string literal not displayed */

)
View Source
var (
	// PrivateIP 127.x.x.x is reserved IP, but for simplicity, we put them in private IP block
	PrivateIP = `10.0.0.0 10.255.255.255
127.0.0.0/8
172.16.0.0 172.31.255.255
192.168.0.0 192.168.255.255`
)

Functions

func IPv4ToInt

func IPv4ToInt(ip string) uint32

IPv4ToInt converts an IPv4 string to its integer representation

func NetIPv4ToInt

func NetIPv4ToInt(ip net.IP) uint32

NetIPv4ToInt converts net.IP(v4) to its integer representation

Types

type ACL

type ACL struct {
	Black lookup // Black are those which should be banned, first to check
	White lookup // White are those which should be accessed directly
	Gray  lookup // Gray are those which should be proxied

	PrivateIPv4Table []ipRange
	RemoteDNS        bool
	Legacy           bool
	OmitRules        []string
}

ACL stands for Access Control List

func LoadACL

func LoadACL(path string) (*ACL, error)

LoadACL loads ACL config, which can be chinalist.txt or SS ACL, note that it will always return a valid ACL struct, but may be empty. An empty ACL checks China IP only, if failed, it goes Gray as always.

func (*ACL) Check

func (acl *ACL) Check(host string, trustIP bool) (rule byte, strIP string, err error)

Check returns a route rule for the given host

func (*ACL) IsPrivateIP

func (acl *ACL) IsPrivateIP(ip string) bool

IsPrivateIP checks if the given IPv4 is private

Jump to

Keyboard shortcuts

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