CheckIP checks if the given IP address is an AWS IP.
(ip netip.Addr)
| 93 | |
| 94 | // CheckIP checks if the given IP address is an AWS IP. |
| 95 | func (r *AWSIPRanges) CheckIP(ip netip.Addr) bool { |
| 96 | if ip.IsLoopback() || ip.IsLinkLocalMulticast() || ip.IsLinkLocalUnicast() || ip.IsPrivate() { |
| 97 | return false |
| 98 | } |
| 99 | |
| 100 | if ip.Is4() { |
| 101 | for _, p := range r.V4 { |
| 102 | if p.Contains(ip) { |
| 103 | return true |
| 104 | } |
| 105 | } |
| 106 | } else { |
| 107 | for _, p := range r.V6 { |
| 108 | if p.Contains(ip) { |
| 109 | return true |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | return false |
| 114 | } |