Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAwsIP ¶
IsAwsIP returns true if the ip address falls within one of the known AWS ip ranges.
Example ¶
ips := []netip.Addr{ netip.MustParseAddr("54.74.0.27"), netip.MustParseAddr("127.0.0.1"), } for _, ip := range ips { if IsAwsIP(ip) { fmt.Printf("%s is AWS\n", ip) } else { fmt.Printf("%s is NOT AWS\n", ip) } }
Output: 54.74.0.27 is AWS 127.0.0.1 is NOT AWS
Types ¶
type IPRange ¶
type IPRange struct { Prefix netip.Prefix NetworkBorderGroup string Region string Services []string }
func Range ¶
Range returns the ip range and metadata an address falls within. If the IP is not an AWS IP address it returns nil
Example ¶
ip := netip.MustParseAddr("54.74.0.27") r := Range(ip) fmt.Println(r.Prefix) fmt.Println(r.NetworkBorderGroup) fmt.Println(r.Region) fmt.Println(r.Services)
Output: 54.74.0.0/15 eu-west-1 eu-west-1 [AMAZON EC2]
Click to show internal directories.
Click to hide internal directories.