MCPcopy Index your code
hub / github.com/coder/coder / CheckIP

Method CheckIP

cli/cliutil/awscheck.go:95–114  ·  view source on GitHub ↗

CheckIP checks if the given IP address is an AWS IP.

(ip netip.Addr)

Source from the content-addressed store, hash-verified

93
94// CheckIP checks if the given IP address is an AWS IP.
95func (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}

Callers 2

isAWSIPFunction · 0.80
TestIPV4CheckFunction · 0.80

Calls 1

ContainsMethod · 0.45

Tested by 1

TestIPV4CheckFunction · 0.64