Documentation ¶
Overview ¶
Copyright (C) 2020-2021, IrineSistiana
This file is part of mosdns.
mosdns is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
mosdns is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Index ¶
- Variables
- func BatchLoad(l *List, entries []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 LoadFromV2CIDR(l *List, cidr []*v2data.CIDR) error
- func LoadGeoIPFromDAT(file, tag string) (*v2data.GeoIP, error)
- func LoadGeoIPListFromDAT(file string) (*v2data.GeoIPList, error)
- func ParseIP(s string) (IPv6, IPVersion, error)
- type IPVersion
- type IPv6
- type List
- func (list *List) Append(newNet ...Net)
- func (list *List) Contains(ip net.IP) bool
- func (list *List) Grow(n int)
- func (list *List) Len() int
- func (list *List) Less(i, j int) bool
- func (list *List) Match(ip net.IP) bool
- func (list *List) Merge(srcList *List)
- func (list *List) Sort()
- func (list *List) Swap(i, j int)
- type Matcher
- type Net
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidIP = errors.New("invalid ip")
)
Functions ¶
func BatchLoad ¶
BatchLoad is a helper func to load multiple files using Load. It might modify the List and causes List unsorted.
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 ¶
LoadFromDAT loads ip from v2ray proto file. It might modify the List and causes List unsorted.
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.
func LoadFromV2CIDR ¶
LoadFromV2CIDR loads ip from v2ray CIDR. 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.