Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGcpIP ¶
IsGcpIP returns true if the ip address falls within one of the known GCP ip ranges.
Example ¶
ips := []netip.Addr{ netip.MustParseAddr("104.155.192.1"), netip.MustParseAddr("54.74.0.27"), netip.MustParseAddr("127.0.0.1"), } for _, ip := range ips { if IsGcpIP(ip) { fmt.Printf("%s is GCP\n", ip) } else { fmt.Printf("%s is NOT GCP\n", ip) } }
Output: 104.155.192.1 is GCP 54.74.0.27 is NOT GCP 127.0.0.1 is NOT GCP
Types ¶
type IPRange ¶
func Range ¶
Range returns the ip range and metadata an address falls within. If the IP is not an GCP IP address it returns nil
Example ¶
ip := netip.MustParseAddr("104.155.192.1") r := Range(ip) fmt.Println(r.Prefix) fmt.Println(r.Service) fmt.Println(r.Scope)
Output: 104.155.192.0/19 Google Cloud asia-east1
Click to show internal directories.
Click to hide internal directories.