MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / Contains

Method Contains

config/types.go:114–137  ·  view source on GitHub ↗

Contains checks whether passed addr is in the range of networks

(addr string)

Source from the content-addressed store, hash-verified

112
113// Contains checks whether passed addr is in the range of networks
114func (n Networks) Contains(addr string) bool {
115 if len(n) == 0 {
116 return true
117 }
118
119 h, _, err := net.SplitHostPort(addr)
120 if err != nil {
121 // If we only have an IP address. This happens when the proxy middleware is enabled.
122 h = addr
123 }
124
125 ip := net.ParseIP(h)
126 if ip == nil {
127 panic(fmt.Sprintf("BUG: unexpected error while parsing IP: %s", h))
128 }
129
130 for _, ipnet := range n {
131 if ipnet.Contains(ip) {
132 return true
133 }
134 }
135
136 return false
137}
138
139// Duration wraps time.Duration. It is used to parse the custom duration format
140type Duration time.Duration

Callers 13

serveHTTPFunction · 0.95
getScopeMethod · 0.80
decoratePostRequestMethod · 0.80
TestServeFunction · 0.80
fakeCHHandlerFunction · 0.80
checkResponseFunction · 0.80
getNetworkFunction · 0.80
proxy_test.goFile · 0.80
TestLogMaskFunction · 0.80

Calls

no outgoing calls

Tested by 8

TestServeFunction · 0.64
fakeCHHandlerFunction · 0.64
checkResponseFunction · 0.64
getNetworkFunction · 0.64
TestLogMaskFunction · 0.64