Documentation
¶
Index ¶
- func GetIPv4Segment(ipStr string, segment int) uint8
- func GetIPv6Segment(ipStr string, segment int) uint16
- func IPv4CIDRRange(cidr string) (uint32, uint32)
- func IPv4InCIDR(ipStr string, cidr string) bool
- func IPv4IntToStr(ip uint32) string
- func IPv4StrToInt(ipStr string) uint32
- func IPv6CIDRRange(cidr string) (num.U128, num.U128)
- func IPv6InCIDR(ipStr string, cidr string) bool
- func IPv6IntToStr(ip num.U128) string
- func IPv6StrToInt(ipStr string) num.U128
- func ReadFile(filename string) ([]string, error)
- func ReadFileFromURL(url string) ([]string, error)
- type IPv4Range
- type IPv4RangeList
- func (list *IPv4RangeList) Append(rge *IPv4Range)
- func (list *IPv4RangeList) InsertSorted(rge *IPv4Range)
- func (list *IPv4RangeList) Len() int
- func (list *IPv4RangeList) Range() string
- func (list *IPv4RangeList) Search(ipStr string) *IPv4Range
- func (list *IPv4RangeList) Sort()
- func (list *IPv4RangeList) String() string
- type IPv4RangeMapList
- func (m IPv4RangeMapList) Append(ipRange *IPv4Range)
- func (m IPv4RangeMapList) AppendBatch(ipRanges []*IPv4Range)
- func (m IPv4RangeMapList) InsertSorted(ipRange *IPv4Range)
- func (m IPv4RangeMapList) InsertSortedCIDRs(ipRanges []*IPv4Range)
- func (m IPv4RangeMapList) Search(ipStr string) *IPv4Range
- func (m IPv4RangeMapList) Sort()
- type IPv4Search
- type IPv6Range
- type IPv6RangeList
- func (lst *IPv6RangeList) Append(rge *IPv6Range)
- func (lst *IPv6RangeList) InsertSorted(rge *IPv6Range)
- func (lst *IPv6RangeList) Len() int
- func (lst *IPv6RangeList) Range() string
- func (lst *IPv6RangeList) Search(ipStr string) *IPv6Range
- func (lst *IPv6RangeList) Sort()
- func (lst *IPv6RangeList) String() string
- type IPv6RangeMapList
- func (m IPv6RangeMapList) Append(ipRange *IPv6Range)
- func (m IPv6RangeMapList) AppendBatch(ipRanges []*IPv6Range)
- func (m IPv6RangeMapList) InsertSorted(ipRange *IPv6Range)
- func (m IPv6RangeMapList) InsertSortedCIDRs(ipRanges []*IPv6Range)
- func (m IPv6RangeMapList) Search(ipStr string) *IPv6Range
- func (m IPv6RangeMapList) Sort()
- type IPv6Search
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIPv4Segment ¶
GetIPv4Segment returns the segment of an IPv4 address
func GetIPv6Segment ¶
GetIPv6Segment returns the segment of an IPv6 address
func IPv4CIDRRange ¶
IPv4CIDRRange returns the start and end IP v4 address for a CIDR range
func IPv4InCIDR ¶
IPv4InCIDR checks if an IPv4 address is in a CIDR range
func IPv4IntToStr ¶
IPv4IntToStr converts an integer to a string IPv4 address
func IPv4StrToInt ¶
IPv4StrToInt converts a string IPv4 address to an integer
func IPv6CIDRRange ¶
IPv6CIDRRange returns the start and end IPv6 address for a CIDR range
func IPv6InCIDR ¶
IPv6InCIDR checks if an IPv6 address is in a CIDR range
func IPv6IntToStr ¶
IPv6IntToStr converts an integer to a string IPv6 address
func IPv6StrToInt ¶
IPv6StrToInt converts a string IPv6 address to an integer
func ReadFile ¶
ReadFile reads a ip cidr list file and returns a slice of strings, one for each line.
func ReadFileFromURL ¶
ReadFileFromURL from a URL and returns a slice of strings, one for each line.
Types ¶
type IPv4Range ¶
type IPv4Range struct {
// contains filtered or unexported fields
}
IPv4Range represents an IPv4 CIDR range.
func NewIPv4Range ¶
NewIPv4Range creates a new IPv4 CIDR range
func NewIPv4RangeSlice ¶
NewIPv4RangeSlice creates a new slice of IPv4Range.
type IPv4RangeList ¶
type IPv4RangeList []*IPv4Range
IPv4RangeList is a list of IPv4 CIDR ranges.
func NewIPv4RangeList ¶
func NewIPv4RangeList(lines []string) IPv4RangeList
func (*IPv4RangeList) Append ¶
func (list *IPv4RangeList) Append(rge *IPv4Range)
Append adds a IPv4 CIDR to the list
func (*IPv4RangeList) InsertSorted ¶
func (list *IPv4RangeList) InsertSorted(rge *IPv4Range)
InsertSorted inserts a IPv4 range to the list, keeping the list sorted
func (*IPv4RangeList) Len ¶
func (list *IPv4RangeList) Len() int
Len returns the length of the list of IPv4 CIDR ranges
func (*IPv4RangeList) Range ¶
func (list *IPv4RangeList) Range() string
Range returns a string representation of the list of IPv4 address ranges
func (*IPv4RangeList) Search ¶
func (list *IPv4RangeList) Search(ipStr string) *IPv4Range
Search searches if an IP address in the list
func (*IPv4RangeList) Sort ¶
func (list *IPv4RangeList) Sort()
Sort sorts the list of IPv4 CIDR ranges
func (*IPv4RangeList) String ¶
func (list *IPv4RangeList) String() string
String returns a string representation of the list of IPv4 CIDR ranges
type IPv4RangeMapList ¶
type IPv4RangeMapList map[uint8]*IPv4RangeList
IPv4RangeMapList is a map of lists of IPv4 CIDR ranges
func NewIPv4RangeMapList ¶
func NewIPv4RangeMapList() IPv4RangeMapList
NewIPv4RangeMapList creates a new map of lists of IPv4 CIDR ranges
func (IPv4RangeMapList) Append ¶
func (m IPv4RangeMapList) Append(ipRange *IPv4Range)
Append adds an IPv4 CIDR range to the map of lists of IPv4 CIDR ranges
func (IPv4RangeMapList) AppendBatch ¶
func (m IPv4RangeMapList) AppendBatch(ipRanges []*IPv4Range)
AppendBatch adds a list of IPv4 CIDR ranges to the map of lists of IPv4 CIDR ranges
func (IPv4RangeMapList) InsertSorted ¶
func (m IPv4RangeMapList) InsertSorted(ipRange *IPv4Range)
InsertSorted inserts a IPv4 CIDR range to the map of lists of IPv4 CIDR ranges, keeping the lists sorted
func (IPv4RangeMapList) InsertSortedCIDRs ¶
func (m IPv4RangeMapList) InsertSortedCIDRs(ipRanges []*IPv4Range)
InsertSortedCIDRs inserts a list of IPv4 CIDR ranges to the map of IPv4 CIDR ranges lists, keeping the lists sorted
func (IPv4RangeMapList) Search ¶
func (m IPv4RangeMapList) Search(ipStr string) *IPv4Range
Search searches if an IPv4 address is in the map of lists
func (IPv4RangeMapList) Sort ¶
func (m IPv4RangeMapList) Sort()
Sort sorts the map of lists of IPv4 CIDR ranges
type IPv4Search ¶
type IPv4Search struct {
// contains filtered or unexported fields
}
IPv4Search is a struct that contains a map of IPv4 ranges.
func NewIPv4Search ¶
func NewIPv4Search(lines []string) *IPv4Search
NewIPv4Search creates a new IPv4Search struct.
func NewIPv4SearchWithCountry ¶
func NewIPv4SearchWithCountry(country string) (*IPv4Search, error)
NewIPv4SearchWithCountry creates a new IPv4Search struct from a country code.
func NewIPv4SearchWithFile ¶
func NewIPv4SearchWithFile(path string) (*IPv4Search, error)
NewIPv4SearchWithFile creates a new IPv4Search struct from a file.
func NewIPv4SearchWithFileFromURL ¶
func NewIPv4SearchWithFileFromURL(url string) (*IPv4Search, error)
NewIPv4SearchWithFileFromURL creates a new IPv4Search struct from a URL.
func (*IPv4Search) Search ¶
func (s *IPv4Search) Search(ip string) *IPv4Range
Search searches if an IPv4 address is in the map of lists of IPv4 ranges.
type IPv6Range ¶
type IPv6Range struct {
// contains filtered or unexported fields
}
IPv6Range represents an IPv6 CIDR range.
func NewIPv6Range ¶
NewIPv6Range creates a new IPv6 CIDR range
func NewIPv6RangeSlice ¶
type IPv6RangeList ¶
type IPv6RangeList []*IPv6Range
IPv6RangeList is a list of IPv6 CIDR ranges.
func NewIPv6RangeList ¶
func NewIPv6RangeList(lines []string) IPv6RangeList
func (*IPv6RangeList) Append ¶
func (lst *IPv6RangeList) Append(rge *IPv6Range)
Append adds a IPv6 CIDR to the list
func (*IPv6RangeList) InsertSorted ¶
func (lst *IPv6RangeList) InsertSorted(rge *IPv6Range)
InsertSorted inserts a IPv6 range to the list, keeping the list sorted
func (*IPv6RangeList) Len ¶
func (lst *IPv6RangeList) Len() int
Len returns the length of the list of IPv6 CIDR ranges
func (*IPv6RangeList) Range ¶
func (lst *IPv6RangeList) Range() string
Range returns a string representation of the list of IPv6 address ranges
func (*IPv6RangeList) Search ¶
func (lst *IPv6RangeList) Search(ipStr string) *IPv6Range
Search searches if an IPv6 address in the list
func (*IPv6RangeList) Sort ¶
func (lst *IPv6RangeList) Sort()
Sort sorts the list of IPv6 CIDR ranges
func (*IPv6RangeList) String ¶
func (lst *IPv6RangeList) String() string
String returns a string representation of the list of IPv6 CIDR ranges
type IPv6RangeMapList ¶
type IPv6RangeMapList map[uint16]*IPv6RangeList
IPv6RangeMapList is a map of lists of IPv6 CIDR ranges
func NewIPv6RangeMapList ¶
func NewIPv6RangeMapList() IPv6RangeMapList
NewIPv6RangeMapList creates a new map of lists of IPv6 CIDR ranges
func (IPv6RangeMapList) Append ¶
func (m IPv6RangeMapList) Append(ipRange *IPv6Range)
Append adds an IPv6 CIDR range to the map of lists of IPv6 CIDR ranges
func (IPv6RangeMapList) AppendBatch ¶
func (m IPv6RangeMapList) AppendBatch(ipRanges []*IPv6Range)
AppendBatch adds a list of IPv6 CIDR ranges to the map of lists of IPv6 CIDR
func (IPv6RangeMapList) InsertSorted ¶
func (m IPv6RangeMapList) InsertSorted(ipRange *IPv6Range)
func (IPv6RangeMapList) InsertSortedCIDRs ¶
func (m IPv6RangeMapList) InsertSortedCIDRs(ipRanges []*IPv6Range)
InsertSortedCIDRs inserts a list of IPv6 CIDR ranges to the map of IPv6 CIDR lists keeping the lists sorted
func (IPv6RangeMapList) Search ¶
func (m IPv6RangeMapList) Search(ipStr string) *IPv6Range
Search searches if an IPv6 address is in the map of lists
func (IPv6RangeMapList) Sort ¶
func (m IPv6RangeMapList) Sort()
Sort sorts the map of lists of IPv6 CIDR ranges
type IPv6Search ¶
type IPv6Search struct {
// contains filtered or unexported fields
}
IPv6Search is a struct that contains a map of IPv6 ranges.
func NewIPv6Search ¶
func NewIPv6Search(lines []string) *IPv6Search
NewIPv6Search creates a new IPv6Search struct.
func NewIPv6SearchWithCountry ¶
func NewIPv6SearchWithCountry(country string) (*IPv6Search, error)
NewIPv6SearchWithCountry creates a new IPv6Search struct from a country code.
func NewIPv6SearchWithFile ¶
func NewIPv6SearchWithFile(path string) (*IPv6Search, error)
NewIPv6SearchWithFile creates a new IPv6Search struct from a file.
func NewIPv6SearchWithFileFromURL ¶
func NewIPv6SearchWithFileFromURL(url string) (*IPv6Search, error)
NewIPv6SearchWithFileFromURL creates a new IPv6Search struct from a URL.
func (*IPv6Search) Search ¶
func (s *IPv6Search) Search(ip string) *IPv6Range
Search searches if an IPv6 address is in the map of lists of IPv6 ranges.