Documentation ¶
Index ¶
- Variables
- func Load(l *List, ip string) error
- func LoadFromReader(l *List, reader io.Reader) error
- func LoadFromText(l *List, s string) error
- func LoadFromV2CIDR(l *List, cidr []*v2data.CIDR) error
- func LoadGeoIPListFromDAT(b []byte) (*v2data.GeoIPList, error)
- type DynamicMatcher
- type List
- func (list *List) Append(newNet ...netip.Prefix)
- func (list *List) Contains(addr netip.Addr) (bool, error)
- func (list *List) Len() int
- func (list *List) Less(i, j int) bool
- func (list *List) Match(ip net.IP) (bool, error)
- func (list *List) Merge(srcList *List)
- func (list *List) Sort()
- func (list *List) Swap(i, j int)
- type Matcher
- type MatcherGroup
Constants ¶
This section is empty.
Variables ¶
var ErrNotSorted = errors.New("list is not sorted")
Functions ¶
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 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 LoadFromV2CIDR ¶
LoadFromV2CIDR loads ip from v2ray CIDR. It might modify the List and causes List unsorted.
Types ¶
type DynamicMatcher ¶
type DynamicMatcher struct {
// contains filtered or unexported fields
}
func NewDynamicMatcher ¶
func NewDynamicMatcher(parseFunc func(in []byte) (*List, error)) *DynamicMatcher
func (*DynamicMatcher) Len ¶
func (d *DynamicMatcher) Len() int
func (*DynamicMatcher) Update ¶
func (d *DynamicMatcher) Update(newData []byte) error
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a list of netip.Prefix. It stores all netip.Prefix in one single slice and use binary search. It is suitable for large static cidr search.
func NewListFrom ¶
NewListFrom returns a *List using l as its initial contents. The new List takes ownership of l, and the caller should not use l after this call.
func NewV2rayIPDat ¶
NewV2rayIPDat builds a List from given v and args. The format of args is "tag1,tag2,...". Only lists that are matched by given tags will be loaded to List.
func (*List) Append ¶
Append appends new netip.Prefix(s) to the list. This modified the list. Caller must call List.Sort() before calling List.Contains()
func (*List) Merge ¶
Merge merges srcList with list This modified the list. Caller must call List.Sort() before calling List.Contains()
type MatcherGroup ¶
type MatcherGroup struct {
// contains filtered or unexported fields
}
func BatchLoadProvider ¶
func BatchLoadProvider(e []string, dm *data_provider.DataManager) (*MatcherGroup, error)
BatchLoadProvider is a helper func to load multiple files using Load.
func (*MatcherGroup) Len ¶
func (m *MatcherGroup) Len() int