Documentation ¶
Index ¶
- Variables
- func BatchLoad(l *List, entries []string) error
- func BatchLoadFromFiles(l *List, files []string) error
- func Load(l *List, entry string) error
- func LoadFromDAT(l *List, file, tag string) error
- func LoadFromFile(l *List, file string) error
- func LoadFromReader(l *List, reader io.Reader) error
- func LoadFromText(l *List, s string) error
- func LoadFromTextFile(l *List, file string) error
- func ParseIP(s string) (IPv6, IPVersion, error)
- type IPVersion
- type IPv6
- type List
- type Matcher
- type Net
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidIP = errors.New("invalid ip")
)
var LoadFromDATFunc func(l *List, file, tag string) error
Functions ¶
func BatchLoad ¶
BatchLoad is a helper func to load multiple files using Load. It might modify the List and causes List unsorted.
func BatchLoadFromFiles ¶
func Load ¶
Load loads data from entry. If entry begin with "ext:", Load loads the file by using LoadFromFile. Else it loads the entry as a text pattern by using LoadFromText.
func LoadFromDAT ¶
func LoadFromFile ¶
LoadFromFile loads ip from a text file or a geoip file. If file contains a ':' and has format like 'geoip:cn', it will be read as a geoip file. It might modify the List and causes List unsorted.
func LoadFromReader ¶
LoadFromReader loads IP list from a reader. It might modify the List and causes List unsorted.
func LoadFromText ¶
LoadFromText loads an IP from s. It might modify the List and causes List unsorted.
func LoadFromTextFile ¶
LoadFromTextFile reads IP list from a text file. It might modify the List and causes List unsorted.
Types ¶
type IPv6 ¶
type IPv6 [2]uint64
IPv6 represents a ipv6 addr
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a list of Nets. All Nets will be in ipv6 format, even it's an ipv4 addr. Because we use bin search.
func (*List) Append ¶
Append appends new Nets to the list. This modified list. Caller must call List.Sort() before calling List.Contains()
func (*List) Contains ¶
Contains reports whether the list includes given ip. list must be sorted, or Contains will panic.
func (*List) Merge ¶
Merge merges srcList with list This modified list. Caller must call List.Sort() before calling List.Contains()
type Net ¶
type Net struct {
// contains filtered or unexported fields
}
Net represents a ip network
func NewNet ¶
NewNet returns a new IPNet, mask should be an ipv6 mask, which means you should +96 if you have an ipv4 mask.
func ParseCIDR ¶
ParseCIDR parses s as a CIDR notation IP address and prefix length. As defined in RFC 4632 and RFC 4291.