Documentation
¶
Index ¶
- func CIDR2Range(c string) (string, string, error)
- func DownloadAWS() ([]byte, error)
- func DownloadAzure() ([]byte, error)
- func ToDots(val uint32) string
- func UpdateAWS(ipmap *IntervalSet, body []byte) error
- func UpdateAzure(ipmap *IntervalSet, body []byte) error
- type AWS
- type AWSPrefix
- type AzureIPRange
- type AzurePublicIPAddresses
- type AzureRegion
- type IntervalSet
- func (ipset *IntervalSet) AddCIDR(cidr, name, url string) error
- func (ipset *IntervalSet) AddRange(dotsleft, dotsright, name, url string) error
- func (ipset IntervalSet) Contains(dots string) (bool, error)
- func (ipset *IntervalSet) DeleteByName(name string)
- func (ipset *IntervalSet) ExportCSV(in io.Writer) error
- func (ipset *IntervalSet) ImportCSV(in io.Reader) error
- func (ipset IntervalSet) Len() int
- func (ipset IntervalSet) RankBySize() NameSizeList
- type NameSize
- type NameSizeList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CIDR2Range ¶
CIDR2Range converts a CIDR to a dotted IP address pair, or empty strings and error
generic.. does not care if ipv4 or ipv6
func DownloadAWS ¶
DownloadAWS downloads the latest AWS IP ranges list
func DownloadAzure ¶
DownloadAzure downloads and return raw bytes of the MS Azure ip range list
func UpdateAWS ¶
func UpdateAWS(ipmap *IntervalSet, body []byte) error
UpdateAWS parses the AWS IP json file and updates the interval set
func UpdateAzure ¶
func UpdateAzure(ipmap *IntervalSet, body []byte) error
UpdateAzure takes a raw data, parses it and updates the ipmap
Types ¶
type AWS ¶
type AWS struct { SyncToken string `json:"syncToken"` CreateDate string `json:"createDate"` Prefixes []AWSPrefix `json:"prefixes"` }
AWS is main record for AWS IP info
type AWSPrefix ¶
type AWSPrefix struct { IPPrefix string `json:"ip_prefix"` Region string `json:"region"` Service string `json:"service"` }
AWSPrefix is AWS prefix in their IP ranges file
type AzureIPRange ¶
type AzureIPRange struct {
Subnet string `xml:"Subnet,attr"`
}
AzureIPRange is a MS Azure record
type AzurePublicIPAddresses ¶
type AzurePublicIPAddresses struct {
AzureRegion []AzureRegion
}
AzurePublicIPAddresses is a listing of regions
type AzureRegion ¶
type AzureRegion struct { Name string `xml:"Name,attr"` IPRange []AzureIPRange `xml:"IpRange"` }
AzureRegion is a MS Region
type IntervalSet ¶
type IntervalSet struct {
// contains filtered or unexported fields
}
IntervalSet is a mapping of an IP range (the closed interval)
to additional data
func NewIntervalSet ¶
func NewIntervalSet(capacity int) *IntervalSet
NewIntervalSet creates a new set with a capacity
func (*IntervalSet) AddCIDR ¶
func (ipset *IntervalSet) AddCIDR(cidr, name, url string) error
AddCIDR adds an entry based on a CIDR range
func (*IntervalSet) AddRange ¶
func (ipset *IntervalSet) AddRange(dotsleft, dotsright, name, url string) error
AddRange adds an entry based on an IP range
func (IntervalSet) Contains ¶
func (ipset IntervalSet) Contains(dots string) (bool, error)
Contains returns true if the IP address is in some interval
else false or error
func (*IntervalSet) DeleteByName ¶
func (ipset *IntervalSet) DeleteByName(name string)
DeleteByName deletes all entries with the given name
func (*IntervalSet) ExportCSV ¶
func (ipset *IntervalSet) ExportCSV(in io.Writer) error
ExportCSV export data to a CSV file
func (*IntervalSet) ImportCSV ¶
func (ipset *IntervalSet) ImportCSV(in io.Reader) error
ImportCSV imports data from a CSV file
func (IntervalSet) Len ¶
func (ipset IntervalSet) Len() int
Len returns the number of elements in the set
func (IntervalSet) RankBySize ¶
func (ipset IntervalSet) RankBySize() NameSizeList
RankBySize returns a list ISP and how many IPs they have
From this it's easy to compute * Lastest providers * Number of providers * Total number IPs address
type NameSizeList ¶
type NameSizeList []NameSize
NameSizeList is a list of NameSize
func (NameSizeList) Len ¶
func (list NameSizeList) Len() int
Len satifies the sort.Sortable interface
func (NameSizeList) Less ¶
func (list NameSizeList) Less(i, j int) bool
Less satifies the sort.Sortable interface THIS IS DESCENDING SORT, the sign is flipped
MORE = FIRST
func (NameSizeList) Swap ¶
func (list NameSizeList) Swap(i, j int)
Swap satifies the sort.Sortable interface