Documentation
¶
Index ¶
- Constants
- Variables
- func EmptyRegionNameError(providerName string) error
- func EmptyServiceNameError(providerName, regionName string) error
- func LatestPrefixFileNotFound(bucketName string) error
- func NoBucketNameSpecified() error
- func NoIPPrefixesError(providerName, regionName, serviceName string) error
- func NoRegionNetworksError(providerName string) error
- func NoServiceNetworksError(providerName, regionName string) error
- func NotEnoughIPPrefixesError(providerName string, numObserved, numRequired int) error
- func NumProvidersError(numProviders, numCrawlers int) error
- func ProviderNameEmptyError() error
- func RegionNetworksNotFound(region string) error
- func ServiceNetworksNotFound(service string) error
- func SetVerbose()
- func Verbose() bool
- type ExternalNetworkSources
- type IsRedundantRegionServicePairFn
- type NetworkCrawler
- type Provider
- type ProviderNetworkRanges
- type RegionNetworkDetail
- type RegionServicePair
- type ServiceIPRanges
Constants ¶
const ChecksumFileName = "checksum"
ChecksumFileName is the name which contains the checksum of the network ranges file
const DefaultRegion = "unknown"
DefaultRegion is used when a vendor does not specify regions for the IP ranges provided
const DefaultService = "unknown"
DefaultService is used when a vendor does not specify service names for the IP ranges provider
const LatestPrefixFileName = "latest_prefix"
LatestPrefixFileName is the name of the file that contains the prefix of latest networks definitions.
const MasterBucketPrefix = "external-networks"
MasterBucketPrefix is the top level prefix we use for all the uploads we do in this crawler
const MaxNumDefinitions = 10
MaxNumDefinitions is the maximum number of runs(outputted network definitions) we remember in the bucket specified in script. Oldest record should be deleted first.
const NetworkFileName = "networks"
NetworkFileName is the name of the network file we upload
Variables ¶
var ( // Google is provider "enum" for Google Cloud Google = newProvider("Google") // Azure is provider "enum" for Microsoft Azure Cloud Azure = newProvider("Azure") // Amazon is provider "enum" for Amazon AWS Amazon = newProvider("Amazon") // Oracle is provider "enum" for Oracle Cloud Platform Oracle = newProvider("Oracle") // Cloudflare is provider "enum" for Cloudflare Cloudflare = newProvider("Cloudflare") )
var ProviderToURLs = map[Provider][]string{ Google: { "https://www.gstatic.com/ipranges/cloud.json", }, Azure: { "https://www.microsoft.com/download/details.aspx?id=56519", "https://www.microsoft.com/download/details.aspx?id=57063", "https://www.microsoft.com/download/details.aspx?id=57062", "https://www.microsoft.com/download/details.aspx?id=57064", }, Amazon: { "https://ip-ranges.amazonaws.com/ip-ranges.json", }, Oracle: { "https://docs.cloud.oracle.com/en-us/iaas/tools/public_ip_ranges.json", }, Cloudflare: { "https://api.cloudflare.com/client/v4/ips", }, }
ProviderToURLs is a mapping from provider to its crawler endpoint. It is kept here for easier maintenance.
Functions ¶
func EmptyRegionNameError ¶
EmptyRegionNameError is returned when an empty region name is found
func EmptyServiceNameError ¶
EmptyServiceNameError is returned when an empty service name is found
func LatestPrefixFileNotFound ¶
LatestPrefixFileNotFound is returned when there is no latest metadata file on the bucket
func NoBucketNameSpecified ¶
func NoBucketNameSpecified() error
NoBucketNameSpecified is returned when the script is invoked without a bucket name
func NoIPPrefixesError ¶
NoIPPrefixesError is returned when a service does not have any IP prefix crawled
func NoRegionNetworksError ¶
NoRegionNetworksError is returned when a provider does not have any region crawled
func NoServiceNetworksError ¶
NoServiceNetworksError is returned when a region does not have any service crawled
func NotEnoughIPPrefixesError ¶
NotEnoughIPPrefixesError is returned when a crawler did not crawl enough IP prefixes for a provider
func NumProvidersError ¶
NumProvidersError is returned when the number of providers crawled does not match with the number of crawles spawned
func ProviderNameEmptyError ¶
func ProviderNameEmptyError() error
ProviderNameEmptyError is returned when an empty provider name is found
func RegionNetworksNotFound ¶
RegionNetworksNotFound is returned when a region networks spec is not found
func ServiceNetworksNotFound ¶
ServiceNetworksNotFound is returned when a service networks spec is not found
Types ¶
type ExternalNetworkSources ¶
type ExternalNetworkSources struct {
ProviderNetworks []*ProviderNetworkRanges `json:"providerNetworks"`
}
ExternalNetworkSources contains all the external networks for all providers
type IsRedundantRegionServicePairFn ¶
type IsRedundantRegionServicePairFn func( newPair *RegionServicePair, existingPair *RegionServicePair, ) (*RegionServicePair, error)
IsRedundantRegionServicePairFn is a predicate function to determine if a new region service pair should be added to output or not. For example, if an IP address belongs to multiple region/service pairs, user needs to provide a predicate function which looks at the pairs that are already recorded in ProviderNetworkRanges and the new pair that is about to be added, then decide if the new pair should be added as well or not. The existing pairs are given one by one to the user.
The return value indicates which pair to remove. There could be three different return outcomes. Remove the new pair, remove the existing pair, or keep both. The returned pair is first checked with the new pair before checking with the existing pair. In case of keeping both pairs, a nil value should be returned
func GetDefaultRegionServicePairRedundancyCheck ¶
func GetDefaultRegionServicePairRedundancyCheck() IsRedundantRegionServicePairFn
GetDefaultRegionServicePairRedundancyCheck returns the default check Default check checks if region and service names are the same
type NetworkCrawler ¶
type NetworkCrawler interface { CrawlPublicNetworkRanges() (*ProviderNetworkRanges, error) GetHumanReadableProviderName() string GetProviderKey() Provider // GetNumRequiredIPPrefixes returns number of required IP prefixes crawled by crawler // Used during validation of crawler outputs. GetNumRequiredIPPrefixes() int }
NetworkCrawler defines an interface for the implementation of Provider specific network range crawlers
type Provider ¶
type Provider string
Provider is a string representing different external network providers
func ToProvider ¶
ToProvider converts a string representation of a provider to Provider type
type ProviderNetworkRanges ¶
type ProviderNetworkRanges struct { ProviderName string `json:"providerName"` RegionNetworks []*RegionNetworkDetail `json:"regionNetworks"` // contains filtered or unexported fields }
ProviderNetworkRanges contains networks for all regions of a provider
func NewProviderNetworkRanges ¶
func NewProviderNetworkRanges(providerName string) *ProviderNetworkRanges
NewProviderNetworkRanges returns a new instance of ProviderNetworkRanges
func (*ProviderNetworkRanges) AddIPPrefix ¶
func (p *ProviderNetworkRanges) AddIPPrefix(region, service, ipPrefix string, fn IsRedundantRegionServicePairFn) error
AddIPPrefix adds the specified IP prefix to the region and service name pair returns error if the IP given is not a valid IP prefix
type RegionNetworkDetail ¶
type RegionNetworkDetail struct { RegionName string `json:"regionName"` ServiceNetworks []*ServiceIPRanges `json:"serviceNetworks"` }
RegionNetworkDetail contains all the networks of services under a region
func RgnNetDetSliceRemove ¶
func RgnNetDetSliceRemove(in []*RegionNetworkDetail, i int) []*RegionNetworkDetail
RgnNetDetSliceRemove removes an element from a RegionNetworkDetail slice at the specified index
type RegionServicePair ¶
RegionServicePair is a tuple of region and service names
func RgnSvcPairSliceRemove ¶
func RgnSvcPairSliceRemove(in []*RegionServicePair, i int) []*RegionServicePair
RgnSvcPairSliceRemove removes an element from a RegionServicePair slice at the specified index
func (*RegionServicePair) Equals ¶
func (r *RegionServicePair) Equals(p *RegionServicePair) bool
Equals checks if two RegionServicePairs are equal
func (*RegionServicePair) String ¶
func (r *RegionServicePair) String() string
String returns the string representation of a RegionServicePair
type ServiceIPRanges ¶
type ServiceIPRanges struct { // ServiceName denotes the service name for the IP ranges ServiceName string `json:"serviceName"` // Sample IPv4 prefix: 8.8.0.0/16 IPv4Prefixes []string `json:"ipv4Prefixes"` // Sample IPv6 prefix: 2600:1901::/48 IPv6Prefixes []string `json:"ipv6Prefixes"` }
ServiceIPRanges contains all the IP ranges used by a specific service
func SvcIPRangesSliceRemove ¶
func SvcIPRangesSliceRemove(in []*ServiceIPRanges, i int) []*ServiceIPRanges
SvcIPRangesSliceRemove removes an element from a ServiceIPRanges slice at the specified index